Example usage for javax.swing ButtonGroup ButtonGroup

List of usage examples for javax.swing ButtonGroup ButtonGroup

Introduction

In this page you can find the example usage for javax.swing ButtonGroup ButtonGroup.

Prototype

public ButtonGroup() 

Source Link

Document

Creates a new ButtonGroup.

Usage

From source file:v800_trainer.JCicloTronic.java

/** Creates new form JCicloTronic */
public JCicloTronic() {

    ScreenSize = new Dimension();
    SelectionChanged = false;//  w ww .  ja  v  a 2 s . c  o m
    ScreenSize.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth() - 50,
            java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 50);
    Size = new Dimension();

    Properties = new java.util.Properties();
    SystemProperties = java.lang.System.getProperties();
    chooser = new javax.swing.JFileChooser();
    RawData = new byte[98316];
    //        System.setProperty("jna.library.path" , "C:/WINDOWS/system32");

    try {
        FileInputStream in = new FileInputStream(SystemProperties.getProperty("user.dir")
                + SystemProperties.getProperty("file.separator") + "JCicloexp.cfg");
        Properties.load(in);
        in.close();
    } catch (Exception e) {
        FontSize = 20;
        setFontSizeGlobal("Tahoma", FontSize);

        JOptionPane.showMessageDialog(null,
                "Keine Config-Datei in:  " + SystemProperties.getProperty("user.dir"), "Achtung!",
                JOptionPane.ERROR_MESSAGE);
        Properties.put("working.dir", SystemProperties.getProperty("user.dir"));
        Eigenschaften = new Eigenschaften(new javax.swing.JFrame(), true, this);
        this.setExtendedState(Frame.MAXIMIZED_BOTH);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        double width = screenSize.getWidth();
        double height = screenSize.getHeight();
        this.setSize(new Dimension((int) width, (int) height));
        this.setPreferredSize(new Dimension((int) width, (int) height));
        this.setMinimumSize(new Dimension((int) width, (int) height));
        repaint();
    }
    try {

        UIManager.setLookAndFeel(Properties.getProperty("LookFeel"));
        SwingUtilities.updateComponentTreeUI(this);
        this.pack();
    } catch (Exception exc) {
    }

    if (debug) {
        try {
            System.setErr(new java.io.PrintStream(new FileOutputStream(Properties.getProperty("working.dir")
                    + SystemProperties.getProperty("file.separator") + "error.txt")));
            //        System.err =  new FileOutputStream(Properties.getProperty("working.dir") + SystemProperties.getProperty("file.separator") + "error.txt");
            System.setOut(new java.io.PrintStream(new FileOutputStream(Properties.getProperty("working.dir")
                    + SystemProperties.getProperty("file.separator") + "error.txt")));
        } catch (Exception err) {
        }
    }

    initComponents();

    setTitle("V800 Trainer    Datadir: " + Properties.getProperty("data.dir"));

    icon = new ImageIcon("hw.jpg");
    setIconImage(icon.getImage());

    if (Integer.parseInt(Properties.getProperty("View Geschw", "1")) == 1) {
        Graphik_check_Geschwindigkeit.setSelected(true);
    } else {
        Graphik_check_Geschwindigkeit.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Hhe", "1")) == 1) {
        Graphik_check_Hhe.setSelected(true);
    } else {
        Graphik_check_Hhe.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Hf", "1")) == 1) {
        Graphik_check_HF.setSelected(true);
    } else {
        Graphik_check_HF.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Temp", "1")) == 1) {
        Graphik_check_Temp.setSelected(true);
    } else {
        Graphik_check_Temp.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Steigp", "1")) == 1) {
        Graphik_check_Steigung_p.setSelected(true);
    } else {
        Graphik_check_Steigung_p.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Steigm", "1")) == 1) {
        Graphik_check_Steigung_m.setSelected(true);
    } else {
        Graphik_check_Steigung_m.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View av_Geschw", "1")) == 1) {
        Graphik_check_av_Geschw.setSelected(true);
    } else {
        Graphik_check_av_Geschw.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Cadence", "1")) == 1) {
        Graphik_check_Cadence.setSelected(true);
    } else {
        Graphik_check_Cadence.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("View Schrittlnge", "1")) == 1) {
        Graphik_check_Schrittlnge.setSelected(true);
    } else {
        Graphik_check_Schrittlnge.setSelected(false);
    }

    if (Integer.parseInt(Properties.getProperty("ZeitStreckeAbstnde", "1")) == 1) {
        Graphik_check_Abstand.setSelected(true);
    } else {
        Graphik_check_Abstand.setSelected(false);
    }
    if (Integer.parseInt(Properties.getProperty("SummenHisto", "1")) == 1) {
        Summenhistogramm_Check.setSelected(true);
    } else {
        Summenhistogramm_Check.setSelected(false);
    }

    if (Integer.parseInt(Properties.getProperty("xy_Strecke", "1")) == 1) {
        Graphik_Radio_Strecke.setSelected(true);
        Graphik_Radio_Zeit.setSelected(false);
    } else {
        Graphik_Radio_Strecke.setSelected(false);
        Graphik_Radio_Zeit.setSelected(true);
    }

    //Buttons fr XY-Darstellung   (ber Strecke oder ber Zeit)
    X_Axis = new ButtonGroup();
    X_Axis.add(Graphik_Radio_Strecke);
    X_Axis.add(Graphik_Radio_Zeit);

    //Buttons fr Jahresbersicht
    bersicht = new ButtonGroup();
    bersicht.add(jRadioButton_jahresverlauf);
    bersicht.add(jRadioButton_monatsbersicht);

    Datenliste_Zeitabschnitt.addItem("nicht aktiv");
    Datenliste_Zeitabschnitt.addItem("vergangene Woche");
    Datenliste_Zeitabschnitt.addItem("vergangener Monat");
    Datenliste_Zeitabschnitt.addItem("vergangenes Jahr");
    Datenliste_Zeitabschnitt.addItem("Alles");

    if (Datentabelle.getRowCount() != 0) {
        Datentabelle.addRowSelectionInterval(0, 0);
        Datenliste_scroll_Panel.getViewport().setViewPosition(new java.awt.Point(0, 0));
    }
    //        if (Properties.getProperty("CommPort").equals("nocom")) {
    //            jMenuReceive.setEnabled(false);
    //        } else {
    //            jMenuReceive.setEnabled(true);
    //        }

    jLabel69_Selektiert.setText(Datentabelle.getSelectedRowCount() + " / " + Datentabelle.getRowCount());

    setFileChooserFont(chooser.getComponents());
    locmap = true;
    Map_Type.removeAllItems();
    Map_Type.addItem("OpenStreetMap");
    Map_Type.addItem("Virtual Earth Map");
    Map_Type.addItem("Virtual Earth Satelite");
    Map_Type.addItem("Virtual Earth Hybrid");
    locmap = false;
    //    ChangeModel();
}

From source file:com.milkdairy.collectionsmodule.CollectionsUpdateFormJPanel.java

