List of usage examples for javax.swing BorderFactory createTitledBorder
public static TitledBorder createTitledBorder(Border border)
From source file:components.BorderDemo.java
public BorderDemo() { super(new GridLayout(1, 0)); //Keep references to the next few borders, //for use in titles and compound borders. Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty; //A border that puts 10 extra pixels at the sides and //bottom of each pane. Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10); blackline = BorderFactory.createLineBorder(Color.black); raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); raisedbevel = BorderFactory.createRaisedBevelBorder(); loweredbevel = BorderFactory.createLoweredBevelBorder(); empty = BorderFactory.createEmptyBorder(); //First pane: simple borders JPanel simpleBorders = new JPanel(); simpleBorders.setBorder(paneEdge);/*from w ww .jav a2s .c o m*/ simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS)); addCompForBorder(blackline, "line border", simpleBorders); addCompForBorder(raisedetched, "raised etched border", simpleBorders); addCompForBorder(loweredetched, "lowered etched border", simpleBorders); addCompForBorder(raisedbevel, "raised bevel border", simpleBorders); addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders); addCompForBorder(empty, "empty border", simpleBorders); //Second pane: matte borders JPanel matteBorders = new JPanel(); matteBorders.setBorder(paneEdge); matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS)); ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); //20x22 Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon); if (icon != null) { addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders); } else { addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders); } border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red); addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders); border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon); if (icon != null) { addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders); } else { addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders); } //Third pane: titled borders JPanel titledBorders = new JPanel(); titledBorders.setBorder(paneEdge); titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS)); TitledBorder titled; titled = BorderFactory.createTitledBorder("title"); addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders); titled = BorderFactory.createTitledBorder(blackline, "title"); addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredetched, "title"); addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)", TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredbevel, "title"); addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders); titled = BorderFactory.createTitledBorder(empty, "title"); addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders); //Fourth pane: compound borders JPanel compoundBorders = new JPanel(); compoundBorders.setBorder(paneEdge); compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS)); Border redline = BorderFactory.createLineBorder(Color.red); Border compound; compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel); addCompForBorder(compound, "compound border (two bevels)", compoundBorders); compound = BorderFactory.createCompoundBorder(redline, compound); addCompForBorder(compound, "compound border (add a red outline)", compoundBorders); titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER, TitledBorder.BELOW_BOTTOM); addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Simple", null, simpleBorders, null); tabbedPane.addTab("Matte", null, matteBorders, null); tabbedPane.addTab("Titled", null, titledBorders, null); tabbedPane.addTab("Compound", null, compoundBorders, null); tabbedPane.setSelectedIndex(0); String toolTip = new String( "<html>Blue Wavy Line border art crew:<br> Bill Pauley<br> Cris St. Aubyn<br> Ben Wronsky<br> Nathan Walrath<br> Tommy Adams, special consultant</html>"); tabbedPane.setToolTipTextAt(1, toolTip); add(tabbedPane); }
From source file:uk.co.petertribble.solview.explorer.CpuInfoPanel.java
private void addAccessory() { Kstat ks = hi.getKstat();// w w w . j a va 2s .c om if (ks != null) { Kstat ksc = proctree.makeCpuKstat(ks); kap = new AccessoryCpuPanel(ksc, 1, jkstat); JPanel jp = new JPanel(new BorderLayout()); jp.add(kap); jp.setBorder(BorderFactory.createTitledBorder("CPU activity")); jvp.add(jp); kbc = new KstatAreaChart(jkstat, ksc, mystats, true); kbc.setColors(mycolors); jvp.add(new ChartPanel(kbc.getChart())); } }
From source file:BorderDemo.java
public BorderDemo() { super(new GridLayout(1, 0)); // Keep references to the next few borders, // for use in titles and compound borders. Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty; // A border that puts 10 extra pixels at the sides and // bottom of each pane. Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10); blackline = BorderFactory.createLineBorder(Color.black); raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); raisedbevel = BorderFactory.createRaisedBevelBorder(); loweredbevel = BorderFactory.createLoweredBevelBorder(); empty = BorderFactory.createEmptyBorder(); // First pane: simple borders JPanel simpleBorders = new JPanel(); simpleBorders.setBorder(paneEdge);//from w w w. j a v a2 s. c o m simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS)); addCompForBorder(blackline, "line border", simpleBorders); addCompForBorder(raisedetched, "raised etched border", simpleBorders); addCompForBorder(loweredetched, "lowered etched border", simpleBorders); addCompForBorder(raisedbevel, "raised bevel border", simpleBorders); addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders); addCompForBorder(empty, "empty border", simpleBorders); // Second pane: matte borders JPanel matteBorders = new JPanel(); matteBorders.setBorder(paneEdge); matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS)); ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); // 20x22 Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon); if (icon != null) { addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders); } else { addCompForBorder(border, "matte border (-1,-1,-1,-1,<null-icon>)", matteBorders); } border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red); addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders); border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon); if (icon != null) { addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders); } else { addCompForBorder(border, "matte border (0,20,0,0,<null-icon>)", matteBorders); } // Third pane: titled borders JPanel titledBorders = new JPanel(); titledBorders.setBorder(paneEdge); titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS)); TitledBorder titled; titled = BorderFactory.createTitledBorder("title"); addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders); titled = BorderFactory.createTitledBorder(blackline, "title"); addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredetched, "title"); addCompForTitledBorder(titled, "titled lowered etched border" + " (right just., default pos.)", TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredbevel, "title"); addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders); titled = BorderFactory.createTitledBorder(empty, "title"); addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders); // Fourth pane: compound borders JPanel compoundBorders = new JPanel(); compoundBorders.setBorder(paneEdge); compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS)); Border redline = BorderFactory.createLineBorder(Color.red); Border compound; compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel); addCompForBorder(compound, "compound border (two bevels)", compoundBorders); compound = BorderFactory.createCompoundBorder(redline, compound); addCompForBorder(compound, "compound border (add a red outline)", compoundBorders); titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER, TitledBorder.BELOW_BOTTOM); addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Simple", null, simpleBorders, null); tabbedPane.addTab("Matte", null, matteBorders, null); tabbedPane.addTab("Titled", null, titledBorders, null); tabbedPane.addTab("Compound", null, compoundBorders, null); tabbedPane.setSelectedIndex(0); String toolTip = new String( "<html>Blue Wavy Line border art crew:<br> Bill Pauley<br> Cris St. Aubyn<br> Ben Wronsky<br> Nathan Walrath<br> Tommy Adams, special consultant</html>"); tabbedPane.setToolTipTextAt(1, toolTip); add(tabbedPane); }
From source file:GCWrapper.java
/** * Creates and lays out components in the container. See the comments below * for an organizational overview by panel. */// w ww .ja v a 2s .co m private void initComponents(Container c) { c.setLayout(new BorderLayout()); // Graphics Config JPanel gcPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); c.add(gcPanel, BorderLayout.NORTH); gcSelection.setPreferredSize(new Dimension(400, 30)); gcPanel.add(gcSelection); // Capabilities JPanel capsPanel = new JPanel(new BorderLayout()); c.add(capsPanel, BorderLayout.CENTER); // Image Capabilities JPanel imageCapsPanel = new JPanel(new GridLayout(2, 1)); capsPanel.add(imageCapsPanel, BorderLayout.NORTH); imageCapsPanel.setBorder(BorderFactory.createTitledBorder("Image Capabilities")); imageAccelerated.setEnabled(false); imageCapsPanel.add(imageAccelerated); imageTrueVolatile.setEnabled(false); imageCapsPanel.add(imageTrueVolatile); // Buffer Capabilities JPanel bufferCapsPanel = new JPanel(new BorderLayout()); capsPanel.add(bufferCapsPanel, BorderLayout.CENTER); bufferCapsPanel.setBorder(BorderFactory.createTitledBorder("Buffer Capabilities")); // Buffer Access JPanel bufferAccessCapsPanel = new JPanel(new GridLayout(3, 1)); bufferAccessCapsPanel.setPreferredSize(new Dimension(300, 88)); bufferCapsPanel.add(bufferAccessCapsPanel, BorderLayout.NORTH); // Flipping JPanel flippingPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(flippingPanel); flippingPanel.add(flipping); flipping.setEnabled(false); flippingPanel.add(flippingMethod); // Full-screen JPanel fsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(fsPanel); JPanel indentPanel = new JPanel(); indentPanel.setPreferredSize(new Dimension(30, 30)); fsPanel.add(indentPanel); fsPanel.add(fullScreen); fullScreen.setEnabled(false); // Multi-buffering JPanel mbPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(mbPanel); indentPanel = new JPanel(); indentPanel.setPreferredSize(new Dimension(30, 30)); mbPanel.add(indentPanel); mbPanel.add(multiBuffer); multiBuffer.setEnabled(false); // Front and Back Buffer Capabilities JPanel buffersPanel = new JPanel(new GridLayout(1, 2)); bufferCapsPanel.add(buffersPanel, BorderLayout.CENTER); // Front Buffer JPanel fbPanel = new JPanel(new GridLayout(2, 1)); fbPanel.setBorder(BorderFactory.createTitledBorder("Front Buffer")); buffersPanel.add(fbPanel); fbPanel.add(fbAccelerated); fbAccelerated.setEnabled(false); fbPanel.add(fbTrueVolatile); fbTrueVolatile.setEnabled(false); // Back Buffer JPanel bbPanel = new JPanel(new GridLayout(2, 1)); bbPanel.setPreferredSize(new Dimension(250, 80)); bbPanel.setBorder(BorderFactory.createTitledBorder("Back and Intermediate Buffers")); buffersPanel.add(bbPanel); bbPanel.add(bbAccelerated); bbAccelerated.setEnabled(false); bbPanel.add(bbTrueVolatile); bbTrueVolatile.setEnabled(false); }
From source file:com.moteiv.trawler.Trawler.java
protected Box getControls() { java.util.Dictionary labels;//w w w. ja va 2 s. c o m if (controls == null) { controls = Box.createVerticalBox(); JPanel runtimeControls = new JPanel(new GridLayout(0, 1)); runtimeControls.setBorder(BorderFactory.createTitledBorder("Runtime Controls")); vLog = new JCheckBox("Log packets", false); vLog.addActionListener(this); runtimeControls.add(vLog); runtimeControls.add(new JLabel("Edge persistence (sec)", JLabel.LEFT)); eDispose = new JSlider(0, 300, 10); eDispose.setMajorTickSpacing(100); eDispose.setMinorTickSpacing(10); eDispose.setPaintTicks(true); eDispose.setPaintTrack(true); // labels = eDispose.getLabelTable(); eDispose.setPaintLabels(true); eDispose.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { LinkData.setEdgeDelay((1 + eDispose.getValue()) * 1000); savePrefs(); } }); runtimeControls.add(eDispose); runtimeControls.add(new JLabel("Vertex persistence (sec)", JLabel.LEFT)); vDispose = new JSlider(0, 300, 30); vDispose.setMajorTickSpacing(100); vDispose.setMinorTickSpacing(10); vDispose.setPaintTicks(true); vDispose.setPaintTrack(true); vDispose.setPaintLabels(true); vDispose.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { NodeData.setNodeDelay((1 + vDispose.getValue()) * 1000); savePrefs(); } }); runtimeControls.add(vDispose); graphReset = new JButton("Reset Nodes"); graphReset.addActionListener(this); runtimeControls.add(graphReset); controls.add(runtimeControls); JPanel vertexControl = new JPanel(new GridLayout(0, 1)); vertexControl.setBorder(BorderFactory.createTitledBorder("Node display")); vLabels = new JCheckBox("Display vertex details", true); vLabels.addActionListener(this); vertexControl.add(vLabels); vBlink = new JCheckBox("Blink on incoming packets"); vBlink.addActionListener(this); vertexControl.add(vBlink); vSave = new JCheckBox("Save node locations", true); vSave.addActionListener(this); vertexControl.add(vSave); controls.add(vertexControl); JPanel edgeControl = new JPanel(new GridLayout(0, 1)); edgeControl.setBorder(BorderFactory.createTitledBorder("Link diplay")); eLabels = new JCheckBox("Display link quality", true); eLabels.addActionListener(this); edgeControl.add(eLabels); eFilter = new JCheckBox("Show alternate parents", true); eFilter.addActionListener(this); edgeControl.add(eFilter); controls.add(edgeControl); } return controls; }
From source file:TableSelectionDemo.java
public TableSelectionDemo() { super(new BorderLayout()); String[] columnNames = { "French", "Spanish", "Italian" }; String[][] tableData = { { "un", "uno", "uno" }, { "deux", "dos", "due" }, { "trois", "tres", "tre" }, { "quatre", "cuatro", "quattro" }, { "cinq", "cinco", "cinque" }, { "six", "seis", "sei" }, { "sept", "siete", "sette" } }; table = new JTable(tableData, columnNames); listSelectionModel = table.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); table.setSelectionModel(listSelectionModel); JScrollPane tablePane = new JScrollPane(table); // Build control area (use default FlowLayout). JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2);//from w w w . j a v a 2 s . co m comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); // Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); // Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); JPanel tableContainer = new JPanel(new GridLayout(1, 1)); tableContainer.setBorder(BorderFactory.createTitledBorder("Table")); tableContainer.add(tablePane); tablePane.setPreferredSize(new Dimension(420, 130)); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(250, 50)); topHalf.setPreferredSize(new Dimension(200, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); // XXX: next line needed if bottomHalf is a scroll pane: // bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 110)); splitPane.add(bottomHalf); }
From source file:instance.gui.InstanceGUI.java
private void createSnapshotSection() { snapshotSection = new JPanel(); snapshotSection.setLayout(new BorderLayout()); snapshotSection.setBorder(BorderFactory.createTitledBorder("Snapshot(s)")); createSnapshotTable();//ww w.j a v a 2 s .c o m snapshotTab.add(snapshotSection); }
From source file:com.genericworkflownodes.knime.nodes.io.OutputFileNodeDialog.java
private void addComponents() { componentContainer.add(textField);//from w ww . j a v a2s . com componentContainer.add(searchButton); componentContainer.setBorder(BorderFactory.createTitledBorder("Selected output file:")); dialogPanel.add(componentContainer); }
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 . jav a 2s . co 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:components.SharedModelDemo.java
public SharedModelDemo() { super(new BorderLayout()); Vector data = new Vector(7); String[] columnNames = { "French", "Spanish", "Italian" }; String[] oneData = { "un", "uno", "uno" }; String[] twoData = { "deux", "dos", "due" }; String[] threeData = { "trois", "tres", "tre" }; String[] fourData = { "quatre", "cuatro", "quattro" }; String[] fiveData = { "cinq", "cinco", "cinque" }; String[] sixData = { "six", "seis", "sei" }; String[] sevenData = { "sept", "siete", "sette" }; //Build the model. SharedDataModel dataModel = new SharedDataModel(columnNames); dataModel.addElement(oneData);// w w w . j a va2 s .c o m dataModel.addElement(twoData); dataModel.addElement(threeData); dataModel.addElement(fourData); dataModel.addElement(fiveData); dataModel.addElement(sixData); dataModel.addElement(sevenData); list = new JList(dataModel); list.setCellRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList l, Object value, int i, boolean s, boolean f) { String[] array = (String[]) value; return super.getListCellRendererComponent(l, array[0], i, s, f); } }); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); JScrollPane listPane = new JScrollPane(list); table = new JTable(dataModel); table.setSelectionModel(listSelectionModel); JScrollPane tablePane = new JScrollPane(table); //Build control area (use default FlowLayout). JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2); comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); //Build output area. output = new JTextArea(10, 40); output.setEditable(false); JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); //Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.X_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); listContainer.setBorder(BorderFactory.createTitledBorder("List")); listContainer.add(listPane); JPanel tableContainer = new JPanel(new GridLayout(1, 1)); tableContainer.setBorder(BorderFactory.createTitledBorder("Table")); tableContainer.add(tablePane); tablePane.setPreferredSize(new Dimension(300, 100)); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(400, 50)); topHalf.setPreferredSize(new Dimension(400, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.NORTH); bottomHalf.add(outputPane, BorderLayout.CENTER); //XXX: next line needed if bottomHalf is a scroll pane: //bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 135)); splitPane.add(bottomHalf); }