List of usage examples for javax.swing JComboBox JComboBox
public JComboBox()
JComboBox
with a default data model. From source file:com.itemanalysis.jmetrik.swing.GraphOptionPanel.java
private void initComponents() { orientationButtonGroup = new ButtonGroup(); colorPanel = new JPanel(); color1Label = new JLabel(); colorLabel2 = new JLabel(); colorButton1 = new JButton(); colorButton2 = new JButton(); colorLabel3 = new JLabel(); colorButton3 = new JButton(); colorLabel4 = new JLabel(); colorButton4 = new JButton(); colorLabel5 = new JLabel(); colorButton5 = new JButton(); colorLabel6 = new JLabel(); colorButton6 = new JButton(); colorLabel7 = new JLabel(); colorButton7 = new JButton(); colorLabel8 = new JLabel(); colorButton8 = new JButton(); colorLabel9 = new JLabel(); colorButton9 = new JButton(); lineStylePanel = new JPanel(); lineLabel1 = new JLabel(); lineStyleComboBox1 = new JComboBox(); lineLabel2 = new JLabel(); lineStyleComboBox2 = new JComboBox(); lineLabel3 = new JLabel(); lineStyleComboBox3 = new JComboBox(); lineLabel4 = new JLabel(); lineStyleComboBox4 = new JComboBox(); lineLabel5 = new JLabel(); lineStyleComboBox5 = new JComboBox(); lineLabel6 = new JLabel(); lineStyleComboBox6 = new JComboBox(); lineLabel7 = new JLabel(); lineStyleComboBox7 = new JComboBox(); lineLabel8 = new JLabel(); lineStyleComboBox8 = new JComboBox(); lineLabel9 = new JLabel(); lineStyleComboBox9 = new JComboBox(); lineWidthLabel = new JLabel(); lineWidthTextField = new JTextField(); displayPanel = new JPanel(); legendPositionComboBox = new JComboBox(); legendCheckbox = new JCheckBox(); markersCheckbox = new JCheckBox(); horizontalRadioButton = new JRadioButton(); verticalRadioButton = new JRadioButton(); sizePanel = new JPanel(); widthLabel = new JLabel(); widthTextField = new JTextField(); heightLabel = new JLabel(); heightTextField = new JTextField(); resetButton = new JButton(); // setBorder(BorderFactory.createTitledBorder("")); colorPanel.setBorder(BorderFactory.createTitledBorder("Color Sequence")); color1Label.setText("Color 1"); colorLabel2.setText("Color 2"); colorButton1.setText("Choose Color"); colorButton1.setMaximumSize(new Dimension(116, 25)); colorButton1.setMinimumSize(new Dimension(116, 25)); colorButton1.setPreferredSize(new Dimension(116, 25)); colorButton1.setBackground(color[0]); colorButton1.addActionListener(new ActionListener() { @Override/*from w w w.java 2 s.c o m*/ public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(GraphOptionPanel.this, "Color 1", color[0]); if (newColor != null) { colorButton1.setBackground(newColor); color[0] = newColor; } } }); colorButton2.setText("Choose Color"); colorButton2.setMaximumSize(new Dimension(116, 25)); colorButton2.setMinimumSize(new Dimension(116, 25)); colorButton2.setPreferredSize(new Dimension(116, 25)); colorButton2.setBackground(color[1]); colorButton2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(GraphOptionPanel.this, "Color 2", color[1]); if (newColor != null) { colorButton2.setBackground(newColor); color[1] = newColor; } } }); colorLabel3.setText("Color 3"); colorButton3.setText("Choose Color"); colorButton3.setMaximumSize(new Dimension(116, 25)); colorButton3.setMinimumSize(new Dimension(116, 25)); colorButton3.setPreferredSize(new Dimension(116, 25)); colorButton3.setBackground(color[2]); colorButton3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(GraphOptionPanel.this, "Color 3", color[2]); if (newColor != null) { colorButton3.setBackground(newColor); color[2] = newColor; } } }); colorLabel4.setText("Color 4"); colorButton4.setText("Choose Color"); colorButton4.setMaximumSize(new Dimension(116, 25)); colorButton4.setMinimumSize(new Dimension(116, 25)); colorButton4.setPreferredSize(new Dimension(116, 25)); colorButton4.setBackground(color[3]); colorButton4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(GraphOptionPanel.this, "Color 4", color[3]); if (newColor != null) { colorButton4.setBackground(newColor); color[3] = newColor; } } }); colorLabel5.setText("Color 5"); colorButton5.setText("Choose Color"); colorButton5.setMaximumSize(new Dimension(116, 25)); colorButton5.setMinimumSize(new Dimension(116, 25)); colorButton5.setPreferredSize(new Dimension(116, 25)); colorButton5.setBackground(color[4]); colorButton5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(GraphOptionPanel.this, "Color 5", color[4]); if (newColor != null) { colorButton5.setBackground(newColor); color[4] = newColor; } } }); colorLabel6.setText("Color 6"); colorButton6.setText("Choose Color"); colorButton6.setMaximumSize(new Dimension(116, 25)); colorButton6.setMinimumSize(new Dimension(116, 25)); colorButton6.setPreferredSize(new Dimension(116, 25)); colorButton6.setBackground(color[5]); colorButton6.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(GraphOptionPanel.this, "Color 6", color[5]); if (newColor != null) { colorButton6.setBackground(newColor); color[5] = newColor; } } }); colorLabel7.setText("Color 7"); colorButton7.setText("Choose Color"); colorButton7.setMaximumSize(new Dimension(116, 25)); colorButton7.setMinimumSize(new Dimension(116, 25)); colorButton7.setPreferredSize(new Dimension(116, 25)); colorButton7.setBackground(color[6]); colorButton7.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(GraphOptionPanel.this, "Color 7", color[6]); if (newColor != null) { colorButton7.setBackground(newColor); color[6] = newColor; } } }); colorLabel8.setText("Color 8"); colorButton8.setText("Choose Color"); colorButton8.setMaximumSize(new Dimension(116, 25)); colorButton8.setMinimumSize(new Dimension(116, 25)); colorButton8.setPreferredSize(new Dimension(116, 25)); colorButton8.setBackground(color[7]); colorButton8.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(GraphOptionPanel.this, "Color 8", color[7]); if (newColor != null) { colorButton8.setBackground(newColor); color[7] = newColor; } } }); colorLabel9.setText("Color 9"); colorButton9.setText("Choose Color"); colorButton9.setMaximumSize(new Dimension(116, 25)); colorButton9.setMinimumSize(new Dimension(116, 25)); colorButton9.setPreferredSize(new Dimension(116, 25)); colorButton9.setBackground(color[8]); colorButton9.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(GraphOptionPanel.this, "Color 9", color[8]); if (newColor != null) { colorButton9.setBackground(newColor); color[8] = newColor; } } }); GroupLayout colorPanelLayout = new GroupLayout(colorPanel); colorPanel.setLayout(colorPanelLayout); colorPanelLayout.setHorizontalGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(colorPanelLayout.createSequentialGroup().addContainerGap() .addGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(colorPanelLayout.createSequentialGroup().addComponent(color1Label) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(colorButton1, GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)) .addGroup(colorPanelLayout.createSequentialGroup().addComponent(colorLabel2) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(colorButton2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(colorPanelLayout.createSequentialGroup().addComponent(colorLabel3) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(colorButton3, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(colorPanelLayout.createSequentialGroup().addComponent(colorLabel4) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(colorButton4, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(colorPanelLayout.createSequentialGroup().addComponent(colorLabel5) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(colorButton5, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(colorPanelLayout.createSequentialGroup().addComponent(colorLabel6) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(colorButton6, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(colorPanelLayout.createSequentialGroup().addComponent(colorLabel7) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(colorButton7, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(colorPanelLayout.createSequentialGroup().addComponent(colorLabel8) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(colorButton8, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(colorPanelLayout.createSequentialGroup().addComponent(colorLabel9) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(colorButton9, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap())); colorPanelLayout.setVerticalGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(colorPanelLayout.createSequentialGroup().addContainerGap() .addGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(color1Label).addComponent(colorButton1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(colorLabel2).addComponent(colorButton2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(colorLabel3).addComponent(colorButton3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(colorLabel4).addComponent(colorButton4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(colorLabel5).addComponent(colorButton5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(colorLabel6).addComponent(colorButton6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(colorLabel7).addComponent(colorButton7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(colorLabel8).addComponent(colorButton8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(colorPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(colorLabel9).addComponent(colorButton9, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); lineStylePanel.setBorder(BorderFactory.createTitledBorder("Line Styles")); lineLabel1.setText("Line 1"); lineStyleComboBox1.setModel(new DefaultComboBoxModel(ChartStyle.LINE_STYLE_NAME)); lineStyleComboBox1.setRenderer(new LineStyleComboBoxRenderer()); lineStyleComboBox1.setSelectedItem(ChartStyle.floatStyleToString(selectedLineStyles[0])); lineStyleComboBox1.setMinimumSize(new Dimension(150, 25)); lineStyleComboBox1.setPreferredSize(new Dimension(150, 25)); lineLabel2.setText("Line 2"); lineStyleComboBox2.setModel(new DefaultComboBoxModel(ChartStyle.LINE_STYLE_NAME)); lineStyleComboBox2.setRenderer(new LineStyleComboBoxRenderer()); lineStyleComboBox2.setSelectedItem(ChartStyle.floatStyleToString(selectedLineStyles[1])); lineStyleComboBox2.setMinimumSize(new Dimension(150, 25)); lineStyleComboBox2.setPreferredSize(new Dimension(150, 25)); lineLabel3.setText("Line 3"); lineStyleComboBox3.setModel(new DefaultComboBoxModel(ChartStyle.LINE_STYLE_NAME)); lineStyleComboBox3.setRenderer(new LineStyleComboBoxRenderer()); lineStyleComboBox3.setSelectedItem(ChartStyle.floatStyleToString(selectedLineStyles[2])); lineStyleComboBox3.setMinimumSize(new Dimension(150, 25)); lineStyleComboBox3.setPreferredSize(new Dimension(150, 25)); lineLabel4.setText("Line 4"); lineStyleComboBox4.setModel(new DefaultComboBoxModel(ChartStyle.LINE_STYLE_NAME)); lineStyleComboBox4.setRenderer(new LineStyleComboBoxRenderer()); lineStyleComboBox4.setSelectedItem(ChartStyle.floatStyleToString(selectedLineStyles[3])); lineStyleComboBox4.setMinimumSize(new Dimension(150, 25)); lineStyleComboBox4.setPreferredSize(new Dimension(150, 25)); lineLabel5.setText("Line 5"); lineStyleComboBox5.setModel(new DefaultComboBoxModel(ChartStyle.LINE_STYLE_NAME)); lineStyleComboBox5.setRenderer(new LineStyleComboBoxRenderer()); lineStyleComboBox5.setSelectedItem(ChartStyle.floatStyleToString(selectedLineStyles[4])); lineStyleComboBox5.setMinimumSize(new Dimension(150, 25)); lineStyleComboBox5.setPreferredSize(new Dimension(150, 25)); lineLabel6.setText("Line 6"); lineStyleComboBox6.setModel(new DefaultComboBoxModel(ChartStyle.LINE_STYLE_NAME)); lineStyleComboBox6.setRenderer(new LineStyleComboBoxRenderer()); lineStyleComboBox6.setSelectedItem(ChartStyle.floatStyleToString(selectedLineStyles[5])); lineStyleComboBox6.setMinimumSize(new Dimension(150, 25)); lineStyleComboBox6.setPreferredSize(new Dimension(150, 25)); lineLabel7.setText("Line 7"); lineStyleComboBox7.setModel(new DefaultComboBoxModel(ChartStyle.LINE_STYLE_NAME)); lineStyleComboBox7.setRenderer(new LineStyleComboBoxRenderer()); lineStyleComboBox7.setSelectedItem(ChartStyle.floatStyleToString(selectedLineStyles[6])); lineStyleComboBox7.setMinimumSize(new Dimension(150, 25)); lineStyleComboBox7.setPreferredSize(new Dimension(150, 25)); lineLabel8.setText("Line 8"); lineStyleComboBox8.setModel(new DefaultComboBoxModel(ChartStyle.LINE_STYLE_NAME)); lineStyleComboBox8.setRenderer(new LineStyleComboBoxRenderer()); lineStyleComboBox8.setSelectedItem(ChartStyle.floatStyleToString(selectedLineStyles[7])); lineStyleComboBox8.setMinimumSize(new Dimension(150, 25)); lineStyleComboBox8.setPreferredSize(new Dimension(150, 25)); lineLabel9.setText("Line 9"); lineStyleComboBox9.setModel(new DefaultComboBoxModel(ChartStyle.LINE_STYLE_NAME)); lineStyleComboBox9.setRenderer(new LineStyleComboBoxRenderer()); lineStyleComboBox9.setSelectedItem(ChartStyle.floatStyleToString(selectedLineStyles[8])); lineStyleComboBox9.setMinimumSize(new Dimension(150, 25)); lineStyleComboBox9.setPreferredSize(new Dimension(150, 25)); GroupLayout lineStylePanelLayout = new GroupLayout(lineStylePanel); lineStylePanel.setLayout(lineStylePanelLayout); lineStylePanelLayout.setHorizontalGroup(lineStylePanelLayout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(lineStylePanelLayout.createSequentialGroup().addContainerGap() .addGroup(lineStylePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(lineStylePanelLayout.createSequentialGroup().addComponent(lineLabel1) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lineStyleComboBox1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(lineStylePanelLayout.createSequentialGroup().addComponent(lineLabel2) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lineStyleComboBox2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(lineStylePanelLayout.createSequentialGroup().addComponent(lineLabel3) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lineStyleComboBox3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(lineStylePanelLayout.createSequentialGroup().addComponent(lineLabel4) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lineStyleComboBox4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(lineStylePanelLayout.createSequentialGroup().addComponent(lineLabel5) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lineStyleComboBox5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(lineStylePanelLayout.createSequentialGroup().addComponent(lineLabel6) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lineStyleComboBox6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(lineStylePanelLayout.createSequentialGroup().addComponent(lineLabel7) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lineStyleComboBox7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(lineStylePanelLayout.createSequentialGroup().addComponent(lineLabel8) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lineStyleComboBox8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(lineStylePanelLayout.createSequentialGroup().addComponent(lineLabel9) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(lineStyleComboBox9, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); lineStylePanelLayout .setVerticalGroup(lineStylePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(lineStylePanelLayout.createSequentialGroup().addContainerGap() .addGroup(lineStylePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lineLabel1).addComponent(lineStyleComboBox1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(lineStylePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lineLabel2).addComponent(lineStyleComboBox2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(lineStylePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lineLabel3).addComponent(lineStyleComboBox3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(lineStylePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lineLabel4).addComponent(lineStyleComboBox4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(lineStylePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lineLabel5).addComponent(lineStyleComboBox5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(lineStylePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lineLabel6).addComponent(lineStyleComboBox6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(lineStylePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lineLabel7).addComponent(lineStyleComboBox7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(lineStylePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lineLabel8).addComponent(lineStyleComboBox8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(lineStylePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lineLabel9).addComponent(lineStyleComboBox9, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); displayPanel.setBorder(BorderFactory.createTitledBorder("Display Options")); legendPositionComboBox .setModel(new DefaultComboBoxModel(new String[] { "Bottom", "Left", "Top", "Right" })); legendPositionComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String s = legendPositionComboBox.getSelectedItem().toString(); if ("Bottom".equals(s)) { prefs.setLegendPosition(RectangleEdge.BOTTOM); } else if ("Left".equals(s)) { prefs.setLegendPosition(RectangleEdge.LEFT); } else if ("Top".equals(s)) { prefs.setLegendPosition(RectangleEdge.TOP); } else { prefs.setLegendPosition(RectangleEdge.RIGHT); } } }); legendCheckbox.setSelected(true); legendCheckbox.setText("Legend"); legendCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (legendCheckbox.isSelected()) { prefs.setShowLegend(true); } else { prefs.setShowLegend(false); } } }); markersCheckbox.setText("Point markers"); markersCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (markersCheckbox.isSelected()) { prefs.setShowMarkers(true); } else { prefs.setShowMarkers(false); } } }); orientationButtonGroup.add(horizontalRadioButton); horizontalRadioButton.setText("Horizontal orientation"); horizontalRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (horizontalRadioButton.isSelected()) { prefs.setChartOrientation(PlotOrientation.HORIZONTAL); } } }); orientationButtonGroup.add(verticalRadioButton); verticalRadioButton.setSelected(true); verticalRadioButton.setText("Vertical orientation"); verticalRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (verticalRadioButton.isSelected()) { prefs.setChartOrientation(PlotOrientation.VERTICAL); } } }); GroupLayout displayPanelLayout = new GroupLayout(displayPanel); displayPanel.setLayout(displayPanelLayout); displayPanelLayout.setHorizontalGroup(displayPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(displayPanelLayout.createSequentialGroup().addContainerGap().addGroup(displayPanelLayout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(displayPanelLayout.createSequentialGroup().addGroup(displayPanelLayout .createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(markersCheckbox) .addGroup(displayPanelLayout.createSequentialGroup().addComponent(legendCheckbox) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(legendPositionComboBox, 0, 89, Short.MAX_VALUE))) .addGap(26, 26, 26)) .addGroup(displayPanelLayout.createSequentialGroup().addComponent(horizontalRadioButton) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(displayPanelLayout.createSequentialGroup().addComponent(verticalRadioButton) .addGap(0, 0, Short.MAX_VALUE))))); displayPanelLayout.setVerticalGroup(displayPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(displayPanelLayout.createSequentialGroup().addContainerGap() .addGroup(displayPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(legendCheckbox).addComponent(legendPositionComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(markersCheckbox) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(horizontalRadioButton) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(verticalRadioButton) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); sizePanel.setBorder(BorderFactory.createTitledBorder("Chart Size")); widthLabel.setText("Width"); widthTextField.setText("450"); widthTextField.setMaximumSize(new Dimension(100, 25)); widthTextField.setMinimumSize(new Dimension(100, 25)); widthTextField.setPreferredSize(new Dimension(100, 25)); widthTextField.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { //do nothing } @Override public void focusLost(FocusEvent e) { String s = widthTextField.getText(); try { int w = Integer.parseInt(s); prefs.setChartWidth(w); } catch (NumberFormatException ex) { widthTextField.setText("450"); } } }); heightLabel.setText("Height"); heightTextField.setText("400"); heightTextField.setMaximumSize(new Dimension(100, 25)); heightTextField.setMinimumSize(new Dimension(100, 25)); heightTextField.setPreferredSize(new Dimension(100, 25)); heightTextField.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { //do nothing } @Override public void focusLost(FocusEvent e) { try { String s = heightTextField.getText(); int h = Integer.parseInt(s); prefs.setChartHeight(h); } catch (NumberFormatException ex) { heightTextField.setText("400"); } } }); lineWidthLabel.setText("Line width"); lineWidthTextField.setText("1.0"); lineWidthTextField.setMaximumSize(new Dimension(100, 25)); lineWidthTextField.setMinimumSize(new Dimension(100, 25)); lineWidthTextField.setPreferredSize(new Dimension(100, 25)); lineWidthTextField.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { //do nothing } @Override public void focusLost(FocusEvent e) { try { String s = lineWidthTextField.getText(); float lw = Float.parseFloat(s); prefs.setChartLineWidth(lw); } catch (NumberFormatException ex) { lineWidthTextField.setText("1.0"); } } }); GroupLayout sizePanelLayout = new GroupLayout(sizePanel); sizePanel.setLayout(sizePanelLayout); sizePanelLayout.setHorizontalGroup(sizePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(sizePanelLayout.createSequentialGroup().addContainerGap() .addGroup(sizePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(widthLabel).addComponent(heightLabel).addComponent(lineWidthLabel)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(sizePanelLayout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(widthTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(heightTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lineWidthTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); sizePanelLayout.setVerticalGroup(sizePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(sizePanelLayout.createSequentialGroup().addContainerGap() .addGroup(sizePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(widthLabel).addComponent(widthTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(sizePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(heightLabel).addComponent(heightTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(sizePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(lineWidthLabel).addComponent(lineWidthTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); resetButton.setText("Reset to Default Chart Options"); resetButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { resetPanel(); } }); GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout .createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout .createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false) .addComponent(displayPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(colorPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(lineStylePanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(sizePanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addComponent(resetButton)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(colorPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lineStylePanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(sizePanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(displayPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(resetButton) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); }
From source file:EditorPaneExample11.java
public EditorPaneExample11() { super("JEditorPane Example 11"); pane = new JEditorPane(); pane.setEditable(false); // Read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;// w w w . j a v a 2 s . c om c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Allocate the empty tree model DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty"); emptyModel = new DefaultTreeModel(emptyRootNode); // Create and place the heading tree tree = new JTree(emptyModel); tree.setPreferredSize(new Dimension(200, 200)); getContentPane().add(new JScrollPane(tree), "East"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); try { // Check if the new page and the old // page are the same. URL url; if (selection instanceof URL) { url = (URL) selection; } else { url = new URL((String) selection); } URL loadedURL = pane.getPage(); if (loadedURL != null && loadedURL.sameFile(url)) { return; } // Try to display the page urlCombo.setEnabled(false); // Disable input urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Busy cursor loadingState.setText("Loading..."); loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height); loadedType.setText(""); loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height); timeLabel.setText(""); timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height); // Display an empty tree while loading tree.setModel(emptyModel); tree.paintImmediately(0, 0, tree.getSize().width, tree.getSize().height); startTime = System.currentTimeMillis(); // Choose the loading method if (onlineLoad.isSelected()) { // Usual load via setPage pane.setPage(url); loadedType.setText(pane.getContentType()); } else { pane.setContentType("text/html"); loadedType.setText(pane.getContentType()); if (loader == null) { loader = new HTMLDocumentLoader(); } HTMLDocument doc = loader.loadDocument(url); loadComplete(); pane.setDocument(doc); displayLoadTime(); populateCombo(findLinks(doc, null)); TreeNode node = buildHeadingTree(doc); tree.setModel(new DefaultTreeModel(node)); enableInput(); } } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", selection.toString() }, "File Open Error", JOptionPane.ERROR_MESSAGE); loadingState.setText("Failed"); enableInput(); } } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); TreeNode node = buildHeadingTree(pane.getDocument()); tree.setModel(new DefaultTreeModel(node)); enableInput(); } } }); // Listener for tree selection tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject instanceof Heading) { Heading heading = (Heading) userObject; try { Rectangle textRect = pane.modelToView(heading.getOffset()); textRect.y += 3 * textRect.height; pane.scrollRectToVisible(textRect); } catch (BadLocationException e) { } } } } }); }
From source file:org.jfree.chart.demo.DrawStringDemo.java
private JPanel createTab2Content() { JPanel jpanel = new JPanel(new BorderLayout()); JPanel jpanel1 = new JPanel(); jpanel1.add(new JLabel("Text anchor: ")); combo2 = new JComboBox(); populateTextAnchorCombo(combo2);/*w ww .j a va 2 s.c om*/ combo2.setActionCommand("combo2.changed"); combo2.addActionListener(this); jpanel1.add(combo2); jpanel1.add(new JLabel("Rotation anchor: ")); combo3 = new JComboBox(); populateTextAnchorCombo(combo3); combo3.setActionCommand("combo3.changed"); combo3.addActionListener(this); jpanel1.add(combo3); spinner = new Spinner(0); spinner.addPropertyChangeListener(this); jpanel1.add(spinner); jpanel.add(jpanel1, "North"); drawStringPanel2 = new DrawStringPanel("Rotated Text", true); jpanel.add(drawStringPanel2); return jpanel; }
From source file:rhinova.gui.dataentry.link.LinkDataEntryPanel.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license vSpacer5 = new JPanel(null); label2 = new JLabel(); hSpacer1 = new JPanel(null); label1 = new JLabel(); txtName = new JTextField(); vSpacer4 = new JPanel(null); label6 = new JLabel(); txtCap = new JTextField(); vSpacer3 = new JPanel(null); label7 = new JLabel(); txtSur = new JTextField(); hSpacer2 = new JPanel(null); vSpacer2 = new JPanel(null); label8 = new JLabel(); res1 = new JComboBox(); vSpacer1 = new JPanel(null); label9 = new JLabel(); res2 = new JComboBox(); vSpacer6 = new JPanel(null); btnCreate = new JButton(); hSpacer3 = new JPanel(null); //======== this ======== setLayout(new GridBagLayout()); ((GridBagLayout) getLayout()).columnWidths = new int[] { 0, 65, 145, 0, 0 }; ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ((GridBagLayout) getLayout()).columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0E-4 }; ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 }; add(vSpacer5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); //---- label2 ---- label2.setText("Link Entry Panel"); label2.setFont(new Font("Tahoma", Font.PLAIN, 16)); add(label2, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(hSpacer1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); //---- label1 ---- label1.setText("name"); add(label1, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(txtName, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(vSpacer4, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); //---- label6 ---- label6.setText("capacity"); add(label6, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(txtCap, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(vSpacer3, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); //---- label7 ---- label7.setText("survival rate"); add(label7, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(txtSur, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(hSpacer2, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0)); add(vSpacer2, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); //---- label8 ---- label8.setText("reserve1"); add(label8, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(res1, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(vSpacer1, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); //---- label9 ---- label9.setText("reserve2"); add(label9, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(res2, new GridBagConstraints(2, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(vSpacer6, new GridBagConstraints(1, 11, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); //---- btnCreate ---- btnCreate.setText("Create Link"); btnCreate.addActionListener(new ActionListener() { @Override//from w w w . j a va2 s . c o m public void actionPerformed(ActionEvent e) { btnCreateActionPerformed(e); } }); add(btnCreate, new GridBagConstraints(2, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); add(hSpacer3, new GridBagConstraints(2, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:com.emr.schemas.EditMappingsForm.java
/** * Constructor//from w w w. ja v a2s.c o m * @param mpiConn {@link Connection} Connection object for the MPI Database * @param emrConn {@link Connection} Connection object for the EMR Database * @param selected_columns {@link List} List of the selected source columns * @param destinationTable {@link String} The destination table * @param sourceQuery {@link String} The query for getting the data to be moved * @param sourceTables {@link List} List of source tables * @param relations {@link String} Relationships between the source tables */ public EditMappingsForm(Connection mpiConn, Connection emrConn, List selected_columns, String destinationTable, String sourceQuery, List sourceTables, String relations, DestinationTables parent) { this.mpiConn = mpiConn; this.emrConn = emrConn; this.selected_columns = selected_columns; this.destinationTable = destinationTable; this.sourceQuery = sourceQuery; this.sourceTables = sourceTables; this.relations = relations; this.parent = parent; columnsToBeMapped = new ArrayList(); query = ""; insertQuery = ""; selectQuery = ""; model = new DefaultTableModel(new Object[] { "Source", "Destination", "Apply Mappings?" }, selected_columns.size()); initComponents(); this.setClosable(true); ComboBoxTableCellEditor sourceColumns = new ComboBoxTableCellEditor(selected_columns, new JComboBox()); ComboBoxTableCellEditor destinationColumnsEditor = new ComboBoxTableCellEditor( getTableColumns(destinationTable), new JComboBox()); mappingsTable.getColumnModel().getColumn(0).setCellEditor(sourceColumns); mappingsTable.getColumnModel().getColumn(1).setCellEditor(destinationColumnsEditor); /*Action foreignKeysMap = new AbstractAction(){ @Override public void actionPerformed(ActionEvent e) { JTable table = (JTable)e.getSource(); int modelRow = Integer.valueOf( e.getActionCommand() ); String foreignKeysTable=(String)mappingsTable.getModel().getValueAt(modelRow, 0); if(foreignKeysTable==null || "".equals(foreignKeysTable)){ JOptionPane.showMessageDialog(null, "Column Mappings not defined", "Empty Column Mappings", JOptionPane.ERROR_MESSAGE); }else{ String tablename=foreignKeysTable.substring(0, foreignKeysTable.lastIndexOf(".")); String column=foreignKeysTable.substring(foreignKeysTable.lastIndexOf(".") + 1,foreignKeysTable.length()); System.out.println("Table: " + tablename + ", Column: " + column); //open form for mapping the source foreign table to the destination foreign table JDesktopPane desktopPane = getDesktopPane(); ForeignDataMover frm=new ForeignDataMover(emrConn,mpiConn,foreignKeysTable); desktopPane.add(frm); frm.setVisible(true); frm.setSize(400, 400); frm.setLocation(120,60); frm.moveToFront(); btnMoveData.setEnabled(false); frm.addInternalFrameListener(new InternalFrameListener() { @Override public void internalFrameOpened(InternalFrameEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void internalFrameClosing(InternalFrameEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void internalFrameClosed(InternalFrameEvent e) { btnMoveData.setEnabled(true); } @Override public void internalFrameIconified(InternalFrameEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void internalFrameDeiconified(InternalFrameEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void internalFrameActivated(InternalFrameEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void internalFrameDeactivated(InternalFrameEvent e) { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); } } }; ButtonColumn buttonColumn = new ButtonColumn(mappingsTable, foreignKeysMap, 2);*/ CheckboxColumn checkboxColumn = new CheckboxColumn(mappingsTable, 2); grp = new ButtonGroup(); grp.add(radioAppendRows); grp.add(radioDeleteRows); }
From source file:Composite.java
public void init() { GridBagLayout layOut = new GridBagLayout(); getContentPane().setLayout(layOut);/*ww w .ja va2 s . c o m*/ GridBagConstraints l = new GridBagConstraints(); l.weightx = 1.0; l.fill = GridBagConstraints.BOTH; l.gridwidth = GridBagConstraints.RELATIVE; alphaLabel = new JLabel(); alphaLabel.setText("Alphas"); Font newFont = getFont().deriveFont(1); alphaLabel.setFont(newFont); alphaLabel.setHorizontalAlignment(JLabel.CENTER); layOut.setConstraints(alphaLabel, l); getContentPane().add(alphaLabel); GridBagConstraints c = new GridBagConstraints(); getContentPane().setLayout(layOut); l.gridwidth = GridBagConstraints.REMAINDER; rulesLabel = new JLabel(); rulesLabel.setText("Rules"); newFont = getFont().deriveFont(1); rulesLabel.setFont(newFont); rulesLabel.setHorizontalAlignment(JLabel.CENTER); layOut.setConstraints(rulesLabel, l); getContentPane().add(rulesLabel); GridBagConstraints a = new GridBagConstraints(); a.gridwidth = GridBagConstraints.RELATIVE; a.weightx = 1.0; a.fill = GridBagConstraints.BOTH; alphas = new JComboBox(); layOut.setConstraints(alphas, a); alphas.addItem("1.0"); alphas.addItem("0.75"); alphas.addItem("0.50"); alphas.addItem("0.25"); alphas.addItem("0.0"); alphas.addItemListener(this); getContentPane().add(alphas); a.gridwidth = GridBagConstraints.REMAINDER; rules = new JComboBox(); layOut.setConstraints(rules, a); rules.addItem("SRC"); rules.addItem("DST_IN"); rules.addItem("DST_OUT"); rules.addItem("DST_OVER"); rules.addItem("SRC_IN"); rules.addItem("SRC_OVER"); rules.addItem("SRC_OUT"); rules.addItem("CLEAR"); rules.addItemListener(this); getContentPane().add(rules); GridBagConstraints fC = new GridBagConstraints(); fC.fill = GridBagConstraints.BOTH; fC.weightx = 1.0; fC.weighty = 1.0; fC.gridwidth = GridBagConstraints.REMAINDER; comp = new CompPanel(); layOut.setConstraints(comp, fC); getContentPane().add(comp); validate(); }
From source file:EditorPaneExample12.java
public EditorPaneExample12() { super("JEditorPane Example 12"); pane = new JEditorPane(); pane.setEditable(false); // Read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;/* w w w . ja va 2s. c om*/ c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Allocate the empty tree model DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty"); emptyModel = new DefaultTreeModel(emptyRootNode); // Create and place the heading tree tree = new JTree(emptyModel); tree.setPreferredSize(new Dimension(200, 200)); getContentPane().add(new JScrollPane(tree), "East"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); loadNewPage(selection); } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); TreeNode node = buildHeadingTree(pane.getDocument()); tree.setModel(new DefaultTreeModel(node)); enableInput(); loadingPage = false; } } }); // Listener for tree selection tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject instanceof Heading) { Heading heading = (Heading) userObject; try { Rectangle textRect = pane.modelToView(heading.getOffset()); textRect.y += 3 * textRect.height; pane.scrollRectToVisible(textRect); } catch (BadLocationException e) { } } } } }); // Listener for hypertext events pane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { // Ignore hyperlink events if the frame is busy if (loadingPage == true) { return; } if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane sp = (JEditorPane) evt.getSource(); if (evt instanceof HTMLFrameHyperlinkEvent) { HTMLDocument doc = (HTMLDocument) sp.getDocument(); doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt); } else { loadNewPage(evt.getURL()); } } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { pane.setCursor(handCursor); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { pane.setCursor(defaultCursor); } } }); }
From source file:com.willwinder.ugs.nbp.setupwizard.panels.WizardPanelConnection.java
private void initComponents() { labelDescription = new JLabel("<html><body><p>" + Localization.getString("platform.plugin.setupwizard.connection.intro") + "</p></body></html>"); // Firmware options firmwareCombo = new JComboBox<>(); firmwareCombo.addActionListener(a -> setFirmware()); labelFirmware = new JLabel("Firmware:"); // Baud rate options baudCombo = new JComboBox<>(); baudCombo.setModel(new DefaultComboBoxModel<>( new String[] { "2400", "4800", "9600", "19200", "38400", "57600", "115200", "230400" })); baudCombo.setSelectedIndex(6);// w w w . ja v a 2 s .c o m baudCombo.setToolTipText("Select baudrate to use for the serial port."); baudCombo.addActionListener(e -> this.setBaudRate()); labelBaud = new JLabel(Localization.getString("platform.plugin.setupwizard.port-rate")); portCombo = new JComboBox<>(); portCombo.addActionListener(e -> this.setPort()); labelPort = new JLabel(Localization.getString("platform.plugin.setupwizard.port")); connectButton = new JButton(Localization.getString("platform.plugin.setupwizard.connect")); connectButton.addActionListener((e) -> { try { getBackend().connect(getBackend().getSettings().getFirmwareVersion(), getBackend().getSettings().getPort(), Integer.valueOf(getBackend().getSettings().getPortRate())); } catch (Exception e1) { e1.printStackTrace(); } }); labelVersion = new JLabel(Localization.getString("platform.plugin.setupwizard.unknown-version")); labelVersion.setVisible(false); labelNotSupported = new JLabel( Localization.getString("platform.plugin.setupwizard.connection.not-supported")); labelNotSupported.setIcon(ImageUtilities.loadImageIcon("icons/information24.png", false)); labelNotSupported.setVisible(false); }
From source file:EditorPaneExample15.java
public EditorPaneExample15() { super("JEditorPane Example 15"); pane = new JEditorPane(); pane.setEditable(false); // Read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;/*from w ww.ja va 2s . com*/ c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; urlCombo = new JComboBox(); panel.add(urlCombo, c); urlCombo.setEditable(true); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, c); getContentPane().add(panel, "South"); // Allocate the empty tree model DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty"); emptyModel = new DefaultTreeModel(emptyRootNode); // Create and place the heading tree tree = new JTree(emptyModel); tree.setPreferredSize(new Dimension(200, 200)); getContentPane().add(new JScrollPane(tree), "East"); // Change page based on combo selection urlCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (populatingCombo == true) { return; } Object selection = urlCombo.getSelectedItem(); loadNewPage(selection); } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadComplete(); displayLoadTime(); populateCombo(findLinks(pane.getDocument(), null)); TreeNode node = buildHeadingTree(pane.getDocument()); tree.setModel(new DefaultTreeModel(node)); enableInput(); loadingPage = false; } } }); // Listener for tree selection tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent evt) { TreePath path = evt.getNewLeadSelectionPath(); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object userObject = node.getUserObject(); if (userObject instanceof Heading) { Heading heading = (Heading) userObject; try { Rectangle textRect = pane.modelToView(heading.getOffset()); textRect.y += 3 * textRect.height; pane.scrollRectToVisible(textRect); } catch (BadLocationException e) { } } } } }); // Listener for hypertext events pane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent evt) { // Ignore hyperlink events if the frame is busy if (loadingPage == true) { return; } if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane sp = (JEditorPane) evt.getSource(); if (evt instanceof HTMLFrameHyperlinkEvent) { HTMLDocument doc = (HTMLDocument) sp.getDocument(); doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt); } else { loadNewPage(evt.getURL()); } } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { pane.setCursor(handCursor); } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { pane.setCursor(defaultCursor); } } }); }
From source file:org.jdal.swing.form.FormUtils.java
public static JComboBox<?> newCombo(int chars) { StringBuilder sb = new StringBuilder(chars); while (chars-- > 0) sb.append("X"); JComboBox<String> combo = new JComboBox<String>(); combo.setPrototypeDisplayValue(sb.toString()); return combo; }