public void init() {
    this.setLayout(null);
    System.setProperty("collectionsStoredFormColor", this.color);
    this.setBackground(Color.getColor("collectionsStoredFormColor"));

    this.formerIDL = this.addComponent(formerIDL, milkManagementSystemService.xPoint,
            milkManagementSystemService.yPoint, milkManagementSystemService.lblWidth,
            milkManagementSystemService.lblHeight);
    this.formerIDL.setText("Former ID");
    formerIDTF = this.addComponent(formerIDTF,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20,
            milkManagementSystemService.yPoint, milkManagementSystemService.tfWidth,
            milkManagementSystemService.tflHeight);
    formerIDTF.setEditable(false);// w  w  w  .  j  a  v a  2 s  .  c o  m

    this.formerIDErrorL = this.addComponent(formerIDErrorL,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth
                    + milkManagementSystemService.tfWidth + 40,
            milkManagementSystemService.yPoint, milkManagementSystemService.lblWidth,
            milkManagementSystemService.lblHeight);
    this.formerIDErrorL.setForeground(Color.RED);

    this.formerNameL = this.addComponent(formerNameL, milkManagementSystemService.xPoint,
            milkManagementSystemService.yPoint + 40, milkManagementSystemService.lblWidth,
            milkManagementSystemService.lblHeight);
    this.formerNameL.setText("Former Name");
    formerNameTF = this.addComponent(formerNameTF,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20,
            milkManagementSystemService.yPoint + 40, milkManagementSystemService.tfWidth,
            milkManagementSystemService.tflHeight);
    formerNameTF.setEditable(false);
    this.formerNameErrorL = this.addComponent(formerNameErrorL,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth
                    + milkManagementSystemService.tfWidth + 40,
            milkManagementSystemService.yPoint + 40, milkManagementSystemService.lblWidth,
            milkManagementSystemService.lblHeight);
    this.formerNameErrorL.setForeground(Color.RED);

    this.milkPadL = this.addComponent(milkPadL, milkManagementSystemService.xPoint,
            milkManagementSystemService.yPoint + 80, milkManagementSystemService.lblWidth,
            milkManagementSystemService.lblHeight);
    this.milkPadL.setText("Milk Pad Value");
    milkPadTF = this.addComponent(milkPadTF,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20,
            milkManagementSystemService.yPoint + 80, milkManagementSystemService.tfWidth,
            milkManagementSystemService.tflHeight);
    this.milkPadErrorL = this.addComponent(milkPadErrorL,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth
                    + milkManagementSystemService.tfWidth + 40,
            milkManagementSystemService.yPoint + 80, milkManagementSystemService.lblWidth,
            milkManagementSystemService.lblHeight);
    this.milkPadErrorL.setForeground(Color.RED);

    this.milkValueL = this.addComponent(milkValueL, milkManagementSystemService.xPoint,
            milkManagementSystemService.yPoint + 120, milkManagementSystemService.lblWidth,
            milkManagementSystemService.lblHeight);
    this.milkValueL.setText("Milk Quantity");
    milkValueTF = this.addComponent(milkValueTF,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20,
            milkManagementSystemService.yPoint + 120, milkManagementSystemService.tfWidth,
            milkManagementSystemService.tflHeight);
    this.milkValueErrorL = this.addComponent(milkValueErrorL,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth
                    + milkManagementSystemService.tfWidth + 40,
            milkManagementSystemService.yPoint + 120, milkManagementSystemService.lblWidth,
            milkManagementSystemService.lblHeight);
    this.milkValueErrorL.setForeground(Color.RED);

    this.milkPriceL = this.addComponent(milkPriceL, milkManagementSystemService.xPoint,
            milkManagementSystemService.yPoint + 160, milkManagementSystemService.lblWidth,
            milkManagementSystemService.lblHeight);
    this.milkPriceL.setText("Milk Price");
    milkPriceTF = this.addComponent(milkPriceTF,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20,
            milkManagementSystemService.yPoint + 160, milkManagementSystemService.tfWidth,
            milkManagementSystemService.tflHeight);
    this.milkPriceErrorL = this.addComponent(milkPriceErrorL,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth
                    + milkManagementSystemService.tfWidth + 40,
            milkManagementSystemService.yPoint + 160, milkManagementSystemService.lblWidth,
            milkManagementSystemService.lblHeight);
    this.milkPriceErrorL.setForeground(Color.RED);

    this.saveBtn = this.addComponent(this.saveBtn,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20,
            milkManagementSystemService.yPoint + 200, 80, 30);
    this.saveBtn.setText("Save");
    this.saveBtn.setForeground(Color.BLUE);
    this.add(this.saveBtn);

    this.saveBtn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {

            milkPriceErrorL.setText("");
            milkPadErrorL.setText("");
            milkValueErrorL.setText("");
            milkPriceErrorL.setText("");
            formerNameErrorL.setText("");
            formerIDErrorL.setText("");
            if ("".equals(formerIDTF.getText())) {
                formerIDErrorL.setText(ERROR_FORM);
            } else if ("".equals(formerNameTF.getText())) {
                formerNameErrorL.setText(ERROR_FORM);
            } else if ("".equals(milkPadTF.getText())) {
                milkPadErrorL.setText(ERROR_FORM);
            } else if ("".equals(milkValueTF.getText())) {
                milkValueErrorL.setText(ERROR_FORM);
            } else if ("".equals(milkPriceTF.getText())) {
                milkPriceErrorL.setText(ERROR_FORM);
            }
            //            else if (formerIDCombo.getSelectedItem() == null) {
            //               System.out.println("Former id selection Error");
            //         }
            //               else if (startdateTimePicker == null) {
            //               System.out.println("date selection Error");
            //            }
            else {
                Milk milk = new Milk();
                milk.setFormerID(formerIDCombo.getSelectedItem().toString());
                milk.setName(formerNameTF.getText());
                milk.setPadValue(milkPadTF.getText());
                milk.setQuantity(milkValueTF.getText());
                milk.setRate(milkPriceTF.getText());
                milk.setDate("dsad");
                System.out.println("Im in Former create and save submit action " + milk.toString());
                //filePersistenceManager.save(milk);
            }
            System.out.println("Im in Former create and update submit action");
        }
    });

    this.resetBtn = this.addComponent(this.resetBtn,
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 140,
            milkManagementSystemService.yPoint + 200, 80, 30);
    this.resetBtn.setText("Reset");
    this.resetBtn.setForeground(Color.BLUE);
    this.add(this.resetBtn);

    this.resetBtn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {

            milkPriceTF.setText("");
            milkPadTF.setText("");
            milkValueTF.setText("");
            milkPriceTF.setText("");
            System.out.println("Im in Former create and update submit action");
        }
    });

    collectionMonthDetailsJP = new CollectionMonthDetailsJPanel();
    collectionMonthDetailsJP.setBounds(
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2
                    + milkManagementSystemService.tfWidth * 2,
            milkManagementSystemService.yPoint,
            (milkManagementSystemService.SCREEN_WIDTH / 2) - milkManagementSystemService.tfWidth / 5, 400);
    this.add(collectionMonthDetailsJP);

    List<String> formerIds = persistenceManager.getFormerValues("id");
    if (!CollectionUtils.isEmpty(formerIds)) {
        ids = new String[formerIds.size()];
        formerIds.toArray(ids);
    }

    formerIDCombo = new JComboBox(ids);
    // has to be editable
    formerIDCombo.setEditable(true);

    // change the editor's document
    new CustomInitialSelectionComboBox(formerIDCombo);

    formerIDCombo.setBounds(
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2
                    + milkManagementSystemService.tfWidth + 40,
            milkManagementSystemService.yPoint, milkManagementSystemService.lblWidth + 20,
            milkManagementSystemService.lblHeight + 10);
    formerIDCombo.setMaximumRowCount(5);
    this.add(formerIDCombo);

    List<String> formerNames = persistenceManager.getFormerValues("name");
    if (!CollectionUtils.isEmpty(formerNames)) {
        names = new String[formerNames.size()];
        formerNames.toArray(names);
    }
    System.out.println("Names1 " + formerNames);
    formerNameCombo = new JComboBox(names);
    // has to be editable
    formerNameCombo.setEditable(true);

    // change the editor's document
    new CustomInitialSelectionComboBox(formerNameCombo);

    //customerIDListScrollPane = new JScrollPane(customerIDCombo);
    formerNameCombo.setBounds(
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2
                    + milkManagementSystemService.tfWidth + 40,
            milkManagementSystemService.yPoint + milkManagementSystemService.lblHeight + 20,
            milkManagementSystemService.lblWidth + 20, milkManagementSystemService.lblHeight + 10);
    formerNameCombo.setMaximumRowCount(5);
    this.add(formerNameCombo);

    UtilDateModel model = new UtilDateModel();
    model.setDate(2016, 04, 16);
    model.setSelected(true);

    Properties p = new Properties();
    p.put("text.today", "Today");
    p.put("text.month", "Month");
    p.put("text.year", "Year");
    JDatePanelImpl datePanel = new JDatePanelImpl(model, p);

    datePicker = new JDatePickerImpl(datePanel, new DateLabelFormatter());
    datePicker.setBounds(
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2
                    + milkManagementSystemService.tfWidth + 40,
            milkManagementSystemService.yPoint + milkManagementSystemService.lblHeight + 60,
            milkManagementSystemService.lblWidth + 20, milkManagementSystemService.lblHeight + 5);
    this.add(datePicker);

    am = new JRadioButton("AM", true);
    pm = new JRadioButton("PM");
    //Group the radio buttons.
    ButtonGroup amPmgroup = new ButtonGroup();
    amPmgroup.add(am);
    amPmgroup.add(pm);
    am.setBounds(
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2
                    + milkManagementSystemService.tfWidth + 40,
            milkManagementSystemService.yPoint + milkManagementSystemService.lblHeight + 100,
            milkManagementSystemService.lblWidth / 2, milkManagementSystemService.lblHeight + 5);
    this.add(am);
    pm.setBounds(
            milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2
                    + milkManagementSystemService.tfWidth + 40 + milkManagementSystemService.lblWidth / 2,
            milkManagementSystemService.yPoint + milkManagementSystemService.lblHeight + 100,
            milkManagementSystemService.lblWidth / 2, milkManagementSystemService.lblHeight + 5);
    this.add(pm);

    this.search = this.addComponent(this.search,
            milkManagementSystemService.xPoint + (milkManagementSystemService.lblWidth * 2)
                    + milkManagementSystemService.tfWidth + 60,
            milkManagementSystemService.yPoint + 200, 80, 30);
    this.search.setText("Search");
    this.search.setForeground(Color.BLUE);
    this.add(this.search);

    this.search.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            System.out.println("Im in Former create and update submit action");
            System.out.println("Former id" + (String) formerIDCombo.getSelectedItem());
            System.out.println("Former name" + (String) formerNameCombo.getSelectedItem());
            System.out.println("Am   " + am.isSelected());
            System.out.println("pm   " + pm.isSelected());

            String forID = (String) formerIDCombo.getSelectedItem();
            String forName = (String) formerNameCombo.getSelectedItem();
            String amPMStr = am.isSelected() ? "AM" : "PM";
            String dateTime = DateTimeUtil
                    .convertdateToStringeWithTime((Date) datePicker.getModel().getValue());
            System.out.println("Seleted date " + dateTime);
            List<Collection> collectionList = persistenceManager.getCollectionsBy(forID, forName, amPMStr,
                    dateTime);
            if (!CollectionUtils.isEmpty(collectionList)) {
                Collection searchCollection = collectionList.get(0);
                formerNameTF.setText(searchCollection.getFormerName());
                ;
                formerIDTF.setText(searchCollection.getFormerID());
                ;
                milkPadTF.setText(searchCollection.getMilkPad());
                ;
                milkValueTF.setText(searchCollection.getMilkQuantity());
                ;
                milkPriceTF.setText(searchCollection.getMilkPrice());
                ;
            }
        }
    });

    //      UtilDateModel model = new UtilDateModel();
    //      JDatePanelImpl datePanel = new JDatePanelImpl(model, null);
    //      JDatePickerImpl datePicker = new JDatePickerImpl(datePanel, null);
    //       
    //      this.add(datePicker);
    //      JSpinner timeSpinner = new JSpinner( new SpinnerDateModel() );
    //      JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "HH:mm:ss");
    //      timeSpinner.setEditor(timeEditor);
    //      timeSpinner.setValue(new Date()); 
    //      timeSpinner.setBounds();
    //      this.add(timeSpinner);

    //       DateTimePicker dateTimePicker = new DateTimePicker();
    //        dateTimePicker.setFormats( DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.MEDIUM ) );
    //        dateTimePicker.setTimeFormat( DateFormat.getTimeInstance( DateFormat.MEDIUM ) );
    //        dateTimePicker.setDate(new Date());
    //        dateTimePicker.setBounds(milkManagementSystemService.xPoint
    //             + (milkManagementSystemService.lblWidth*2)+milkManagementSystemService.tfWidth+60,
    //             milkManagementSystemService.yPoint + 200, 80, 30);
    //        this.add(dateTimePicker);

}

