List of usage examples for javax.swing JRadioButton getModel
public ButtonModel getModel()
From source file:Main.java
public static void main(String[] argv) throws Exception { JRadioButton radioButton = new JRadioButton(); ButtonGroup group = new ButtonGroup(); ButtonModel model = radioButton.getModel(); group.setSelected(model, true);//from w ww . j a va 2 s. c o m }
From source file:Main.java
public static JRadioButton getSelection(ButtonGroup group) { for (Enumeration e = group.getElements(); e.hasMoreElements();) { JRadioButton b = (JRadioButton) e.nextElement(); if (b.getModel() == group.getSelection()) { return b; }// w ww. j av a 2s.com } return null; }
From source file:Main.java
/** * This method returns the selected radio button in a button group. * @param group the button group//ww w .j a v a 2 s . c o m * @return the selected radio button */ public static JRadioButton getSelectedRadioButton(ButtonGroup group) { for (Enumeration e = group.getElements(); e.hasMoreElements();) { JRadioButton b = (JRadioButton) e.nextElement(); if (b.getModel() == group.getSelection()) { return b; } } return null; }
From source file:Main.java
/** * Determines if radio button is selected. * //from w w w. ja v a 2 s. c o m * @param radioButton * @return */ public static boolean isRadioButtonSelected(JRadioButton radioButton) { DefaultButtonModel model = (DefaultButtonModel) radioButton.getModel(); return model.getGroup().isSelected(model); }
From source file:view.transacao.Relatorio.java
public JRadioButton getSelectedRadio(ButtonGroup group) { for (Enumeration eRadio = group.getElements(); eRadio.hasMoreElements();) { JRadioButton radioButton = (JRadioButton) eRadio.nextElement(); if (radioButton.getModel() == group.getSelection()) { return radioButton; }// w ww .ja va2 s.c o m } return null; }
From source file:Main.java
public Main() { JRadioButton radMarriedYes = new JRadioButton("Yes?", true); JRadioButton radMarriedNo = new JRadioButton("No?", false); JRadioButton radGolfYes = new JRadioButton("Yes?", false); JRadioButton radGolfNo = new JRadioButton("No?", true); ButtonGroup radioGroup1 = new ButtonGroup(); ButtonGroup radioGroup2 = new ButtonGroup(); setLayout(null);//w w w.j a va 2 s. co m add(radMarriedYes); add(radMarriedNo); add(radGolfYes); add(radGolfNo); radioGroup1.add(radMarriedYes); radioGroup1.add(radMarriedNo); radioGroup1.isSelected(radMarriedNo.getModel()); radioGroup2.add(radGolfYes); radioGroup2.add(radGolfNo); radMarriedYes.setBounds(30, 50, 50, 20); radMarriedNo.setBounds(30, 80, 50, 20); radGolfYes.setBounds(150, 50, 50, 20); radGolfNo.setBounds(150, 80, 50, 20); }
From source file:org.fhcrc.cpl.viewer.quant.gui.QuantitationReviewer.java
/** * Initialize all GUI components and display the UI *///w ww. j a va2 s.c o m protected void initGUI() { settingsCLM = new ProteinQuantChartsCLM(false); setTitle("Qurate"); try { setIconImage(ImageIO.read(WorkbenchFrame.class.getResourceAsStream("icon.gif"))); } catch (Exception e) { } try { Localizer.renderSwixml("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewer.xml", this); assert null != contentPanel; } catch (Exception x) { ApplicationContext.errorMessage("error creating dialog", x); throw new RuntimeException(x); } //Menu openFileAction = new OpenFileAction(this); createChartsAction = new CreateChartsAction(); filterPepXMLAction = new FilterPepXMLAction(this); proteinSummaryAction = new ProteinSummaryAction(this); try { JMenuBar jmenu = (JMenuBar) Localizer.getSwingEngine(this) .render("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewerMenu.xml"); for (int i = 0; i < jmenu.getMenuCount(); i++) jmenu.getMenu(i).getPopupMenu().setLightWeightPopupEnabled(false); this.setJMenuBar(jmenu); } catch (Exception x) { ApplicationContext.errorMessage(TextProvider.getText("ERROR_LOADING_MENUS"), x); throw new RuntimeException(x); } //Global stuff setSize(fullWidth, fullHeight); setContentPane(contentPanel); ListenerHelper helper = new ListenerHelper(this); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(5, 5, 5, 5); gbc.weighty = 1; gbc.weightx = 1; leftPanel.setLayout(new GridBagLayout()); leftPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); //Properties panel stuff propertiesTable = new QuantEvent.QuantEventPropertiesTable(); propertiesScrollPane = new JScrollPane(); propertiesScrollPane.setViewportView(propertiesTable); propertiesScrollPane.setMinimumSize(new Dimension(propertiesWidth, propertiesHeight)); //event summary table; disembodied eventSummaryTable = new QuantEventsSummaryTable(); eventSummaryTable.setVisible(true); ListSelectionModel tableSelectionModel = eventSummaryTable.getSelectionModel(); tableSelectionModel.addListSelectionListener(new EventSummaryTableListSelectionHandler()); JScrollPane eventSummaryScrollPane = new JScrollPane(); eventSummaryScrollPane.setViewportView(eventSummaryTable); eventSummaryScrollPane.setSize(propertiesWidth, propertiesHeight); eventSummaryFrame = new Frame("All Events"); eventSummaryFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { eventSummaryFrame.setVisible(false); } }); eventSummaryFrame.setSize(950, 450); eventSummaryFrame.add(eventSummaryScrollPane); //fields related to navigation navigationPanel = new JPanel(); backButton = new JButton("<"); backButton.setToolTipText("Previous Event"); backButton.setMaximumSize(new Dimension(50, 30)); backButton.setEnabled(false); forwardButton = new JButton(">"); forwardButton.setToolTipText("Next Event"); forwardButton.setMaximumSize(new Dimension(50, 30)); forwardButton.setEnabled(false); showEventSummaryButton = new JButton("Show All"); showEventSummaryButton.setToolTipText("Show all events in a table"); showEventSummaryButton.setEnabled(false); helper.addListener(backButton, "buttonBack_actionPerformed"); helper.addListener(forwardButton, "buttonForward_actionPerformed"); helper.addListener(showEventSummaryButton, "buttonShowEventSummary_actionPerformed"); gbc.fill = GridBagConstraints.NONE; gbc.gridwidth = GridBagConstraints.RELATIVE; gbc.anchor = GridBagConstraints.WEST; navigationPanel.add(backButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; navigationPanel.add(forwardButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; navigationPanel.add(showEventSummaryButton, gbc); gbc.fill = GridBagConstraints.BOTH; navigationPanel.setBorder(BorderFactory.createTitledBorder("Event")); gbc.anchor = GridBagConstraints.PAGE_START; //Fields related to curation of events curationPanel = new JPanel(); curationPanel.setLayout(new GridBagLayout()); curationPanel.setBorder(BorderFactory.createTitledBorder("Curation")); //Quantitation curation JPanel quantCurationPanel = new JPanel(); quantCurationPanel.setLayout(new GridBagLayout()); quantCurationPanel.setBorder(BorderFactory.createTitledBorder("Quantitation")); quantCurationButtonGroup = new ButtonGroup(); JRadioButton unknownRadioButton = new JRadioButton("?"); JRadioButton goodRadioButton = new JRadioButton("Good"); JRadioButton badRadioButton = new JRadioButton("Bad"); onePeakRatioRadioButton = new JRadioButton("1-Peak"); unknownRadioButton.setEnabled(false); goodRadioButton.setEnabled(false); badRadioButton.setEnabled(false); onePeakRatioRadioButton.setEnabled(false); quantCurationButtonGroup.add(unknownRadioButton); quantCurationButtonGroup.add(goodRadioButton); quantCurationButtonGroup.add(badRadioButton); quantCurationButtonGroup.add(onePeakRatioRadioButton); unknownRadioButtonModel = unknownRadioButton.getModel(); goodRadioButtonModel = goodRadioButton.getModel(); badRadioButtonModel = badRadioButton.getModel(); onePeakRadioButtonModel = onePeakRatioRadioButton.getModel(); helper.addListener(unknownRadioButton, "buttonCuration_actionPerformed"); helper.addListener(goodRadioButton, "buttonCuration_actionPerformed"); helper.addListener(badRadioButton, "buttonCuration_actionPerformed"); helper.addListener(onePeakRadioButtonModel, "buttonCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; quantCurationPanel.add(unknownRadioButton, gbc); quantCurationPanel.add(badRadioButton, gbc); quantCurationPanel.add(goodRadioButton, gbc); quantCurationPanel.add(onePeakRatioRadioButton, gbc); gbc.anchor = GridBagConstraints.PAGE_START; //ID curation JPanel idCurationPanel = new JPanel(); idCurationPanel.setLayout(new GridBagLayout()); idCurationPanel.setBorder(BorderFactory.createTitledBorder("ID")); idCurationButtonGroup = new ButtonGroup(); JRadioButton idUnknownRadioButton = new JRadioButton("?"); JRadioButton idGoodRadioButton = new JRadioButton("Good"); JRadioButton idBadRadioButton = new JRadioButton("Bad"); idUnknownRadioButton.setEnabled(false); idGoodRadioButton.setEnabled(false); idBadRadioButton.setEnabled(false); idCurationButtonGroup.add(idUnknownRadioButton); idCurationButtonGroup.add(idGoodRadioButton); idCurationButtonGroup.add(idBadRadioButton); idUnknownRadioButtonModel = idUnknownRadioButton.getModel(); idGoodRadioButtonModel = idGoodRadioButton.getModel(); idBadRadioButtonModel = idBadRadioButton.getModel(); helper.addListener(idUnknownRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idGoodRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idBadRadioButton, "buttonIDCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; idCurationPanel.add(idUnknownRadioButton, gbc); idCurationPanel.add(idBadRadioButton, gbc); idCurationPanel.add(idGoodRadioButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; curationPanel.add(quantCurationPanel, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; curationPanel.add(idCurationPanel, gbc); //curation comment commentTextField = new JTextField(); commentTextField.setToolTipText("Comment on this event"); //saves after every keypress. Would be more efficient to save when navigating away or saving to file commentTextField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (quantEvents == null) return; QuantEvent quantEvent = quantEvents.get(displayedEventIndex); //save the comment, being careful about tabs and new lines quantEvent.setComment(commentTextField.getText().replace("\t", " ").replace("\n", " ")); } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { } }); curationPanel.add(commentTextField, gbc); assessmentPanel = new JPanel(); assessmentPanel.setLayout(new GridBagLayout()); assessmentPanel.setBorder(BorderFactory.createTitledBorder("Algorithmic Assessment")); assessmentTypeTextField = new JTextField(); assessmentTypeTextField.setEditable(false); assessmentPanel.add(assessmentTypeTextField, gbc); assessmentDescTextField = new JTextField(); assessmentDescTextField.setEditable(false); assessmentPanel.add(assessmentDescTextField, gbc); //Theoretical peak distribution gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; theoreticalPeaksPanel = new JPanel(); theoreticalPeaksPanel.setBorder(BorderFactory.createTitledBorder("Theoretical Peaks")); theoreticalPeaksPanel.setLayout(new GridBagLayout()); theoreticalPeaksPanel.setMinimumSize(new Dimension(leftPanelWidth - 10, theoreticalPeaksPanelHeight)); theoreticalPeaksPanel.setMaximumSize(new Dimension(1200, theoreticalPeaksPanelHeight)); showTheoreticalPeaks(); //Add everything to the left panel gbc.insets = new Insets(0, 5, 0, 5); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; leftPanel.addComponentListener(new LeftPanelResizeListener()); gbc.weighty = 10; gbc.fill = GridBagConstraints.VERTICAL; leftPanel.add(propertiesScrollPane, gbc); gbc.fill = GridBagConstraints.NONE; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_END; gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(assessmentPanel, gbc); leftPanel.add(theoreticalPeaksPanel, gbc); gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(curationPanel, gbc); leftPanel.add(navigationPanel, gbc); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_START; //Chart display multiChartDisplay = new TabbedMultiChartDisplayPanel(); multiChartDisplay.setResizeDelayMS(0); rightPanel.addComponentListener(new RightPanelResizeListener()); rightPanel.add(multiChartDisplay, gbc); //status message messageLabel.setBackground(Color.WHITE); messageLabel.setFont(Font.decode("verdana plain 12")); messageLabel.setText(" "); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); //paranoia. Sometimes it seems Qurate doesn't exit when you close every window addWindowStateListener(new WindowStateListener() { public void windowStateChanged(WindowEvent e) { if (e.getNewState() == WindowEvent.WINDOW_CLOSED) { dispose(); System.exit(0); } } }); }
From source file:src.gui.ItSIMPLE.java
/** * This method creates the panel containing the pddl version selection component * @return /*from w w w . jav a2 s .com*/ */ private JPanel getPddlVersionSettingsPanel() { JPanel settingsPanel = new JPanel(); JRadioButton pddl21 = new JRadioButton("PDDL 2.1"); JRadioButton pddl22 = new JRadioButton("PDDL 2.2"); JRadioButton pddl30 = new JRadioButton("PDDL 3.0", true); JRadioButton pddl31 = new JRadioButton("PDDL 3.1"); pddl21.setOpaque(false); pddl21.setActionCommand(ToXPDDL.PDDL_2_1); pddl22.setOpaque(false); pddl22.setActionCommand(ToXPDDL.PDDL_2_2); pddl30.setOpaque(false); pddl30.setActionCommand(ToXPDDL.PDDL_3_0); pddl31.setOpaque(false); pddl31.setActionCommand(ToXPDDL.PDDL_3_1); pddlButtonsGroup = new ButtonGroup(); pddlButtonsGroup.add(pddl21); pddlButtonsGroup.add(pddl22); pddlButtonsGroup.add(pddl30); pddlButtonsGroup.add(pddl31); pddlButtonsGroup.setSelected(pddl21.getModel(), true); settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.Y_AXIS)); settingsPanel.setOpaque(false); settingsPanel.add(pddl21); settingsPanel.add(pddl22); settingsPanel.add(pddl30); settingsPanel.add(pddl31); return settingsPanel; }
From source file:org.drugis.addis.gui.WelcomeDialog.java
public static JRadioButton getSelection(ButtonGroup group) { for (Enumeration<AbstractButton> e = group.getElements(); e.hasMoreElements();) { JRadioButton b = (JRadioButton) e.nextElement(); if (b.getModel() == group.getSelection()) { return b; }/* w w w .ja v a2 s. c om*/ } return null; }
From source file:org.mbs3.juniuploader.gui.pnlSettings.java
private void logLevelBtnAction(ActionEvent evt) { JRadioButton jbr = (JRadioButton) evt.getSource(); DefaultButtonModel bm = (DefaultButtonModel) jbr.getModel(); ButtonGroup bg = bm.getGroup(); String pkg = "org.mbs.juniuploader"; String logClass = pkg + ".util.GUILog"; java.util.Vector toMark = new java.util.Vector(); String level = jbr.getActionCommand(); log.info("Changing logging level to " + level + " for selected components"); if (bg == grpMain) { log.debug("grpMain setting up level " + level); String prefix = pkg + ""; toMark.add(new String(prefix + ".ClassRunner")); toMark.add(new String(prefix + ".ShutdownThread")); toMark.add(new String(prefix + ".StatusThread")); toMark.add(new String(prefix + ".Uploader")); toMark.add(new String(prefix + ".util.Prefs")); toMark.add(new String(prefix + ".util.Util")); } else if (bg == grpGUI) { log.debug("grpGUI setting up level " + level); String prefix = pkg + ".gui"; toMark.add(new String(prefix + ".frmMain")); toMark.add(new String(prefix + ".pnlDebug")); toMark.add(new String(prefix + ".pnlFormVariables")); toMark.add(new String(prefix + ".pnlMainMenu")); toMark.add(new String(prefix + ".pnlRemoteInterface")); toMark.add(new String(prefix + ".pnlSettings")); toMark.add(new String(prefix + ".pnlUploadRules")); toMark.add(new String(prefix + ".pnlUploadSites")); toMark.add(new String(prefix + ".pnlWoWDirectories")); } else if (bg == grpObjects) { log.debug("grpObjects setting up level " + level); String prefix = pkg + ".objects"; toMark.add(new String(prefix + ".Addon")); toMark.add(new String(prefix + ".AddonFile")); toMark.add(new String(prefix + ".LocalSystem")); toMark.add(new String(prefix + ".RemoteSystem")); prefix = pkg + ".objects.localobjects"; toMark.add(new String(prefix + ".LUAFile")); toMark.add(new String(prefix + ".WAccount")); toMark.add(new String(prefix + ".WDirectory")); prefix = pkg + ".objects.remoteobjects"; toMark.add(new String(prefix + ".FormPair")); toMark.add(new String(prefix + ".FormPairGroup")); toMark.add(new String(prefix + ".UploadRule")); toMark.add(new String(prefix + ".UploadSite")); prefix = pkg + ".objects.util"; toMark.add(new String(prefix + ".CheckSummer")); toMark.add(new String(prefix + ".MyVector")); toMark.add(new String(prefix + ".UUIDGen")); } else if (bg == grpHTTP) { log.debug("grpHTTP setting up level " + level); toMark.add(new String("httpclient.wire.header")); toMark.add(new String("org.apache.commons.httpclient")); } else {/*from w w w. ja v a2 s. com*/ log.info("Unknown button group!!"); } // now that we know what properties to set, let's set them Iterator i = toMark.iterator(); while (i.hasNext()) { String name = (String) i.next(); System.setProperty(logClass + "." + name, level); log.trace("Configuring " + logClass + "." + name + " to " + level); } }