List of usage examples for javax.swing JRadioButton getText
public String getText()
From source file:ItemTest.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); ItemListener listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { System.out.println("Source: " + name(e.getSource())); System.out.println("Item: " + name(e.getItem())); int state = e.getStateChange(); System.out.println("State: " + ((state == ItemEvent.SELECTED) ? "Selected" : "Deselected")); }/*from ww w .j a v a 2 s. com*/ private String name(Object o) { if (o instanceof JComponent) { JComponent comp = (JComponent) o; return comp.getName(); } else { return o.toString(); } } }; JPanel panel = new JPanel(new GridLayout(0, 1)); ButtonGroup group = new ButtonGroup(); JRadioButton option = new JRadioButton("French Fries", true); option.setName(option.getText()); option.addItemListener(listener); group.add(option); panel.add(option); option = new JRadioButton("Onion Rings", false); option.setName(option.getText()); option.addItemListener(listener); group.add(option); panel.add(option); option = new JRadioButton("Ice Cream", false); option.setName(option.getText()); option.addItemListener(listener); group.add(option); panel.add(option); contentPane.add(panel, BorderLayout.NORTH); String flavors[] = { "Item 1", "Item 2", "Item 3" }; JComboBox jc = new JComboBox(flavors); jc.setName("Combo"); jc.addItemListener(listener); jc.setMaximumRowCount(4); contentPane.add(jc, BorderLayout.SOUTH); frame.pack(); frame.show(); }
From source file:com.jdom.util.patterns.mvp.swing.RadioButtonGroupDialog.java
public void actionPerformed(ActionEvent e) { if ("OK".equals(e.getActionCommand())) { for (Component comp : panel.getComponents()) { if (comp instanceof JRadioButton) { JRadioButton checkbox = (JRadioButton) comp; if (checkbox.isSelected()) { RadioButtonGroupDialog.selectedValue = checkbox.getText(); }/*from w w w . j a va 2s.c o m*/ } } } RadioButtonGroupDialog.dialog.setVisible(false); }
From source file:com.windows.MainJFrame.java
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed // TODO add your handling code here: JRadioButton temp = (JRadioButton) evt.getSource(); if (temp.isSelected()) { scanDirection = temp.getText(); }// www .jav a 2s . com }
From source file:com.windows.MainJFrame.java
private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed // TODO add your handling code here: JRadioButton temp = (JRadioButton) evt.getSource(); if (temp.isSelected()) { scanDirection = temp.getText(); }/*from w ww .j av a 2s. c om*/ }
From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java
public void refreshButtons(FileInstance fileInstance, int groupId) { Enumeration buttons;/*from ww w. j a v a 2 s . co m*/ if (groupId == Utilities.XSD_GROUP) { buttons = groupXsd.getElements(); } else { buttons = groupXslt.getElements(); } while (buttons.hasMoreElements()) { JRadioButton jRadioButton = (JRadioButton) buttons.nextElement(); if (jRadioButton.getText().equals(fileInstance.getConversionScriptName()) || jRadioButton.getText().equals(fileInstance.getValidationSchemaName())) { jRadioButton.setSelected(true); break; } } }
From source file:userInterface.HospitalAdminRole.ManagePatientsJPanel.java
private void submitVisitStatusBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_submitVisitStatusBtnActionPerformed Enumeration<AbstractButton> bg = visitBtnGrp.getElements(); while (bg.hasMoreElements()) { JRadioButton jrd = (JRadioButton) bg.nextElement(); int selectedRow = vitalSignAlertsTable.getSelectedRow(); Date currentDate = new Date(); HosptoHouseWorkRequest request = (HosptoHouseWorkRequest) vitalSignAlertsTable.getValueAt(selectedRow, 0);/* w w w .ja va2s.c om*/ if (jrd.isSelected()) { if (selectedRow >= 0) { if (request.getAppointmentDate() != null) { if (jrd.getText().equals("Visited")) { if (!request.getStatus().equals("Cancelled")) { if (request.getAppointmentDate().compareTo(currentDate) < 0) { if (request.getStatus().equals("Confirmed")) { request.setStatus("Visited"); populateAlertFamilyTable(); } else if (request.getStatus().equals("Cancelled")) { JOptionPane.showMessageDialog(null, "Appointment is already cancelled", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); } else if (request.getStatus().equals("Dint Show Up")) { JOptionPane.showMessageDialog(null, "Person dint show up.", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Check after the appointment time", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); return; } } else { JOptionPane.showMessageDialog(null, "Appointment is already cancelled", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); } } else if (jrd.getText().equals("Dint Show Up")) { // HosptoHouseWorkRequest request = (HosptoHouseWorkRequest)vitalSignAlertsTable.getValueAt(selectedRow, 0); if (!request.getStatus().equals("Cancelled")) { if (request.getAppointmentDate().compareTo(currentDate) < 0) { if (request.getStatus().equals("Confirmed")) { request.setStatus("Dint Show Up"); populateAlertFamilyTable(); } else if (request.getStatus().equals("Visited")) { JOptionPane.showMessageDialog(null, "Person already visited.", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Check after the appointment time", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Appointment is already cancelled", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); } } else if (jrd.getText().equals("Cancel")) { // HosptoHouseWorkRequest request = (HosptoHouseWorkRequest)vitalSignAlertsTable.getValueAt(selectedRow, 0); if (!request.getStatus().equals("Cancelled")) { if (request.getAppointmentDate().compareTo(currentDate) > 0) { if (request.getStatus().equals("Confirmed")) { request.setStatus("Cancelled"); populateAlertFamilyTable(); } else { request.setStatus("Cancelled"); populateAlertFamilyTable(); } } else { JOptionPane.showMessageDialog(null, "Can be cancelled before appointment time", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Appointment is already cancelled", "WARNING", JOptionPane.WARNING_MESSAGE); } } } else { JOptionPane.showMessageDialog(null, "Appointment not requested", "MESSAGE", JOptionPane.INFORMATION_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Kindly select a row!", "WARNING", JOptionPane.WARNING_MESSAGE); } } } }
From source file:ffx.ui.ModelingPanel.java
/** * This handles conditional command option input. * * @param evt ActionEvent/*w w w . j av a 2s. co m*/ */ private void conditionalCommandEvent(ActionEvent evt) { Object source = evt.getSource(); if (source instanceof JRadioButton) { JRadioButton jrb = (JRadioButton) source; String selection = jrb.getText().toLowerCase(); for (JLabel label : conditionals) { JTextField jtf = (JTextField) label.getLabelFor(); String cupon = label.getName().toLowerCase(); if (cupon.contains(selection) && jrb.isSelected()) { label.setEnabled(true); jtf.setEnabled(true); } else { label.setEnabled(false); jtf.setEnabled(false); } } } else if (source instanceof JCheckBox) { JCheckBox jcb = (JCheckBox) source; String selection = jcb.getText().toLowerCase(); for (JLabel label : conditionals) { String cupon = label.getName().toLowerCase(); JTextField jtf = (JTextField) label.getLabelFor(); if (cupon.contains(selection) && jcb.isSelected()) { label.setEnabled(true); jtf.setEnabled(true); } else { label.setEnabled(false); jtf.setEnabled(false); } } } statusLabel.setText(" " + createCommandInput()); }
From source file:ffx.ui.ModelingPanel.java
/** * Create a string representing the modeling command to execute. * * @return the modeling command string.//from ww w . j a v a2 s.c o m */ private String createCommandInput() { StringBuilder commandLineParams = new StringBuilder(activeCommand + " "); // Now append command line input to a TextArea, one option per line. // This TextArea gets dumped to an input file. commandTextArea.setText(""); int numparams = optionsTabbedPane.getTabCount(); for (int i = 0; i < numparams; i++) { // A few cases require that a newLine not be generated between // options. boolean newLine = true; // The optionString will collect the parameters for this Option, // then append them to the CommandTextArea. StringBuilder optionString = new StringBuilder(); JPanel optionPanel = (JPanel) optionsTabbedPane.getComponentAt(i); int numOptions = optionPanel.getComponentCount(); String title = optionsTabbedPane.getTitleAt(i); if (title.equalsIgnoreCase("Sequence")) { for (int k = 0; k < acidComboBox.getItemCount(); k++) { if (k != 0) { optionString.append("\n"); } String s = (String) acidComboBox.getItemAt(k); s = s.substring(s.indexOf(" "), s.length()).trim(); optionString.append(s); } // Need an extra newline for Nucleic if (activeCommand.equalsIgnoreCase("NUCLEIC")) { optionString.append("\n"); } } else { JPanel valuePanel = (JPanel) optionPanel.getComponent(numOptions - 1); int numValues = valuePanel.getComponentCount(); for (int j = 0; j < numValues; j++) { Component value = valuePanel.getComponent(j); if (value instanceof JCheckBox) { JCheckBox jcbox = (JCheckBox) value; if (jcbox.isSelected()) { optionString.append("-"); optionString.append(jcbox.getName()); optionString.append(" "); optionString.append(jcbox.getText()); } } else if (value instanceof JTextField) { JTextField jtfield = (JTextField) value; optionString.append("-"); optionString.append(jtfield.getName()); optionString.append(" "); optionString.append(jtfield.getText()); } else if (value instanceof JComboBox) { JComboBox jcb = (JComboBox) value; Object object = jcb.getSelectedItem(); if (object instanceof FFXSystem) { FFXSystem system = (FFXSystem) object; File file = system.getFile(); if (file != null) { String absolutePath = file.getAbsolutePath(); if (absolutePath.endsWith("xyz")) { absolutePath = absolutePath + "_1"; } optionString.append(absolutePath); } } } else if (value instanceof JRadioButton) { JRadioButton jrbutton = (JRadioButton) value; if (jrbutton.isSelected()) { if (!jrbutton.getText().equalsIgnoreCase("NONE")) { optionString.append("-"); optionString.append(jrbutton.getName()); optionString.append(" "); optionString.append(jrbutton.getText()); } if (title.equalsIgnoreCase("C-CAP")) { optionString.append("\n"); } } } } // Handle Conditional Options if (optionPanel.getComponentCount() == 3) { valuePanel = (JPanel) optionPanel.getComponent(1); // JLabel conditionalLabel = (JLabel) // valuePanel.getComponent(0); JTextField jtf = (JTextField) valuePanel.getComponent(1); if (jtf.isEnabled()) { String conditionalInput = jtf.getText(); // Post-Process the Input into Atom Pairs String postProcess = jtf.getName(); if (postProcess != null && postProcess.equalsIgnoreCase("ATOMPAIRS")) { String tokens[] = conditionalInput.split(" +"); StringBuilder atomPairs = new StringBuilder(); int atomNumber = 0; for (String token : tokens) { atomPairs.append(token); if (atomNumber++ % 2 == 0) { atomPairs.append(" "); } else { atomPairs.append("\n"); } } conditionalInput = atomPairs.toString(); } // Append a newline to "enter" the option string. // Append "conditional" input. optionString.append("\n").append(conditionalInput); } } } if (optionString.length() > 0) { commandTextArea.append(optionString.toString()); if (newLine) { commandTextArea.append("\n"); } } } String commandInput = commandTextArea.getText(); if (commandInput != null && !commandInput.trim().equalsIgnoreCase("")) { commandLineParams.append(commandInput); } // The final token on the command line is the structure file name, except // for protein and nucleic. if (!activeCommand.equalsIgnoreCase("Protein") && !activeCommand.equalsIgnoreCase("Nucleic")) { File file = activeSystem.getFile(); if (file != null) { String name = file.getName(); commandLineParams.append(name); commandLineParams.append(" "); } else { return null; } } return commandLineParams.toString(); }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java
private void errorsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) { JRadioButton errorsRadioButton = (JRadioButton) evt.getSource(); showErrorPane(errorsRadioButton.getText()); lastUserSelectedErrorType = errorsRadioButton.getText(); }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java
private void messagesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) { JRadioButton messagesRadioButton = (JRadioButton) evt.getSource(); showMessagePane(messagesRadioButton.getText()); lastUserSelectedMessageType = messagesRadioButton.getText(); }