From source file:DialogDemo.java

/** Creates the panel shown by the second tab. */
private JPanel createFeatureDialogBox() {
    final int numButtons = 5;
    JRadioButton[] radioButtons = new JRadioButton[numButtons];
    final ButtonGroup group = new ButtonGroup();

    JButton showItButton = null;/*w  ww . j  ava2 s  .c o m*/

    final String pickOneCommand = "pickone";
    final String textEnteredCommand = "textfield";
    final String nonAutoCommand = "nonautooption";
    final String customOptionCommand = "customoption";
    final String nonModalCommand = "nonmodal";

    radioButtons[0] = new JRadioButton("Pick one of several choices");
    radioButtons[0].setActionCommand(pickOneCommand);

    radioButtons[1] = new JRadioButton("Enter some text");
    radioButtons[1].setActionCommand(textEnteredCommand);

    radioButtons[2] = new JRadioButton("Non-auto-closing dialog");
    radioButtons[2].setActionCommand(nonAutoCommand);

    radioButtons[3] = new JRadioButton("Input-validating dialog " + "(with custom message area)");
    radioButtons[3].setActionCommand(customOptionCommand);

    radioButtons[4] = new JRadioButton("Non-modal dialog");
    radioButtons[4].setActionCommand(nonModalCommand);

    for (int i = 0; i < numButtons; i++) {
        group.add(radioButtons[i]);
    }
    radioButtons[0].setSelected(true);

    showItButton = new JButton("Show it!");
    showItButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String command = group.getSelection().getActionCommand();

            // pick one of many
            if (command == pickOneCommand) {
                Object[] possibilities = { "ham", "spam", "yam" };
                String s = (String) JOptionPane.showInputDialog(frame,
                        "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog",
                        JOptionPane.PLAIN_MESSAGE, icon, possibilities, "ham");

                // If a string was returned, say so.
                if ((s != null) && (s.length() > 0)) {
                    setLabel("Green eggs and... " + s + "!");
                    return;
                }

                // If you're here, the return value was null/empty.
                setLabel("Come on, finish the sentence!");

                // text input
            } else if (command == textEnteredCommand) {
                String s = (String) JOptionPane.showInputDialog(frame,
                        "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog",
                        JOptionPane.PLAIN_MESSAGE, icon, null, "ham");

                // If a string was returned, say so.
                if ((s != null) && (s.length() > 0)) {
                    setLabel("Green eggs and... " + s + "!");
                    return;
                }

                // If you're here, the return value was null/empty.
                setLabel("Come on, finish the sentence!");

                // non-auto-closing dialog
            } else if (command == nonAutoCommand) {
                final JOptionPane optionPane = new JOptionPane(
                        "The only way to close this dialog is by\n" + "pressing one of the following buttons.\n"
                                + "Do you understand?",
                        JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);

                // You can't use pane.createDialog() because that
                // method sets up the JDialog with a property change
                // listener that automatically closes the window
                // when a button is clicked.
                final JDialog dialog = new JDialog(frame, "Click a button", true);
                dialog.setContentPane(optionPane);
                dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
                dialog.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent we) {
                        setLabel("Thwarted user attempt to close window.");
                    }
                });
                optionPane.addPropertyChangeListener(new PropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent e) {
                        String prop = e.getPropertyName();

                        if (dialog.isVisible() && (e.getSource() == optionPane)
                                && (JOptionPane.VALUE_PROPERTY.equals(prop))) {
                            // If you were going to check something
                            // before closing the window, you'd do
                            // it here.
                            dialog.setVisible(false);
                        }
                    }
                });
                dialog.pack();
                dialog.setLocationRelativeTo(frame);
                dialog.setVisible(true);

                int value = ((Integer) optionPane.getValue()).intValue();
                if (value == JOptionPane.YES_OPTION) {
                    setLabel("Good.");
                } else if (value == JOptionPane.NO_OPTION) {
                    setLabel("Try using the window decorations " + "to close the non-auto-closing dialog. "
                            + "You can't!");
                } else {
                    setLabel("Window unavoidably closed (ESC?).");
                }

                // non-auto-closing dialog with custom message area
                // NOTE: if you don't intend to check the input,
                // then just use showInputDialog instead.
            } else if (command == customOptionCommand) {
                customDialog.setLocationRelativeTo(frame);
                customDialog.setVisible(true);

                String s = customDialog.getValidatedText();
                if (s != null) {
                    // The text is valid.
                    setLabel("Congratulations!  " + "You entered \"" + s + "\".");
                }

                // non-modal dialog
            } else if (command == nonModalCommand) {
                // Create the dialog.
                final JDialog dialog = new JDialog(frame, "A Non-Modal Dialog");

                // Add contents to it. It must have a close button,
                // since some L&Fs (notably Java/Metal) don't provide one
                // in the window decorations for dialogs.
                JLabel label = new JLabel("<html><p align=center>" + "This is a non-modal dialog.<br>"
                        + "You can have one or more of these up<br>" + "and still use the main window.");
                label.setHorizontalAlignment(JLabel.CENTER);
                Font font = label.getFont();
                label.setFont(label.getFont().deriveFont(font.PLAIN, 14.0f));

                JButton closeButton = new JButton("Close");
                closeButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        dialog.setVisible(false);
                        dialog.dispose();
                    }
                });
                JPanel closePanel = new JPanel();
                closePanel.setLayout(new BoxLayout(closePanel, BoxLayout.LINE_AXIS));
                closePanel.add(Box.createHorizontalGlue());
                closePanel.add(closeButton);
                closePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));

                JPanel contentPane = new JPanel(new BorderLayout());
                contentPane.add(label, BorderLayout.CENTER);
                contentPane.add(closePanel, BorderLayout.PAGE_END);
                contentPane.setOpaque(true);
                dialog.setContentPane(contentPane);

                // Show it.
                dialog.setSize(new Dimension(300, 150));
                dialog.setLocationRelativeTo(frame);
                dialog.setVisible(true);
            }
        }
    });

    return createPane(moreDialogDesc + ":", radioButtons, showItButton);
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.filtering.FilteringController.java

