List of usage examples for javax.swing Box Box
public Box(int axis)
Box
that displays its components along the specified axis. From source file:greenfoot.gui.export.ExportPublishPane.java
/** * Creates the scenario information display including information such as title, description, url. * For an update (isUpdate = true), the displayed options are slightly different. */// w ww .j a va 2 s . co m private void createScenarioDisplay() { leftPanel = new Box(BoxLayout.Y_AXIS); JLabel text; MiksGridLayout titleAndDescLayout = new MiksGridLayout(6, 2, 8, 8); titleAndDescLayout.setVerticallyExpandingRow(3); titleAndDescPanel = new JPanel(titleAndDescLayout); titleAndDescPanel.setBackground(background); if (imagePanel == null) { imagePanel = new ImageEditPanel(IMAGE_WIDTH, IMAGE_HEIGHT); imagePanel.setBackground(background); } Box textPanel = new Box(BoxLayout.Y_AXIS); { text = new JLabel(Config.getString("export.publish.image1")); text.setAlignmentX(Component.RIGHT_ALIGNMENT); text.setFont(font); textPanel.add(text); text = new JLabel(Config.getString("export.publish.image2")); text.setAlignmentX(Component.RIGHT_ALIGNMENT); text.setFont(font); textPanel.add(text); } titleAndDescPanel.add(textPanel); titleAndDescPanel.add(imagePanel); if (isUpdate) { text = new JLabel(Config.getString("export.snapshot.label"), SwingConstants.TRAILING); text.setFont(font); titleAndDescPanel.add(text); keepScenarioScreenshot = new JCheckBox(); keepScenarioScreenshot.setSelected(true); // "keep screenshot" defaults to true, therefore the image panel should be disabled imagePanel.enableImageEditPanel(false); keepScenarioScreenshot.setName(Config.getString("export.publish.keepScenario")); keepScenarioScreenshot.setOpaque(false); keepScenarioScreenshot.addChangeListener(this); titleAndDescPanel.add(keepScenarioScreenshot); } text = new JLabel(Config.getString("export.publish.title"), SwingConstants.TRAILING); text.setFont(font); titleAndDescPanel.add(text); String title = project.getName(); if (getTitle() != null) { title = getTitle(); } titleField = new JTextField(title); titleField.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { String text = titleField.getText(); return text.length() > 0; } }); titleField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { checkForExistingScenario(); } }); titleAndDescPanel.add(titleField); // If there is an update a "changes" description area is shown. // If not there a short description and long description area are shown. if (isUpdate) { JLabel updateLabel = new JLabel(Config.getString("export.publish.update"), SwingConstants.TRAILING); updateLabel.setVerticalAlignment(SwingConstants.TOP); updateLabel.setFont(font); updateArea = new JTextArea(); updateArea.setRows(6); updateArea.setLineWrap(true); updateArea.setWrapStyleWord(true); JScrollPane updatePane = new JScrollPane(updateArea); titleAndDescPanel.add(updateLabel); titleAndDescPanel.add(updatePane); titleAndDescLayout.setVerticallyExpandingRow(4); } else { text = new JLabel(Config.getString("export.publish.shortDescription"), SwingConstants.TRAILING); text.setFont(font); shortDescriptionField = new JTextField(); titleAndDescPanel.add(text); titleAndDescPanel.add(shortDescriptionField); text = new JLabel(Config.getString("export.publish.longDescription"), SwingConstants.TRAILING); text.setVerticalAlignment(SwingConstants.TOP); text.setFont(font); descriptionArea = new JTextArea(); descriptionArea.setRows(6); descriptionArea.setLineWrap(true); descriptionArea.setWrapStyleWord(true); JScrollPane description = new JScrollPane(descriptionArea); titleAndDescPanel.add(text); titleAndDescPanel.add(description); } text = new JLabel(Config.getString("export.publish.url"), SwingConstants.TRAILING); text.setFont(font); titleAndDescPanel.add(text); urlField = new JTextField(); titleAndDescPanel.add(urlField); leftPanel.add(titleAndDescPanel, BorderLayout.SOUTH); JComponent sourceAndLockPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 8, 0)); { sourceAndLockPanel.setBackground(background); includeSource = new JCheckBox(Config.getString("export.publish.includeSource")); includeSource.setOpaque(false); includeSource.setSelected(false); includeSource.setFont(font); sourceAndLockPanel.add(includeSource); lockScenario.setFont(font); sourceAndLockPanel.add(lockScenario); sourceAndLockPanel.setMaximumSize(sourceAndLockPanel.getPreferredSize()); } leftPanel.add(sourceAndLockPanel, BorderLayout.SOUTH); }
From source file:uk.ac.abdn.csd.p2p.server.ServerGUI.java
/** * This method prepares all the graphical components that are contained with P2P Visualisation Server. *//* w w w .java 2s . com*/ // <editor-fold defaultstate="collapsed" desc="...GUI"> private void initializeComponent() { listeningPort = 0; JFrame frame = new JFrame(); BorderLayout layout = new BorderLayout(); //create a graph overlay = new UndirectedSparseGraph<Vertex, Edge>(); ObservableGraph<Vertex, Edge> og = new ObservableGraph<Vertex, Edge>(overlay); /* og.addGraphEventListener(new GraphEventListener<Vertex, Edge>() { @Override public void handleGraphEvent( GraphEvent<Vertex, Edge> evt) { System.err.println("got " + evt); } });*/ this.overlay = og; layout1 = new FRLayout2<Vertex, Edge>(overlay); vv = new VisualizationViewer<Vertex, Edge>(layout1, new Dimension(700, 200)); vv.setGraphMouse(new DefaultModalGraphMouse<Vertex, Edge>()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Vertex>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); vv.getRenderContext().setVertexFillPaintTransformer(new VertexPainter()); DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse(); gm1.setMode(ModalGraphMouse.Mode.TRANSFORMING); gm1.setMode(ModalGraphMouse.Mode.PICKING); gm1.add(new MyPopupGraphMousePlugin()); vv.setGraphMouse(gm1); vv.addKeyListener(gm1.getModeKeyListener()); contentPane = new JPanel(layout); displayPanel = new javax.swing.JPanel(); consoleTextArea = new JTextArea(); jScrollPane2 = new JScrollPane(); clearButton = new JButton(); consolePanel = new JPanel(); clearButton = new javax.swing.JButton(); nodeTextArea = new JTextArea(); jScrollPane1 = new JScrollPane(); nodePanel = new JPanel(); linkTextArea = new JTextArea(); jScrollPane3 = new JScrollPane(); linkPanel = new JPanel(); menuBar = new javax.swing.JMenuBar(); serverMenu = new javax.swing.JMenu(); startServerMenuItem = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JPopupMenu.Separator(); exitMenuItem = new javax.swing.JMenuItem(); editMenu = new javax.swing.JMenu(); settingMenuItem = new javax.swing.JMenuItem(); colorSettingMenuItem = new javax.swing.JMenuItem(); toolMenuItem = new javax.swing.JMenu(); clearMenuItem = new javax.swing.JMenuItem(); helpMenu = new javax.swing.JMenu(); aboutMenuItem = new javax.swing.JMenuItem(); zoominMenuItem = new javax.swing.JMenuItem(); zoomoutMenuItem = new javax.swing.JMenuItem(); layoutSettingMenuItem = new javax.swing.JMenuItem(); labelPositionMenuItem = new javax.swing.JMenuItem(); speedSettingMenuItem = new javax.swing.JMenuItem(); topologySettingMenuItem = new javax.swing.JMenuItem(); findNodeMenuItem = new javax.swing.JMenuItem(); serverMenu.setText("Server"); serverMenu.setToolTipText("Server"); startServerMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK)); startServerMenuItem.setText("Start Server"); startServerMenuItem.setToolTipText("Start Server"); startServerMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { startServerMenuItemActionPerformed(evt); } }); serverMenu.add(startServerMenuItem); serverMenu.add(jSeparator1); exitMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK)); exitMenuItem.setText("Exit"); exitMenuItem.setToolTipText("Exit"); exitMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { exitMenuItemActionPerformed(evt); } }); serverMenu.add(exitMenuItem); menuBar.add(serverMenu); editMenu.setText("Edit"); editMenu.setToolTipText("Edit"); settingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK)); settingMenuItem.setText("Server Settings"); settingMenuItem.setToolTipText("Server Settings"); settingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { settingMenuItemActionPerformed(evt); } }); editMenu.add(settingMenuItem); colorSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.ALT_MASK)); colorSettingMenuItem.setText("Colour Settings"); colorSettingMenuItem.setToolTipText("Colour Settings"); colorSettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { colorSettingMenuItemActionPerformed(evt); } }); editMenu.add(colorSettingMenuItem); layoutSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.ALT_MASK)); layoutSettingMenuItem.setText("Layout Settings"); layoutSettingMenuItem.setToolTipText("Layout Settings"); layoutSettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { layoutSettingMenuItemActionPerformed(evt); } }); editMenu.add(layoutSettingMenuItem); speedSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.ALT_MASK)); speedSettingMenuItem.setText("Speed Settings"); speedSettingMenuItem.setToolTipText("Speed Settings"); speedSettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { speedSettingMenuItemActionPerformed(evt); } }); editMenu.add(speedSettingMenuItem); topologySettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.ALT_MASK)); topologySettingMenuItem.setText("Topology Settings"); topologySettingMenuItem.setToolTipText("Topology Settings"); topologySettingMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { topologySettingMenuItemActionPerformed(evt); } }); editMenu.add(topologySettingMenuItem); menuBar.add(editMenu); toolMenuItem.setText("Tools"); toolMenuItem.setToolTipText("Tools"); labelPositionMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.ALT_MASK)); labelPositionMenuItem.setText("Vertex Label Position"); labelPositionMenuItem.setToolTipText("Vertex Label Position"); toolMenuItem.add(labelPositionMenuItem); labelPositionMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { labelPositionMenuItemActionPerformed(evt); } }); final ScalingControl scaler = new CrossoverScalingControl(); zoominMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.ALT_MASK)); zoominMenuItem.setText("Zoom-In"); zoominMenuItem.setToolTipText("Zoom-In"); toolMenuItem.add(zoominMenuItem); zoominMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); zoomoutMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.ALT_MASK)); zoomoutMenuItem.setText("Zoom-Out"); zoomoutMenuItem.setToolTipText("Zoom-Out"); toolMenuItem.add(zoomoutMenuItem); zoomoutMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { scaler.scale(vv, 0.9f, vv.getCenter()); } }); findNodeMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.ALT_MASK)); findNodeMenuItem.setText("Find Node on Overlay"); findNodeMenuItem.setToolTipText("Find Node"); toolMenuItem.add(findNodeMenuItem); findNodeMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { findNodeMenuItemMenuItemActionPerformed(evt); } }); menuBar.add(toolMenuItem); helpMenu.setText("Help"); helpMenu.setToolTipText("Help"); aboutMenuItem.setText("About"); aboutMenuItem.setToolTipText("About"); aboutMenuItem.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { aboutMenuItemActionPerformed(evt); } }); helpMenu.add(aboutMenuItem); menuBar.add(helpMenu); displayPanel.setLayout(new BorderLayout()); displayPanel.setBorder(new TitledBorder("P2P Overlay")); displayPanel.add(vv); validate(); // // nodeTextArea // nodeTextArea.setEditable(false); nodeTextArea.setLineWrap(true); // // jScrollPane1 // jScrollPane1.setViewportView(nodeTextArea); //jScrollPane1.setsi // // nodePanel // nodePanel.setLayout(new BoxLayout(nodePanel, BoxLayout.X_AXIS)); nodePanel.add(jScrollPane1, 0); nodePanel.setBorder(new TitledBorder("Nodes Active")); // // linkTextArea // linkTextArea.setEditable(false); linkTextArea.setLineWrap(true); // // jScrollPane3 // jScrollPane3.setViewportView(linkTextArea); // // linkPanel // linkPanel.setLayout(new BoxLayout(linkPanel, BoxLayout.X_AXIS)); linkPanel.add(jScrollPane3, 0); linkPanel.setBorder(new TitledBorder("Node Links")); // // consoleTextArea // consoleTextArea.setEditable(false); consoleTextArea.setLineWrap(true); // // jScrollPane2 // jScrollPane2.setViewportView(consoleTextArea); // // clearButton // clearButton.setText("Clear"); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clearButton_actionPerformed(e); } }); // // consolePanel // consolePanel.setLayout(new BoxLayout(consolePanel, BoxLayout.X_AXIS)); consolePanel.add(jScrollPane2, 0); consolePanel.add(clearButton, 1); consolePanel.setBorder(new TitledBorder("Console")); // // ServerGUI // Dimension panelD = new Dimension(700, 330); // display Panel Dimension panelD1 = new Dimension(700, 134); // control Panel Dimension panelD2 = new Dimension(350, 140); // nodepanel and linkpanel Dimension panelD3 = new Dimension(700, 140); // nodepanel and linkpanel togther consolePanel.setPreferredSize(panelD1); displayPanel.setPreferredSize(panelD); nodePanel.setPreferredSize(panelD2); linkPanel.setPreferredSize(panelD2); Box box = new Box(BoxLayout.X_AXIS); // put nodepanel and linkpanel in one box box.add(nodePanel); box.add(linkPanel); box.setSize(panelD3); //contentPane.add(BorderLayout.NORTH,displayPanel); //contentPane.add(BorderLayout.CENTER,box); contentPane.add(BorderLayout.NORTH, box); contentPane.add(BorderLayout.CENTER, displayPanel); contentPane.add(BorderLayout.SOUTH, consolePanel); frame.setJMenuBar(menuBar); frame.getContentPane().add(contentPane); frame.setTitle("P2P Visualisation Server"); frame.setSize(new Dimension(800, 600)); frame.setResizable(true); // This code has been adapted from http://lookass.ch/?id=4&area=art&art=47 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension size = frame.getSize(); screenSize.height = screenSize.height / 2; screenSize.width = screenSize.width / 2; size.height = size.height / 2; size.width = size.width / 2; int y = screenSize.height - size.height; int x = screenSize.width - size.width; frame.setLocation(x, y); frame.setVisible(true); frame.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); }
From source file:PolygonOffset.java
LogFloatLabelJSlider(String name, float min, float max, float current) { this.resolution = resolution; this.min = min; this.max = max; this.current = current; if (resolution < minResolution) { resolution = minResolution;//from w w w .j a va2s . c om } minLog = log10(min); maxLog = log10(max); curLog = log10(current); // resolution is 100 steps from min to max scale = 100.0f; resolution = 1.0f / scale; // get the integer versions of max, min, current minInt = (int) Math.round(minLog * scale); maxInt = (int) Math.round(maxLog * scale); curInt = (int) Math.round(curLog * scale); slider = new JSlider(JSlider.HORIZONTAL, minInt, maxInt, curInt); slider.addChangeListener(this); valueLabel = new JLabel(" "); // Need to muck around to make sure that the width of the label // is wide enough for the largest value. Pad the initial string // be large enough to hold the largest value. int pad = 5; // fudge to make up for variable width fonts intDigits = (int) Math.ceil(maxLog) + pad; if (min < 0) { intDigits++; // add one for the '-' } if (minLog < 0) { fractDigits = (int) Math.ceil(-minLog); } else { fractDigits = 0; } nf.setMinimumFractionDigits(fractDigits); nf.setMaximumFractionDigits(fractDigits); String value = nf.format(current); while (value.length() < (intDigits + fractDigits)) { value = value + " "; } valueLabel.setText(value); // add min and max labels to the slider Hashtable labelTable = new Hashtable(); labelTable.put(new Integer(minInt), new JLabel(nf.format(min))); labelTable.put(new Integer(maxInt), new JLabel(nf.format(max))); slider.setLabelTable(labelTable); slider.setPaintLabels(true); // layout to align left setLayout(new BorderLayout()); Box box = new Box(BoxLayout.X_AXIS); add(box, BorderLayout.WEST); box.add(new JLabel(name)); box.add(slider); box.add(valueLabel); }
From source file:EnvironmentExplorer.java
Box lightPanel() { Box panel = new Box(BoxLayout.Y_AXIS); // add the ambient light checkbox to the panel JCheckBox ambientCheckBox = new JCheckBox("Ambient Light"); ambientCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JCheckBox checkbox = (JCheckBox) e.getSource(); lightAmbient.setEnable(checkbox.isSelected()); }/*from w ww .ja v a 2 s . c om*/ }); ambientCheckBox.setSelected(true); panel.add(new LeftAlignComponent(ambientCheckBox)); String[] lightTypeValues = { "None", "Directional", "Positional", "Spot" }; IntChooser lightTypeChooser = new IntChooser("Light Type:", lightTypeValues); lightTypeChooser.addIntListener(new IntListener() { public void intChanged(IntEvent event) { int value = event.getValue(); switch (value) { case 0: lightDirectional.setEnable(false); lightPoint.setEnable(false); lightSpot.setEnable(false); break; case 1: lightDirectional.setEnable(true); lightPoint.setEnable(false); lightSpot.setEnable(false); break; case 2: lightDirectional.setEnable(false); lightPoint.setEnable(true); lightSpot.setEnable(false); break; case 3: lightDirectional.setEnable(false); lightPoint.setEnable(false); lightSpot.setEnable(true); break; } } }); lightTypeChooser.setValueByName("Directional"); panel.add(lightTypeChooser); // Set up the sliders for the attenuation // top row panel.add(new LeftAlignComponent(new JLabel("Light attenuation:"))); FloatLabelJSlider constantSlider = new FloatLabelJSlider("Constant ", 0.1f, 0.0f, 3.0f, attenuation.x); constantSlider.setMajorTickSpacing(1.0f); constantSlider.setPaintTicks(true); constantSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.x = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(constantSlider); FloatLabelJSlider linearSlider = new FloatLabelJSlider("Linear ", 0.1f, 0.0f, 3.0f, attenuation.y); linearSlider.setMajorTickSpacing(1.0f); linearSlider.setPaintTicks(true); linearSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.y = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(linearSlider); FloatLabelJSlider quadradicSlider = new FloatLabelJSlider("Quadradic", 0.1f, 0.0f, 3.0f, attenuation.z); quadradicSlider.setMajorTickSpacing(1.0f); quadradicSlider.setPaintTicks(true); quadradicSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { attenuation.z = e.getValue(); lightPoint.setAttenuation(attenuation); lightSpot.setAttenuation(attenuation); } }); panel.add(quadradicSlider); // Set up the sliders for the attenuation // top row panel.add(new LeftAlignComponent(new JLabel("Spot light:"))); // spread angle is 0-180 degrees, no slider scaling FloatLabelJSlider spotSpreadSlider = new FloatLabelJSlider("Spread Angle ", 1.0f, 0.0f, 180.0f, spotSpreadAngle); spotSpreadSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { spotSpreadAngle = e.getValue(); lightSpot.setSpreadAngle((float) Math.toRadians(spotSpreadAngle)); } }); panel.add(spotSpreadSlider); // concentration angle is 0-128 degrees FloatLabelJSlider spotConcentrationSlider = new FloatLabelJSlider("Concentration", 1.0f, 0.0f, 128.0f, spotConcentration); spotConcentrationSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { spotConcentration = e.getValue(); lightSpot.setConcentration(spotConcentration); } }); panel.add(spotConcentrationSlider); return panel; }
From source file:TransformExplorer.java
Box refPtPanel() { Box panel = new Box(BoxLayout.Y_AXIS); panel.add(new LeftAlignComponent(new JLabel("Reference Point Coordinates"))); // X Ref Pt/*from ww w . java 2 s . c o m*/ FloatLabelJSlider coneRefPtXSlider = new FloatLabelJSlider("X", 0.1f, -2.0f, 2.0f, coneRefPt.x); coneRefPtXSlider.setMajorTickSpacing(1.0f); coneRefPtXSlider.setPaintTicks(true); coneRefPtXSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { coneRefPt.x = e.getValue(); useCompoundTransform = true; updateUsingCompoundTransform(); rotAxis.setRefPt(coneRefPt); } }); panel.add(coneRefPtXSlider); // Y Ref Pt FloatLabelJSlider coneRefPtYSlider = new FloatLabelJSlider("Y", 0.1f, -2.0f, 2.0f, coneRefPt.y); coneRefPtYSlider.setMajorTickSpacing(1.0f); coneRefPtYSlider.setPaintTicks(true); coneRefPtYSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { coneRefPt.y = e.getValue(); useCompoundTransform = true; updateUsingCompoundTransform(); rotAxis.setRefPt(coneRefPt); } }); panel.add(coneRefPtYSlider); // Z Ref Pt FloatLabelJSlider coneRefPtZSlider = new FloatLabelJSlider("Z", 0.1f, -2.0f, 2.0f, coneRefPt.z); coneRefPtZSlider.setMajorTickSpacing(1.0f); coneRefPtZSlider.setPaintTicks(true); coneRefPtZSlider.addFloatListener(new FloatListener() { public void floatChanged(FloatEvent e) { coneRefPt.z = e.getValue(); useCompoundTransform = true; updateUsingCompoundTransform(); rotAxis.setRefPt(coneRefPt); } }); panel.add(coneRefPtZSlider); return panel; }
From source file:com.isencia.passerelle.hmi.generic.GenericHMI.java
@SuppressWarnings("unchecked") private void renderModelComponentAnnotations(final NamedObj e, final JPanel b) { final List<TextAttribute> annotations = e.attributeList(TextAttribute.class); if (!annotations.isEmpty()) { final Box annotationsBox = new Box(BoxLayout.Y_AXIS); // annotationsBox.setBorder(BorderFactory.createTitledBorder("Info")); for (final TextAttribute textAttribute : annotations) { if (isAnnotionAuthorizedForEditor(textAttribute)) { final Box subBox = new Box(BoxLayout.Y_AXIS); // subBox.setBorder(BorderFactory.createTitledBorder(textAttribute.getName())); final String[] annotationLines = textAttribute.text.getExpression().split("\n"); for (final String annotationLine : annotationLines) { final JLabel lab = new JLabel(annotationLine); textAttribute.fontFamily.getExpression(); int bold = 0; if (textAttribute.bold.getExpression().compareTo("true") == 0) { bold = Font.BOLD; }/*from w w w.ja v a 2 s . c om*/ int italic = 0; if (textAttribute.italic.getExpression().compareTo("true") == 0) { italic = Font.ITALIC; } final int textSize = Integer.valueOf(textAttribute.textSize.getExpression()); final Font font = new Font(textAttribute.fontFamily.getExpression(), bold | italic, textSize); lab.setFont(font); final String colorString = textAttribute.textColor.getExpression(); final String sub = colorString.substring(1, colorString.lastIndexOf("}")); final String[] rgba = sub.split(","); final float r = Float.valueOf(rgba[0]); final float g = Float.valueOf(rgba[1]); final float bl = Float.valueOf(rgba[2]); final float a = Float.valueOf(rgba[3]); final Color color = new Color(r, g, bl, a); lab.setForeground(color); subBox.add(lab); } annotationsBox.add(subBox); } } b.add(annotationsBox); } }
From source file:greenfoot.gui.export.ExportPublishPane.java
/** * Creates the tag display with popular tags and an option to add tags *///from w ww .ja va 2 s. c om private JComponent getTagDisplay() { JComponent tagPanel = new JPanel(new MiksGridLayout(3, 1, 8, 8)); { tagPanel.setBackground(background); JComponent popPanel = new JPanel(new MiksGridLayout(8, 1, 8, 0)); popPanel.setBackground(background); JLabel popLabel = new JLabel(Config.getString("export.publish.tags.popular"), SwingConstants.LEADING); popLabel.setFont(font); popPanel.add(popLabel); for (int i = 0; i < popTags.length; i++) { JCheckBox popTag = new JCheckBox(Config.getString("export.publish.tags.loading")); popTag.setBackground(background); popTag.setFont(font); popTag.setEnabled(false); popTags[i] = popTag; popPanel.add(popTag); } tagPanel.add(popPanel); Box textPanel = new Box(BoxLayout.Y_AXIS); { JLabel additionalLabel = new JLabel(Config.getString("export.publish.tags.additional1"), SwingConstants.LEADING); additionalLabel.setFont(font); textPanel.add(additionalLabel); JLabel additionalLabel2 = new JLabel(Config.getString("export.publish.tags.additional2"), SwingConstants.CENTER); additionalLabel2.setFont(font); textPanel.add(additionalLabel2); } tagPanel.add(textPanel); tagArea = new JTextArea(); tagArea.setRows(3); JScrollPane tagScroller = new JScrollPane(tagArea); tagPanel.add(tagScroller); } return tagPanel; }
From source file:net.rptools.maptool.launcher.MapToolLauncher.java
private JPanel buildTroubleshootingPanel() { final JPanel p = new JPanel(); p.setLayout(new BorderLayout()); ActionListener levelChange = new ActionListener() { @Override/*from www . jav a 2s . com*/ public void actionPerformed(ActionEvent e) { Level x = Level.parse(e.getActionCommand()); if (Level.OFF.equals(x) || Level.INFO.equals(x) || Level.WARNING.equals(x) || Level.SEVERE.equals(x)) log.setLevel(x); } }; JPanel logPanel = new JPanel(); logPanel.setLayout(new GridLayout(0, 1)); logPanel.setBorder(new TitledBorder(new LineBorder(Color.BLACK), CopiedFromOtherJars.getText("msg.logDetailPanel.border"))); //$NON-NLS-1$ logPanel.setAlignmentX(Component.LEFT_ALIGNMENT); ButtonGroup logGroup = new ButtonGroup(); for (Level type : new Level[] { Level.OFF, Level.INFO, Level.WARNING, Level.SEVERE }) { JRadioButton jrb = new JRadioButton(type.toString()); jrb.setActionCommand(type.toString()); jrb.addActionListener(levelChange); jrb.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), jrb.getBorder())); logPanel.add(jrb); logGroup.add(jrb); if (type == Level.WARNING) { jrb.setSelected(true); log.setLevel(type); } } jcbEnableAssertions.setAlignmentX(Component.LEFT_ALIGNMENT); jcbEnableAssertions.setText(CopiedFromOtherJars.getText("msg.info.enableAssertions")); //$NON-NLS-1$ jcbEnableAssertions.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.enableAssertions")); //$NON-NLS-1$ jcbEnableAssertions.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (!extraArgs.contains(ASSERTIONS_OPTION)) { extraArgs = (ASSERTIONS_OPTION + " " + extraArgs); //$NON-NLS-1$ } } else if (e.getStateChange() == ItemEvent.DESELECTED) { extraArgs = extraArgs.replace(ASSERTIONS_OPTION, ""); //$NON-NLS-1$ } extraArgs = extraArgs.trim(); jtfArgs.setText(extraArgs); updateCommand(); } }); p.add(logPanel, BorderLayout.NORTH); Box other = new Box(BoxLayout.PAGE_AXIS); other.add(jcbEnableAssertions); other.add(Box.createVerticalGlue()); p.add(other, BorderLayout.CENTER); return p; }
From source file:AppearanceExplorer.java
IntChooser(String name, String[] initChoiceNames, int[] initChoiceValues, int initValue) { if ((initChoiceValues != null) && (initChoiceNames.length != initChoiceValues.length)) { throw new IllegalArgumentException("Name and Value arrays must have the same length"); }/*from w w w. j a v a 2 s .c om*/ choiceNames = new String[initChoiceNames.length]; choiceValues = new int[initChoiceNames.length]; System.arraycopy(initChoiceNames, 0, choiceNames, 0, choiceNames.length); if (initChoiceValues != null) { System.arraycopy(initChoiceValues, 0, choiceValues, 0, choiceNames.length); } else { for (int i = 0; i < initChoiceNames.length; i++) { choiceValues[i] = i; } } // Create the combo box, select the init value combo = new JComboBox(choiceNames); combo.setSelectedIndex(current); combo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); int index = cb.getSelectedIndex(); setValueIndex(index); } }); // set the initial value current = 0; setValue(initValue); // layout to align left setLayout(new BorderLayout()); Box box = new Box(BoxLayout.X_AXIS); add(box, BorderLayout.WEST); box.add(new JLabel(name)); box.add(combo); }
From source file:AppearanceExplorer.java
public Color3fEditor(String initName, Color3f initColor) { name = initName;// ww w. j av a 2 s. c o m color.set(initColor); JLabel label = new JLabel(name); preview = new JPanel(); preview.setPreferredSize(new Dimension(40, 40)); preview.setBackground(color.get()); preview.setBorder(BorderFactory.createRaisedBevelBorder()); button = new JButton("Set"); button.addActionListener(this); JPanel filler = new JPanel(); filler.setPreferredSize(new Dimension(100, 20)); setLayout(new BorderLayout()); Box box = new Box(BoxLayout.X_AXIS); add(box, BorderLayout.WEST); box.add(label); box.add(preview); box.add(button); box.add(filler); }