List of usage examples for javax.swing JRadioButton JRadioButton
public JRadioButton(String text, Icon icon)
From source file:org.wsm.database.tools.editor.ui.GraphPane.java
public GraphPane() { GridBagLayout gbl = new GridBagLayout(); this.setLayout(gbl); this.qesi = new QueryExecStatsInfo(); this.qesi.addPropertyChangeListener(this); dcd = new DefaultCategoryDataset(); JFreeChart chart = getChart(CHART_TYPE_BAR_3D); chart.setBackgroundPaint(Color.white); cp = new ChartPanel(chart); cp.setBorder(BorderFactory.createTitledBorder(null, "Graph", TitledBorder.LEADING, TitledBorder.TOP, UIConstants.LABEL_FONT));//from w ww.ja v a 2 s. c om cp.setMouseZoomable(true, true); //cp.setPreferredSize(new Dimension(700, 500)); gbl.setConstraints(cp, SwingUtils.getGridBagConstraints(0, 0, 2, 1)); this.add(cp); JPanel graphTypeSelectionPanel = new JPanel(); viewBarGraph = new JRadioButton("View Bar Graph", true); viewLineGraph = new JRadioButton("View Line Graph", false); viewLineGraph.setEnabled(false); ButtonGroup bg = new ButtonGroup(); bg.add(viewBarGraph); bg.add(viewLineGraph); GridBagLayout graphTypeGBL = new GridBagLayout(); graphTypeSelectionPanel.setLayout(graphTypeGBL); graphTypeGBL.setConstraints(viewBarGraph, SwingUtils.getGridBagConstraints(0, 0)); graphTypeGBL.setConstraints(viewLineGraph, SwingUtils.getGridBagConstraints(1, 0)); graphTypeSelectionPanel.add(viewBarGraph); graphTypeSelectionPanel.add(viewLineGraph); viewBarGraph.addActionListener(this); viewLineGraph.addActionListener(this); graphTypeSelectionPanel.setBorder(BorderFactory.createTitledBorder(null, "Graph Type", TitledBorder.LEADING, TitledBorder.TOP, UIConstants.LABEL_FONT)); gbl.setConstraints(graphTypeSelectionPanel, SwingUtils.getGridBagConstraints(0, 1, 2, 1)); this.add(graphTypeSelectionPanel); //this.setBounds(50, 100, 100, 200); this.setBackground(Color.WHITE); }
From source file:GenealogyExample.java
public GenealogyExample() { super(new BorderLayout()); // Construct the panel with the toggle buttons. JRadioButton showDescendant = new JRadioButton("Show descendants", true); final JRadioButton showAncestor = new JRadioButton("Show ancestors"); ButtonGroup bGroup = new ButtonGroup(); bGroup.add(showDescendant);/* w ww . ja v a2s . c om*/ bGroup.add(showAncestor); showDescendant.addActionListener(this); showAncestor.addActionListener(this); showAncestor.setActionCommand(SHOW_ANCESTOR_CMD); JPanel buttonPanel = new JPanel(); buttonPanel.add(showDescendant); buttonPanel.add(showAncestor); // Construct the tree. tree = new GenealogyTree(getGenealogyGraph()); JScrollPane scrollPane = new JScrollPane(tree); scrollPane.setPreferredSize(new Dimension(200, 200)); // Add everything to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(scrollPane, BorderLayout.CENTER); }
From source file:TapTapTap.java
private JPanel createPanel() { JPanel p = new JPanel(); ButtonGroup entreeGroup = new ButtonGroup(); JRadioButton radioButton;/* w ww . j ava2s . com*/ p.add(radioButton = new JRadioButton("Beef", true)); entreeGroup.add(radioButton); p.add(radioButton = new JRadioButton("Chicken")); entreeGroup.add(radioButton); p.add(radioButton = new JRadioButton("Vegetable")); entreeGroup.add(radioButton); p.add(new JCheckBox("Ketchup")); p.add(new JCheckBox("Mustard")); p.add(new JCheckBox("Pickles")); p.add(new JLabel("Special requests:")); p.add(new JTextField(20)); mOrderButton = new JButton("Place Order"); p.add(mOrderButton); return p; }
From source file:GenealogyExample.java
public GenealogyExample() { super(new BorderLayout()); //Construct the panel with the toggle buttons. JRadioButton showDescendant = new JRadioButton("Show descendants", true); final JRadioButton showAncestor = new JRadioButton("Show ancestors"); ButtonGroup bGroup = new ButtonGroup(); bGroup.add(showDescendant);/* ww w. j av a2s.c om*/ bGroup.add(showAncestor); showDescendant.addActionListener(this); showAncestor.addActionListener(this); showAncestor.setActionCommand(SHOW_ANCESTOR_CMD); JPanel buttonPanel = new JPanel(); buttonPanel.add(showDescendant); buttonPanel.add(showAncestor); //Construct the tree. tree = new GenealogyTree(getGenealogyGraph()); JScrollPane scrollPane = new JScrollPane(tree); scrollPane.setPreferredSize(new Dimension(200, 200)); //Add everything to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(scrollPane, BorderLayout.CENTER); }
From source file:StrokeTest.java
/** * Makes a radio button to change the cap style. * @param label the button label/*from w w w . j av a 2s . c o m*/ * @param style the cap style * @param group the radio button group */ private void makeCapButton(String label, final int style, ButtonGroup group) { // select first button in group boolean selected = group.getButtonCount() == 0; JRadioButton button = new JRadioButton(label, selected); buttonPanel.add(button); group.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { canvas.setCap(style); } }); }
From source file:RenderQualityTest.java
/** * Makes a set of buttons for a rendering hint key and values * /*w ww.ja v a 2s . c o m*/ * @param key * the key name * @param value1 * the name of the first value for the key * @param value2 * the name of the second value for the key */ void makeButtons(String key, String value1, String value2) { try { final RenderingHints.Key k = (RenderingHints.Key) RenderingHints.class.getField(key).get(null); final Object v1 = RenderingHints.class.getField(value1).get(null); final Object v2 = RenderingHints.class.getField(value2).get(null); JLabel label = new JLabel(key); buttonBox.add(label, new GBC(0, r).setAnchor(GBC.WEST)); ButtonGroup group = new ButtonGroup(); JRadioButton b1 = new JRadioButton(value1, true); buttonBox.add(b1, new GBC(1, r).setAnchor(GBC.WEST)); group.add(b1); b1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { hints.put(k, v1); canvas.setRenderingHints(hints); } }); JRadioButton b2 = new JRadioButton(value2, false); buttonBox.add(b2, new GBC(2, r).setAnchor(GBC.WEST)); group.add(b2); b2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { hints.put(k, v2); canvas.setRenderingHints(hints); } }); hints.put(k, v1); r++; } catch (Exception e) { e.printStackTrace(); } }
From source file:MessageDigestTest.java
/** * Adds a radio button to select an algorithm. * @param c the container into which to place the button * @param name the algorithm name// w w w . j a v a 2 s.c o m * @param g the button group */ public void addRadioButton(Container c, final String name, ButtonGroup g) { ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { setAlgorithm(name); } }; JRadioButton b = new JRadioButton(name, g.getButtonCount() == 0); c.add(b); g.add(b); b.addActionListener(listener); }
From source file:StrokeTest.java
/** * Makes a radio button to change the join style. * @param label the button label/*w ww .j a v a 2 s. c om*/ * @param style the join style * @param group the radio button group */ private void makeJoinButton(String label, final int style, ButtonGroup group) { // select first button in group boolean selected = group.getButtonCount() == 0; JRadioButton button = new JRadioButton(label, selected); buttonPanel.add(button); group.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { canvas.setJoin(style); } }); }
From source file:org.uncommons.watchmaker.swing.evolutionmonitor.PopulationFitnessView.java
/** * Creates the GUI controls for toggling graph display options. * @return A component that can be added to the main panel. *///from ww w . j a v a2s. c om private JComponent createControls(boolean islands) { JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); allDataButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { updateDomainAxisRange(); } }); String text = "Last " + SHOW_FIXED_GENERATIONS + (islands ? " Epochs" : " Generations"); JRadioButton recentDataButton = new JRadioButton(text, true); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(allDataButton); buttonGroup.add(recentDataButton); controls.add(allDataButton); controls.add(recentDataButton); final JCheckBox meanCheckBox = new JCheckBox("Show Mean", true); meanCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getStateChange() == ItemEvent.SELECTED) { dataSet.addSeries(meanSeries); } else { dataSet.removeSeries(meanSeries); } } }); controls.add(meanCheckBox); invertCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { rangeAxis.setInverted(invertCheckBox.isSelected()); } }); controls.add(invertCheckBox); return controls; }
From source file:StrokeTest.java
/** * Makes a radio button to set solid or dashed lines * @param label the button label/*from w w w.j ava 2 s . co m*/ * @param style false for solid, true for dashed lines * @param group the radio button group */ private void makeDashButton(String label, final boolean style, ButtonGroup group) { // select first button in group boolean selected = group.getButtonCount() == 0; JRadioButton button = new JRadioButton(label, selected); buttonPanel.add(button); group.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { canvas.setDash(style); } }); }