/**
 * Initialize the main view: the filtering panel (the two sub-views are kept
 * in two separate controllers)./*from   ww  w . j  a v a 2s  .  c o  m*/
 */
private void initFilteringPanel() {
    // make a new view
    filteringPanel = new FilteringPanel();
    // make a new radio button group for the radio buttons
    ButtonGroup radioButtonGroup = new ButtonGroup();
    radioButtonGroup.add(filteringPanel.getSingleCutOffRadioButton());
    radioButtonGroup.add(filteringPanel.getMultipleCutOffRadioButton());
    // select the first one as default
    filteringPanel.getMultipleCutOffRadioButton().setSelected(true);

    // set icon for question button
    Icon questionIcon = UIManager.getIcon("OptionPane.questionIcon");
    ImageIcon scaledQuestionIcon = GuiUtils.getScaledIcon(questionIcon);
    filteringPanel.getQuestionButton().setIcon(scaledQuestionIcon);

    // action listeners
    // info button
    filteringPanel.getQuestionButton().addActionListener((ActionEvent e) -> {
        // pack and show info dialog
        GuiUtils.centerDialogOnFrame(singleCellPreProcessingController.getMainFrame(), filteringInfoDialog);
        filteringInfoDialog.setVisible(true);
    });

    // which criterium for the filtering?
    filteringPanel.getMultipleCutOffRadioButton().addActionListener((ActionEvent e) -> {
        // need to reset the conditions list back to active
        singleCellPreProcessingController.getConditionsList().setEnabled(true);
        // set as the current condition the first one in the list
        singleCellPreProcessingController
                .setCurrentCondition(singleCellPreProcessingController.getPlateConditionList().get(0));
        singleCellPreProcessingController.getAnalysisPlatePanel()
                .setCurrentCondition(singleCellPreProcessingController.getPlateConditionList().get(0));
        singleCellPreProcessingController.getAnalysisPlatePanel().repaint();

        // get the layout from the bottom panel and show the appropriate one
        CardLayout layout = (CardLayout) filteringPanel.getBottomPanel().getLayout();
        layout.show(filteringPanel.getBottomPanel(), filteringPanel.getMultipleCutOffParentPanel().getName());

        multipleCutOffFilteringController.plotRawKdeMultipleCutOff(getCurrentCondition());
        setMedianDisplForCondition(getCurrentCondition());
        setMedianDisplForExperiment();
    });

    filteringPanel.getSingleCutOffRadioButton().addActionListener((ActionEvent e) -> {
        // need to disable the conditions list
        singleCellPreProcessingController.getConditionsList().clearSelection();
        singleCellPreProcessingController.getConditionsList().setEnabled(false);
        singleCellPreProcessingController.setCurrentCondition(null);
        singleCellPreProcessingController.getAnalysisPlatePanel().setCurrentCondition(null);
        singleCellPreProcessingController.getAnalysisPlatePanel().repaint();
        // get the layout from the bottom panel and show the appropriate one
        CardLayout layout = (CardLayout) filteringPanel.getBottomPanel().getLayout();
        layout.show(filteringPanel.getBottomPanel(), filteringPanel.getSingleCutOffParentPanel().getName());

        singleCutOffFilteringController.plotRawKdeSingleCutOff();
        setMedianDisplForExperiment();
        singleCutOffFilteringController.showMedianDisplInList();

    });

    // add view to parent container
    singleCellPreProcessingController.getSingleCellAnalysisPanel().getFilteringParentPanel().add(filteringPanel,
            gridBagConstraints);
}

