List of usage examples for javax.swing ButtonGroup ButtonGroup
public ButtonGroup()
ButtonGroup
. From source file:PizzaGridBagLayout.java
public PizzaGridBagLayout() { this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel1 = new JPanel(); panel1.setLayout(new GridBagLayout()); addItem(panel1, new JLabel("Name:"), 0, 0, 1, 1, GridBagConstraints.EAST); addItem(panel1, new JLabel("Phone:"), 0, 1, 1, 1, GridBagConstraints.EAST); addItem(panel1, new JLabel("Address:"), 0, 2, 1, 1, GridBagConstraints.EAST); addItem(panel1, name, 1, 0, 2, 1, GridBagConstraints.WEST); addItem(panel1, phone, 1, 1, 1, 1, GridBagConstraints.WEST); addItem(panel1, address, 1, 2, 2, 1, GridBagConstraints.WEST); Box sizeBox = Box.createVerticalBox(); ButtonGroup sizeGroup = new ButtonGroup(); sizeGroup.add(small);// ww w . j ava2 s .c o m sizeGroup.add(medium); sizeGroup.add(large); sizeBox.add(small); sizeBox.add(medium); sizeBox.add(large); sizeBox.setBorder(BorderFactory.createTitledBorder("Size")); addItem(panel1, sizeBox, 0, 3, 1, 1, GridBagConstraints.NORTH); Box styleBox = Box.createVerticalBox(); ButtonGroup styleGroup = new ButtonGroup(); styleGroup.add(thin); styleGroup.add(thick); styleBox.add(thin); styleBox.add(thick); styleBox.setBorder(BorderFactory. createTitledBorder("Style")); addItem(panel1, styleBox, 1, 3, 1, 1, GridBagConstraints.NORTH); Box topBox = Box.createVerticalBox(); ButtonGroup topGroup = new ButtonGroup(); topGroup.add(pepperoni); topGroup.add(mushrooms); topGroup.add(anchovies); topBox.add(pepperoni); topBox.add(mushrooms); topBox.add(anchovies); topBox.setBorder(BorderFactory.createTitledBorder("Toppings")); addItem(panel1, topBox, 2, 3, 1, 1, GridBagConstraints.NORTH); Box buttonBox = Box.createHorizontalBox(); buttonBox.add(okButton); buttonBox.add(Box.createHorizontalStrut(20)); buttonBox.add(closeButton); addItem(panel1, buttonBox, 2, 4, 1, 1, GridBagConstraints.NORTH); this.add(panel1); this.pack(); this.setVisible(true); }
From source file:Main.java
/** * Groups specified buttons and returns created button group. * * @param buttons/* w w w .j a va 2 s.c om*/ * buttons to group * @return created button group */ public static ButtonGroup groupButtons(final AbstractButton... buttons) { final ButtonGroup buttonGroup = new ButtonGroup(); groupButtons(buttonGroup, buttons); return buttonGroup; }
From source file:IteratorTest.java
protected JPanel getTypePanel() { JPanel panel = new JPanel(); panel.add(charButton);/*from w w w . j a va2 s . com*/ panel.add(wordButton); panel.add(lineButton); panel.add(sentButton); ButtonGroup group = new ButtonGroup(); group.add(charButton); group.add(wordButton); group.add(lineButton); group.add(sentButton); return panel; }
From source file:RadioButtonTest.java
public RadioButtonFrame() { setTitle("RadioButtonTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); // add the sample text label label = new JLabel("The quick brown fox jumps over the lazy dog."); label.setFont(new Font("Serif", Font.PLAIN, DEFAULT_SIZE)); add(label, BorderLayout.CENTER); // add the radio buttons buttonPanel = new JPanel(); group = new ButtonGroup(); addRadioButton("Small", 8); addRadioButton("Medium", 12); addRadioButton("Large", 18); addRadioButton("Extra large", 36); add(buttonPanel, BorderLayout.SOUTH); }
From source file:com.mirth.connect.client.ui.AttachmentExportDialog.java
private void initComponents() { binaryButton = new JRadioButton("Binary"); binaryButton.setSelected(true);/*from w w w. j ava2s.c o m*/ binaryButton.setBackground(Color.white); binaryButton.setFocusable(false); textButton = new JRadioButton("Text"); textButton.setBackground(Color.white); textButton.setFocusable(false); ButtonGroup typeButtonGroup = new ButtonGroup(); typeButtonGroup.add(binaryButton); typeButtonGroup.add(textButton); serverButton = new JRadioButton("Server"); serverButton.setBackground(Color.white); serverButton.setFocusable(false); localButton = new JRadioButton("My Computer"); localButton.setBackground(Color.white); localButton.setSelected(true); localButton.setFocusable(false); browseButton = new MirthButton("Browse..."); localButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { browseButton.setEnabled(true); fileField.setText(null); } }); serverButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { browseButton.setEnabled(false); fileField.setText(null); } }); ButtonGroup locationButtonGroup = new ButtonGroup(); locationButtonGroup.add(serverButton); locationButtonGroup.add(localButton); browseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { browseSelected(); } }); fileField = new JTextField(); exportButton = new JButton("Export"); cancelButton = new JButton("Cancel"); exportButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { export(); } }); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); }
From source file:DialogSeparator.java
public FlightReservation() { super("Dialog "); Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(new DialogSeparator("Options")); ButtonGroup group = new ButtonGroup(); JRadioButton r1 = new JRadioButton("First class"); group.add(r1);/*from www. j a v a 2s.co m*/ c.add(r1); JRadioButton r2 = new JRadioButton("Business"); group.add(r2); c.add(r2); JRadioButton r3 = new JRadioButton("Coach"); group.add(r3); c.add(r3); c.add(new DialogSeparator()); JButton b3 = new JButton("Exit"); c.add(b3); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setSize(300, 200); setVisible(true); }
From source file:GeMSE.GS.Analysis.Stats.OneSamplePCAPanel.java
public OneSamplePCAPanel() { initComponents();//from w ww. j a v a2 s.com Color.RGBtoHSB(214, 217, 223, bColor); ButtonGroup groupA = new ButtonGroup(); groupA.add(testAreAtColsRB); groupA.add(testAreAtRowsRB); testAreAtColsRB.setSelected(true); _level = DEFAULT_LEVEL; }
From source file:OptionDialogTest.java
/** * Constructs a button panel./*from w w w . j ava 2 s . c o m*/ * @param title the title shown in the border * @param options an array of radio button labels */ public ButtonPanel(String title, String... options) { setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), title)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); group = new ButtonGroup(); // make one radio button for each option for (String option : options) { JRadioButton b = new JRadioButton(option); b.setActionCommand(option); add(b); group.add(b); b.setSelected(option == options[0]); } }
From source file:StrokeTest.java
public StrokeTestFrame() { setTitle("StrokeTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); canvas = new StrokeComponent(); add(canvas, BorderLayout.CENTER); buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(3, 3)); add(buttonPanel, BorderLayout.NORTH); ButtonGroup group1 = new ButtonGroup(); makeCapButton("Butt Cap", BasicStroke.CAP_BUTT, group1); makeCapButton("Round Cap", BasicStroke.CAP_ROUND, group1); makeCapButton("Square Cap", BasicStroke.CAP_SQUARE, group1); ButtonGroup group2 = new ButtonGroup(); makeJoinButton("Miter Join", BasicStroke.JOIN_MITER, group2); makeJoinButton("Bevel Join", BasicStroke.JOIN_BEVEL, group2); makeJoinButton("Round Join", BasicStroke.JOIN_ROUND, group2); ButtonGroup group3 = new ButtonGroup(); makeDashButton("Solid Line", false, group3); makeDashButton("Dashed Line", true, group3); }
From source file:com.sherchen.idea_plugin.injectcomment.InjectCommentDialog.java
protected InjectCommentDialog(InjectWriteAction injectWriteAction, @Nullable Project project, Editor editor) { super(project, true); this.injectWriteAction = injectWriteAction; //&M& some test code.Sherchen.2015.02.08 19:47:08 m_Project = project;// w ww . ja va 2s .c om m_Editor = editor; //End.Sherchen.2015.02.08 19:47:08 setTitle("Please add the comment"); setResizable(true); //[A] some test code.Sherchen.2015.02.08 buttonGroup = new ButtonGroup(); buttonGroup.add(rbAddRadioButton); buttonGroup.add(rbModifyRadioButton); buttonGroup.add(rbRemoveRadioButton); //End.Sherchen.2015.02.08 buttonGroup.setSelected(rbAddRadioButton.getModel(), true); init(); }