From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java

public void addRadioButton(int x, int y, String text, String toolTipText, String[] bValues, int defaultIndex,
        JPanel panel, ActionListener l) {
    JPanel p = new JPanel();

    p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

    GridBagConstraints c = new GridBagConstraints();
    c.gridx = x;/*from   w w  w  . jav a 2  s .co m*/
    c.gridy = y;

    ButtonGroup group = new ButtonGroup();

    p.setToolTipText(toolTipText);
    p.add(new JLabel(text));

    rButtons = new JRadioButton[bValues.length];
    for (int i = 0; i < bValues.length; i++) {
        rButtons[i] = new JRadioButton(bValues[i]);
        rButtons[i].setName(bValues[i]);
        rButtons[i].addActionListener(l);
        rButtons[i].setActionCommand(bValues[i]);
        p.add(rButtons[i]);
        group.add(rButtons[i]);
        if (defaultIndex == i)
            rButtons[i].setSelected(true);
    }
    panel.add(p, c);
}

From source file:com.digitalgeneralists.assurance.ui.MainWindow.java

private void initializeComponent() {
    if (!this.initialized) {
        logger.info("Initializing the main window.");

        if (AssuranceUtils.getPlatform() == Platform.MAC) {

            System.setProperty("apple.laf.useScreenMenuBar", "true");
            com.apple.eawt.Application macApplication = com.apple.eawt.Application.getApplication();
            MacApplicationAdapter macAdapter = new MacApplicationAdapter(this);
            macApplication.addApplicationListener(macAdapter);
            macApplication.setEnabledPreferencesMenu(true);
        }// ww  w.ja v a  2  s. co m

        this.setTitle(Application.applicationShortName);

        this.setDefaultCloseOperation(EXIT_ON_CLOSE);

        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        this.topArea = new JTabbedPane();

        this.scanLaunchPanel.setPreferredSize(new Dimension(600, 150));

        this.scanHistoryPanel.setPreferredSize(new Dimension(600, 150));

        this.topArea.addTab("Scan", this.scanLaunchPanel);

        this.topArea.addTab("History", this.scanHistoryPanel);

        this.resultsPanel.setPreferredSize(new Dimension(600, 400));

        this.topArea.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                resultsPanel.resetPanel();
                // NOTE:  This isn't ideal.  It feels brittle.
                if (topArea.getSelectedIndex() == viewHistoryMenuItemIndex) {
                    viewHistoryMenuItem.setSelected(true);
                } else {
                    viewScanMenuItem.setSelected(true);
                }
            }
        });

        GridBagConstraints topPanelConstraints = new GridBagConstraints();
        topPanelConstraints.anchor = GridBagConstraints.NORTH;
        topPanelConstraints.fill = GridBagConstraints.BOTH;
        topPanelConstraints.gridx = 0;
        topPanelConstraints.gridy = 0;
        topPanelConstraints.weightx = 1.0;
        topPanelConstraints.weighty = 0.33;
        topPanelConstraints.gridheight = 1;
        topPanelConstraints.gridwidth = 1;
        topPanelConstraints.insets = new Insets(0, 0, 0, 0);

        this.getContentPane().add(this.topArea, topPanelConstraints);

        GridBagConstraints resultsPanelConstraints = new GridBagConstraints();
        resultsPanelConstraints.anchor = GridBagConstraints.SOUTH;
        resultsPanelConstraints.fill = GridBagConstraints.BOTH;
        resultsPanelConstraints.gridx = 0;
        resultsPanelConstraints.gridy = 1;
        resultsPanelConstraints.weightx = 1.0;
        resultsPanelConstraints.weighty = 0.67;
        resultsPanelConstraints.gridheight = 1;
        resultsPanelConstraints.gridwidth = 1;
        resultsPanelConstraints.insets = new Insets(0, 0, 0, 0);

        this.getContentPane().add(this.resultsPanel, resultsPanelConstraints);

        this.applicationDelegate.addEventObserver(ScanStartedEvent.class, this);
        this.applicationDelegate.addEventObserver(ScanCompletedEvent.class, this);
        this.applicationDelegate.addEventObserver(SetScanDefinitionMenuStateEvent.class, this);
        this.applicationDelegate.addEventObserver(SetScanResultsMenuStateEvent.class, this);
        this.applicationDelegate.addEventObserver(ApplicationConfigurationLoadedEvent.class, this);

        JMenu menu;
        JMenuItem menuItem;

        menuBar = new JMenuBar();

        StringBuilder accessiblityLabel = new StringBuilder(128);
        if (AssuranceUtils.getPlatform() != Platform.MAC) {
            menu = new JMenu(Application.applicationShortName);
            menu.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Actions for ")
                    .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuBar.add(menu);

            menuItem = new JMenuItem(MainWindow.quitApplicationMenuLabel, KeyEvent.VK_Q);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
            menuItem.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Close the ")
                    .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.quitApplicationAction);
            menu.add(menuItem);

            menu.addSeparator();

            menuItem = new JMenuItem(MainWindow.aboutApplicationMenuLabel);
            menuItem.getAccessibleContext().setAccessibleDescription(
                    accessiblityLabel.append("Display information about this version of ")
                            .append(Application.applicationShortName).append(".").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.aboutApplicationAction);
            menu.add(menuItem);
        }

        menu = new JMenu("Scan");
        menu.setMnemonic(KeyEvent.VK_S);
        menu.getAccessibleContext().setAccessibleDescription("Actions for file scans");
        menuBar.add(menu);

        menuItem = new JMenuItem(MainWindow.newScanDefinitonMenuLabel, KeyEvent.VK_N);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription("Create a new scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.newScanDefinitonAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.deleteScanDefinitonMenuLabel, KeyEvent.VK_D);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription("Delete the selected scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.deleteScanDefinitonAction);
        menu.add(menuItem);

        menu.addSeparator();

        menuItem = new JMenuItem(MainWindow.scanMenuLabel, KeyEvent.VK_S);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Launch a scan using the selected scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.scanAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.scanAndMergeMenuLabel, KeyEvent.VK_M);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription(
                "Launch a scan using the selected scan definition and merge the results");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.scanAndMergeAction);
        menu.add(menuItem);

        menu = new JMenu("Results");
        menu.setMnemonic(KeyEvent.VK_R);
        menu.getAccessibleContext().setAccessibleDescription("Actions for scan results");
        menuBar.add(menu);

        menuItem = new JMenuItem(MainWindow.replaceSourceMenuLabel, KeyEvent.VK_O);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Replace the source file with the target file");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.replaceSourceAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.replaceTargetMenuLabel, KeyEvent.VK_T);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Replace the target file with the source file");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.replaceTargetAction);
        menu.add(menuItem);

        menu.addSeparator();

        menuItem = new JMenuItem(MainWindow.sourceAttributesMenuLabel);
        menuItem.getAccessibleContext().setAccessibleDescription("View the source file attributes");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.sourceAttributesAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.targetAttributesMenuLabel);
        menuItem.getAccessibleContext().setAccessibleDescription("View the target file attributes");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.targetAttributesAction);
        menu.add(menuItem);

        menu = new JMenu("View");
        menu.setMnemonic(KeyEvent.VK_V);
        menu.getAccessibleContext().setAccessibleDescription(
                accessiblityLabel.append("Views within ").append(Application.applicationShortName).toString());
        accessiblityLabel.setLength(0);
        menuBar.add(menu);

        ButtonGroup group = new ButtonGroup();

        this.viewScanMenuItem = new JRadioButtonMenuItem(MainWindow.viewScanMenuLabel);
        this.viewScanMenuItem.addActionListener(this);
        this.viewScanMenuItem.setActionCommand(AssuranceActions.viewScanAction);
        this.viewScanMenuItem.setSelected(true);
        group.add(this.viewScanMenuItem);
        menu.add(this.viewScanMenuItem);

        this.viewHistoryMenuItem = new JRadioButtonMenuItem(MainWindow.viewHistoryMenuLabel);
        this.viewHistoryMenuItem.addActionListener(this);
        this.viewHistoryMenuItem.setActionCommand(AssuranceActions.viewHistoryAction);
        this.viewHistoryMenuItem.setSelected(true);
        group.add(this.viewHistoryMenuItem);
        menu.add(this.viewHistoryMenuItem);

        if (AssuranceUtils.getPlatform() != Platform.MAC) {
            menu = new JMenu("Tools");
            menu.getAccessibleContext()
                    .setAccessibleDescription(accessiblityLabel.append("Additional actions for ")
                            .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuBar.add(menu);

            menuItem = new JMenuItem(MainWindow.settingsMenuLabel, KeyEvent.VK_COMMA);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, ActionEvent.CTRL_MASK));
            menuItem.getAccessibleContext()
                    .setAccessibleDescription(accessiblityLabel.append("Change settings for the ")
                            .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.displaySettingsAction);
            menu.add(menuItem);
        }

        this.setJMenuBar(menuBar);

        this.initialized = true;
    }
}

From source file:algorithm.QRCodeWatermarking.java

/**
 * Initialises the GUI buttons./*from w w  w .  j a  v a  2 s .  co  m*/
 */
private void initButtons() {
    ButtonGroup encapsulateGroup = new ButtonGroup();
    encapsulateGroup.add(trueEncapsulate);
    encapsulateGroup.add(falseEncapsulate);
    trueEncapsulate.setSelected(true);
    messageLabel.setForeground(Color.red);
}

From source file:JModem.java

/** Finish the initializations. */
private void finishConstructor() {
    // Create the textarea with a JScrollpane wrapping it.
    // Install it in Centre of the TextArea.
    theTextArea = new MyTextArea(20, 80);
    getContentPane().add(new JScrollPane(theTextArea), BorderLayout.CENTER);
    plainFont = new Font("courier", Font.PLAIN, 13);
    theTextArea.setFont(plainFont);/*w  w w.  j  a v a 2 s .  c  o m*/
    xferFileNameTF.setFont(plainFont);

    theModel.populateComboBox();
    portsComboBox.setSelectedIndex(0);

    // Load up the baud rate combo box
    for (int i = 0; i < baudot.length; i++) {
        baudComboBox.addItem(Integer.toString(baudot[i]));
    }
    baudComboBox.setSelectedIndex(0);

    // Load up the System Type combo box
    for (int i = 0; i < sysTypes.length; i++) {
        sysTypeComboBox.addItem(sysTypes[i]);
    }
    sysTypeComboBox.setSelectedIndex(0);

    // put radio buttons into groups to enforce single-selection
    ButtonGroup b1 = new ButtonGroup();
    b1.add(d7RadioButton);
    b1.add(d8RadioButton);

    ButtonGroup b2 = new ButtonGroup();
    b2.add(pNoneRadioButton);
    b2.add(pEvenRadioButton);
    b2.add(pOddRadioButton);

    ButtonGroup b3 = new ButtonGroup();
    b3.add(sendRadioButton);
    b3.add(recvRadioButton);

    ButtonGroup b4 = new ButtonGroup();
    b4.add(xferModeTextRadioButton);
    b4.add(xferModeBinRadioButton);
    xferModeBinRadioButton.setEnabled(true);
}

From source file:com.mirth.connect.connectors.tcp.TcpListener.java

private void initComponents() {
    setBackground(UIConstants.BACKGROUND_COLOR);

    transmissionModeLabel = new JLabel("Transmission Mode:");
    transmissionModeComboBox = new MirthComboBox<String>();
    transmissionModeComboBox.addActionListener(new ActionListener() {
        @Override// ww w  .j  a  v a  2s  .co m
        public void actionPerformed(ActionEvent evt) {
            transmissionModeComboBoxActionPerformed();
        }
    });

    settingsPlaceHolder = new JPanel();

    sampleLabel = new JLabel("Sample Frame:");
    sampleValue = new JLabel(
            "<html><b>&lt;VT&gt;</b> <i>&lt;Message Data&gt;</i> <b>&lt;FS&gt;&lt;CR&gt;</b></html>");
    sampleValue.setForeground(new Color(153, 153, 153));
    sampleValue.setEnabled(false);

    modeLabel = new JLabel("Mode:");
    ButtonGroup modeButtonGroup = new ButtonGroup();

    modeServerRadio = new MirthRadioButton("Server");
    modeServerRadio.setBackground(getBackground());
    modeServerRadio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            modeServerRadioActionPerformed();
        }
    });
    modeButtonGroup.add(modeServerRadio);

    modeClientRadio = new MirthRadioButton("Client");
    modeClientRadio.setBackground(getBackground());
    modeClientRadio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            modeClientRadioActionPerformed();
        }
    });
    modeButtonGroup.add(modeClientRadio);

    remoteAddressLabel = new JLabel("Remote Address:");
    remoteAddressField = new MirthTextField();

    remotePortLabel = new JLabel("Remote Port:");
    remotePortField = new MirthTextField();

    overrideLocalBindingLabel = new JLabel("Override Local Binding:");
    ButtonGroup overrideLocalBindingButtonGroup = new ButtonGroup();

    overrideLocalBindingYesRadio = new MirthRadioButton("Yes");
    overrideLocalBindingYesRadio.setBackground(getBackground());
    overrideLocalBindingButtonGroup.add(overrideLocalBindingYesRadio);

    overrideLocalBindingNoRadio = new MirthRadioButton("No");
    overrideLocalBindingNoRadio.setBackground(getBackground());
    overrideLocalBindingButtonGroup.add(overrideLocalBindingNoRadio);

    reconnectIntervalLabel = new JLabel("Reconnect Interval (ms):");
    reconnectIntervalField = new MirthTextField();

    maxConnectionsLabel = new JLabel("Max Connections:");
    maxConnectionsField = new MirthTextField();

    receiveTimeoutLabel = new JLabel("Receive Timeout (ms):");
    receiveTimeoutField = new MirthTextField();

    bufferSizeLabel = new JLabel("Buffer Size (bytes):");
    bufferSizeField = new MirthTextField();

    keepConnectionOpenLabel = new JLabel("Keep Connection Open:");
    ButtonGroup keepConnectionOpenGroup = new ButtonGroup();

    keepConnectionOpenYesRadio = new MirthRadioButton("Yes");
    keepConnectionOpenYesRadio.setBackground(getBackground());
    keepConnectionOpenGroup.add(keepConnectionOpenYesRadio);

    keepConnectionOpenNoRadio = new MirthRadioButton("No");
    keepConnectionOpenNoRadio.setBackground(getBackground());
    keepConnectionOpenGroup.add(keepConnectionOpenNoRadio);

    dataTypeLabel = new JLabel("Data Type:");
    ButtonGroup dataTypeButtonGroup = new ButtonGroup();

    dataTypeBinaryRadio = new MirthRadioButton("Binary");
    dataTypeBinaryRadio.setBackground(getBackground());
    dataTypeBinaryRadio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            dataTypeBinaryRadioActionPerformed();
        }
    });
    dataTypeButtonGroup.add(dataTypeBinaryRadio);

    dataTypeTextRadio = new MirthRadioButton("Text");
    dataTypeTextRadio.setBackground(getBackground());
    dataTypeTextRadio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            dataTypeASCIIRadioActionPerformed();
        }
    });
    dataTypeButtonGroup.add(dataTypeTextRadio);

    charsetEncodingLabel = new JLabel("Encoding:");
    charsetEncodingComboBox = new MirthComboBox<CharsetEncodingInformation>();

    respondOnNewConnectionLabel = new JLabel("Respond on New Connection:");
    ButtonGroup respondOnNewConnectionButtonGroup = new ButtonGroup();

    respondOnNewConnectionYesRadio = new MirthRadioButton("Yes");
    respondOnNewConnectionYesRadio.setBackground(getBackground());
    respondOnNewConnectionYesRadio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            respondOnNewConnectionYesRadioActionPerformed();
        }
    });
    respondOnNewConnectionButtonGroup.add(respondOnNewConnectionYesRadio);

    respondOnNewConnectionNoRadio = new MirthRadioButton("No");
    respondOnNewConnectionNoRadio.setBackground(getBackground());
    respondOnNewConnectionNoRadio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            respondOnNewConnectionNoRadioActionPerformed();
        }
    });
    respondOnNewConnectionButtonGroup.add(respondOnNewConnectionNoRadio);

    respondOnNewConnectionRecoveryRadio = new MirthRadioButton("Message Recovery");
    respondOnNewConnectionRecoveryRadio.setBackground(getBackground());
    respondOnNewConnectionRecoveryRadio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            respondOnNewConnectionRecoveryRadioActionPerformed();
        }
    });
    respondOnNewConnectionButtonGroup.add(respondOnNewConnectionRecoveryRadio);

    responseAddressLabel = new JLabel("Response Address:");
    responseAddressField = new MirthTextField();

    responsePortLabel = new JLabel("Response Port:");
    responsePortField = new MirthTextField();
}

From source file:com.mirth.connect.client.ui.SettingsPanelAdministrator.java

private void initComponents() {
    setBackground(UIConstants.BACKGROUND_COLOR);

    systemSettingsPanel = new JPanel();
    systemSettingsPanel.setBackground(getBackground());
    systemSettingsPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "System Preferences",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    dashboardRefreshIntervalLabel = new JLabel("Dashboard refresh interval (seconds):");
    dashboardRefreshIntervalField = new MirthTextField();
    dashboardRefreshIntervalField.setToolTipText(
            "<html>Interval in seconds at which to refresh the Dashboard. Decrement this for <br>faster updates, and increment it for slower servers with more channels.</html>");

    String toolTipText = "Sets the default page size for browsers (message, event, etc.)";
    messageBrowserPageSizeLabel = new JLabel("Message browser page size:");
    messageBrowserPageSizeField = new MirthTextField();
    messageBrowserPageSizeField.setToolTipText(toolTipText);

    eventBrowserPageSizeLabel = new JLabel("Event browser page size:");
    eventBrowserPageSizeField = new MirthTextField();
    eventBrowserPageSizeField.setToolTipText(toolTipText);

    formatLabel = new JLabel("Format text in message browser:");
    formatButtonGroup = new ButtonGroup();

    toolTipText = "Pretty print messages in the message browser.";
    formatYesRadio = new MirthRadioButton("Yes");
    formatYesRadio.setBackground(systemSettingsPanel.getBackground());
    formatYesRadio.setToolTipText(toolTipText);
    formatButtonGroup.add(formatYesRadio);

    formatNoRadio = new MirthRadioButton("No");
    formatNoRadio.setBackground(systemSettingsPanel.getBackground());
    formatNoRadio.setToolTipText(toolTipText);
    formatButtonGroup.add(formatNoRadio);

    textSearchWarningLabel = new JLabel("Message browser text search confirmation:");
    textSearchWarningButtonGroup = new ButtonGroup();

    toolTipText = "<html>Show a confirmation dialog in the message browser when attempting a text search, warning users<br/>that the query may take a long time depending on the amount of messages being searched.</html>";
    textSearchWarningYesRadio = new MirthRadioButton("Yes");
    textSearchWarningYesRadio.setBackground(systemSettingsPanel.getBackground());
    textSearchWarningYesRadio.setToolTipText(toolTipText);
    textSearchWarningButtonGroup.add(textSearchWarningYesRadio);

    textSearchWarningNoRadio = new MirthRadioButton("No");
    textSearchWarningNoRadio.setBackground(systemSettingsPanel.getBackground());
    textSearchWarningNoRadio.setToolTipText(toolTipText);
    textSearchWarningButtonGroup.add(textSearchWarningNoRadio);

    importChannelLibrariesLabel = new JLabel("Import code template libraries with channels:");
    importChannelLibrariesButtonGroup = new ButtonGroup();

    toolTipText = "<html>When attempting to import channels that have code template<br/>libraries linked to them, select Yes to always include them,<br/>No to never include them, or Ask to prompt the user each time.</html>";
    importChannelLibrariesYesRadio = new MirthRadioButton("Yes");
    importChannelLibrariesYesRadio.setBackground(systemSettingsPanel.getBackground());
    importChannelLibrariesYesRadio.setToolTipText(toolTipText);
    importChannelLibrariesButtonGroup.add(importChannelLibrariesYesRadio);

    importChannelLibrariesNoRadio = new MirthRadioButton("No");
    importChannelLibrariesNoRadio.setBackground(systemSettingsPanel.getBackground());
    importChannelLibrariesNoRadio.setToolTipText(toolTipText);
    importChannelLibrariesButtonGroup.add(importChannelLibrariesNoRadio);

    importChannelLibrariesAskRadio = new MirthRadioButton("Ask");
    importChannelLibrariesAskRadio.setBackground(systemSettingsPanel.getBackground());
    importChannelLibrariesAskRadio.setToolTipText(toolTipText);
    importChannelLibrariesButtonGroup.add(importChannelLibrariesAskRadio);

    exportChannelLibrariesLabel = new JLabel("Export code template libraries with channels:");
    exportChannelLibrariesButtonGroup = new ButtonGroup();

    toolTipText = "<html>When attempting to export channels that have code template<br/>libraries linked to them, select Yes to always include them,<br/>No to never include them, or Ask to prompt the user each time.</html>";
    exportChannelLibrariesYesRadio = new MirthRadioButton("Yes");
    exportChannelLibrariesYesRadio.setBackground(systemSettingsPanel.getBackground());
    exportChannelLibrariesYesRadio.setToolTipText(toolTipText);
    exportChannelLibrariesButtonGroup.add(exportChannelLibrariesYesRadio);

    exportChannelLibrariesNoRadio = new MirthRadioButton("No");
    exportChannelLibrariesNoRadio.setBackground(systemSettingsPanel.getBackground());
    exportChannelLibrariesNoRadio.setToolTipText(toolTipText);
    exportChannelLibrariesButtonGroup.add(exportChannelLibrariesNoRadio);

    exportChannelLibrariesAskRadio = new MirthRadioButton("Ask");
    exportChannelLibrariesAskRadio.setBackground(systemSettingsPanel.getBackground());
    exportChannelLibrariesAskRadio.setToolTipText(toolTipText);
    exportChannelLibrariesButtonGroup.add(exportChannelLibrariesAskRadio);

    userSettingsPanel = new JPanel();
    userSettingsPanel.setBackground(getBackground());
    userSettingsPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "User Preferences",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    checkForNotificationsLabel = new JLabel("Check for new notifications on login:");
    notificationButtonGroup = new ButtonGroup();

    checkForNotificationsYesRadio = new MirthRadioButton("Yes");
    checkForNotificationsYesRadio.setBackground(userSettingsPanel.getBackground());
    checkForNotificationsYesRadio.setToolTipText(
            "<html>Checks for notifications from Mirth (announcements, available updates, etc.)<br/>relevant to this version of Mirth Connect whenever user logs in.</html>");
    notificationButtonGroup.add(checkForNotificationsYesRadio);

    checkForNotificationsNoRadio = new MirthRadioButton("No");
    checkForNotificationsNoRadio.setBackground(userSettingsPanel.getBackground());
    checkForNotificationsNoRadio.setToolTipText(
            "<html>Checks for notifications from Mirth (announcements, available updates, etc.)<br/>relevant to this version of Mirth Connect whenever user logs in.</html>");
    notificationButtonGroup.add(checkForNotificationsNoRadio);

    codeEditorSettingsPanel = new JPanel();
    codeEditorSettingsPanel.setBackground(getBackground());
    codeEditorSettingsPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Code Editor Preferences",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    toolTipText = "<html>The auto-completion popup will be triggered<br/>after any of these characters are typed.</html>";
    autoCompleteCharactersLabel = new JLabel("Auto-Complete Characters:");
    autoCompleteCharactersField = new MirthTextField();
    autoCompleteCharactersField.setToolTipText(toolTipText);
    autoCompleteCharactersField.getDocument().addDocumentListener(new DocumentListener() {
        @Override//from   w  ww .  j  av a2s  .c o  m
        public void insertUpdate(DocumentEvent evt) {
            autoCompleteActionPerformed();
        }

        @Override
        public void removeUpdate(DocumentEvent evt) {
            autoCompleteActionPerformed();
        }

        @Override
        public void changedUpdate(DocumentEvent evt) {
            autoCompleteActionPerformed();
        }
    });

    toolTipText = "<html>If selected, auto-completion will be<br/>triggered after any letter is typed.</html>";
    autoCompleteIncludeLettersCheckBox = new MirthCheckBox("Include Letters");
    autoCompleteIncludeLettersCheckBox.setBackground(codeEditorSettingsPanel.getBackground());
    autoCompleteIncludeLettersCheckBox.setToolTipText(toolTipText);
    autoCompleteIncludeLettersCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            autoCompleteActionPerformed();
        }
    });

    toolTipText = "<html>The amount of time to wait after typing<br/>an activation character before opening<br/>the auto-completion popup menu.</html>";
    autoCompleteDelayLabel = new JLabel("Activation Delay (ms):");
    autoCompleteDelayField = new MirthTextField();
    autoCompleteDelayField.setToolTipText(toolTipText);
    autoCompleteDelayField.setDocument(new MirthFieldConstraints(9, false, false, true));

    shortcutKeyLabel = new JLabel("Shortcut Key Mappings:");

    shortcutKeyTable = new MirthTable();
    shortcutKeyTable.setModel(new RefreshTableModel(
            new Object[] { "Action Info", "Name", "Description", "Shortcut Key Mapping" }, 0) {
        @Override
        public boolean isCellEditable(int row, int column) {
            return column == KEY_COLUMN;
        }
    });

    shortcutKeyTable.setDragEnabled(false);
    shortcutKeyTable.setRowSelectionAllowed(false);
    shortcutKeyTable.setRowHeight(UIConstants.ROW_HEIGHT);
    shortcutKeyTable.setFocusable(false);
    shortcutKeyTable.setOpaque(true);
    shortcutKeyTable.setSortable(true);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        shortcutKeyTable.setHighlighters(HighlighterFactory
                .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR));
    }

    shortcutKeyTable.getColumnModel().getColumn(NAME_COLUMN).setMinWidth(145);
    shortcutKeyTable.getColumnModel().getColumn(NAME_COLUMN).setPreferredWidth(145);

    shortcutKeyTable.getColumnModel().getColumn(DESCRIPTION_COLUMN).setPreferredWidth(600);

    shortcutKeyTable.getColumnModel().getColumn(KEY_COLUMN).setMinWidth(120);
    shortcutKeyTable.getColumnModel().getColumn(KEY_COLUMN).setPreferredWidth(150);
    shortcutKeyTable.getColumnModel().getColumn(KEY_COLUMN).setCellRenderer(new KeyStrokeCellRenderer());
    shortcutKeyTable.getColumnModel().getColumn(KEY_COLUMN).setCellEditor(new KeyStrokeCellEditor());

    shortcutKeyTable.removeColumn(shortcutKeyTable.getColumnModel().getColumn(ACTION_INFO_COLUMN));

    shortcutKeyTable.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent evt) {
            updateRestoreDefaultsButton();
        }
    });

    shortcutKeyScrollPane = new JScrollPane(shortcutKeyTable);

    restoreDefaultsButton = new JButton("Restore Defaults");
    restoreDefaultsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            restoreDefaults();
        }
    });
}