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:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserUI.java

/** Helper method to create the menu bar. */
private void createMenuBars() {
    rightMenuBar = new JToolBar();
    rightMenuBar.setBorder(null);/*from   w  w  w.jav  a2 s .c  o  m*/
    rightMenuBar.setRollover(true);
    rightMenuBar.setFloatable(false);

    JButton button;
    leftMenuBar = new JToolBar();
    leftMenuBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
    leftMenuBar.setRollover(true);
    leftMenuBar.setFloatable(false);
    BrowserManageAction a;
    int type = model.getBrowserType();
    switch (type) {
    case Browser.PROJECTS_EXPLORER:
    case Browser.SCREENS_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_CONTAINER);
        button = new JButton(a);
        button.setName("new container button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
        break;
    case Browser.ADMIN_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_ADMIN);
        button = new JButton(a);
        button.setName("new group or user button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
        break;
    case Browser.TAGS_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_TAG);
        button = new JButton(a);
        button.setName("new tag button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
    }
    button = new JButton(controller.getAction(BrowserControl.CUT));
    button.setName("cut button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.COPY));
    button.setName("copy button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.PASTE));
    button.setName("paste button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.DELETE));
    button.setName("delete button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.REFRESH));
    button.setName("refresh button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);

    if (type == Browser.ADMIN_EXPLORER) {
        button = new JButton(controller.getAction(BrowserControl.RESET_PASSWORD));
        button.setBorderPainted(false);
        rightMenuBar.add(button);
    } else {
        button = new JButton(controller.getAction(BrowserControl.IMPORT));
        button.setBorderPainted(false);
        //rightMenuBar.add(button);
    }
    rightMenuBar.add(Box.createHorizontalStrut(6));
    rightMenuBar.add(new JSeparator());
    rightMenuBar.add(Box.createHorizontalStrut(6));
    ButtonGroup group = new ButtonGroup();
    JToggleButton b = new JToggleButton();
    group.add(b);
    b.setBorderPainted(true);
    b.setSelected(true);
    b.setAction(controller.getAction(BrowserControl.SORT));

    rightMenuBar.add(b);
    b = new JToggleButton(controller.getAction(BrowserControl.SORT_DATE));
    b.setBorderPainted(true);
    group.add(b);
    rightMenuBar.add(b);

    partialButton = new JToggleButton(controller.getAction(BrowserControl.PARTIAL_NAME));
    partialButton.setBorderPainted(true);
    rightMenuBar.add(partialButton);
    rightMenuBar.add(new JSeparator(JSeparator.VERTICAL));
    button = new JButton(controller.getAction(BrowserControl.COLLAPSE));
    button.setBorderPainted(false);
    rightMenuBar.add(button);
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.util.SaveResultsDialog.java

/**
 * Builds and lays out the elements indicating what to save.
 *
 * @return See above./* www  . j av a 2  s . co  m*/
 */
private JPanel buildContents() {
    JPanel buttons = new JPanel();
    buttons.add(UIUtilities.setTextFont("Save results for"));
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.Y_AXIS));
    ButtonGroup group = new ButtonGroup();
    JRadioButton b = new JRadioButton("Image from current window");
    b.setSelected(activeWindow);
    buttons.add(b);
    group.add(b);
    b.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            activeWindow = (e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    b = new JRadioButton("Images from all image windows");
    b.setSelected(activeWindow);
    buttons.add(b);
    group.add(b);
    buttons.add(Box.createRigidArea(UIUtilities.H_SPACER_SIZE));
    buttons.add(UIUtilities.setTextFont("Save"));
    buttons.add(roi);
    buttons.add(table);
    JPanel row = new JPanel();
    row.setLayout(new FlowLayout(FlowLayout.LEFT));
    JLabel l = new JLabel();
    l.setText("Measurements File Name: ");
    row.add(l);
    row.add(nameField);
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(UIUtilities.buildComponentPanel(buttons));
    p.add(row);
    return p;
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java

/**
 * Creates the items for the menu./* ww w.  j a va2  s.c  om*/
 * 
 * @param add Pass <code>true</code> to build items for the <code>Add</code>
 * menu, <code>false</code> otherwise.
 * @return See above
 */
private List<JMenuItem> createMenuItem(boolean add) {
    List<JMenuItem> items = new ArrayList<JMenuItem>();
    List<GroupSelectionAction> l = controller.getUserGroupAction(add);
    Iterator<GroupSelectionAction> i = l.iterator();
    GroupSelectionAction a;
    JMenuItem item;
    if (add) {
        //Check the groups that already in the view.
        Browser browser = model.getSelectedBrowser();
        List<Long> ids = new ArrayList<Long>();
        if (browser != null) {
            ExperimenterVisitor v = new ExperimenterVisitor(browser, -1);
            browser.accept(v, ExperimenterVisitor.TREEIMAGE_SET_ONLY);
            List<TreeImageDisplay> nodes = v.getNodes();
            Iterator<TreeImageDisplay> j = nodes.iterator();
            TreeImageDisplay node;
            while (j.hasNext()) {
                node = j.next();
                ids.add(((GroupData) node.getUserObject()).getId());
            }
        }

        while (i.hasNext()) {
            a = i.next();
            item = new JMenuItem(a);
            if (ids.size() > 0) {
                item.setEnabled(!ids.contains(a.getGroupId()));
            } else
                item.setEnabled(true);
            initMenuItem(item);
            items.add(item);
        }
    } else {
        ButtonGroup buttonGroup = new ButtonGroup();
        long id = model.getSelectedGroupId();
        while (i.hasNext()) {
            a = i.next();
            item = new JCheckBoxMenuItem(a);
            item.setEnabled(true);
            item.setSelected(a.isSameGroup(id));
            initMenuItem(item);
            buttonGroup.add(item);
            items.add(item);
        }
    }

    return items;
}

From source file:org.parosproxy.paros.view.MainFrame.java

public MainToolbarPanel getMainToolbarPanel() {
    if (mainToolbarPanel == null) {
        mainToolbarPanel = new MainToolbarPanel();

        mainToolbarPanel.addButton(getShowAllTabsButton());
        mainToolbarPanel.addButton(getHideAllTabsButton());
        mainToolbarPanel.addButton(getShowTabIconNamesButton());
        mainToolbarPanel.addSeparator();

        ButtonGroup layoutsButtonGroup = new ButtonGroup();
        mainToolbarPanel.addButton(getExpandSelectLayoutButton());
        layoutsButtonGroup.add(getExpandSelectLayoutButton());
        mainToolbarPanel.addButton(getExpandStatusLayoutButton());
        layoutsButtonGroup.add(getExpandStatusLayoutButton());
        mainToolbarPanel.addButton(getFullLayoutButton());
        layoutsButtonGroup.add(getFullLayoutButton());
        mainToolbarPanel.addSeparator();

        ButtonGroup responsePanelPositionsButtonGroup = new ButtonGroup();
        mainToolbarPanel.addButton(getTabsResponsePanelPositionButton());
        responsePanelPositionsButtonGroup.add(getTabsResponsePanelPositionButton());
        mainToolbarPanel.addButton(getPanelsResponsePanelPositionButton());
        responsePanelPositionsButtonGroup.add(getPanelsResponsePanelPositionButton());
        mainToolbarPanel.addButton(getAboveResponsePanelPositionButton());
        responsePanelPositionsButtonGroup.add(getAboveResponsePanelPositionButton());
        mainToolbarPanel.addSeparator();
    }/*from  w w  w. ja v a2 s .  co  m*/
    return mainToolbarPanel;
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.pdf.PdfExportDialog.java

/**
 * Creates the security config panel. This panel is used to select the level of the PDF security.
 *
 * @return the created security config panel.
 *///from   www  .  j  a  v  a 2s .  c om
private JPanel createSecurityConfigPanel() {
    final JPanel pnlSecurityConfig = new JPanel();
    pnlSecurityConfig.setLayout(new GridLayout());
    pnlSecurityConfig.add(rbSecurityNone);
    pnlSecurityConfig.add(rbSecurity40Bit);
    pnlSecurityConfig.add(rbSecurity128Bit);

    final ButtonGroup btGrpSecurity = new ButtonGroup();
    btGrpSecurity.add(rbSecurity128Bit);
    btGrpSecurity.add(rbSecurity40Bit);
    btGrpSecurity.add(rbSecurityNone);

    return pnlSecurityConfig;
}

From source file:org.pentaho.reporting.tools.configeditor.ConfigDescriptionEditor.java

/**
 * Creates the type selection panel containing some radio buttons to define the detail editor type.
 *
 * @return the type selection panel.//from www  .  j  a v a2 s  .c  om
 */
private JPanel createTypeSelectionPane() {
    final JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(3, 1));

    rbText = new JRadioButton(new SelectTypeAction(resources.getString("config-description-editor.type-text"),
            ConfigDescriptionEditor.TYPE_TEXT)); //$NON-NLS-1$
    rbClass = new JRadioButton(new SelectTypeAction(resources.getString("config-description-editor.type-class"),
            ConfigDescriptionEditor.TYPE_CLASS)); //$NON-NLS-1$
    rbEnum = new JRadioButton(new SelectTypeAction(resources.getString("config-description-editor.type-enum"),
            ConfigDescriptionEditor.TYPE_ENUM)); //$NON-NLS-1$

    final ButtonGroup bg = new ButtonGroup();
    bg.add(rbText);
    bg.add(rbClass);
    bg.add(rbEnum);

    panel.add(rbText);
    panel.add(rbClass);
    panel.add(rbEnum);

    return panel;
}

From source file:org.pentaho.ui.xul.swing.tags.SwingDialog.java

public ButtonGroup getButtonGroup(String group) {
    if (anonymousButtonGroups.containsKey(group)) {
        return anonymousButtonGroups.get(group);
    } else {// www. j  a v a  2s  . c o m
        ButtonGroup grp = new ButtonGroup();
        anonymousButtonGroups.put(group, grp);
        return grp;
    }
}

From source file:org.p_vcd.ui.VcdDialog.java

public VcdDialog() {
    setSize(700, 450);//from  w  w w .ja  va 2s .com
    setTitle("P-VCD - Video Copy Detection");
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.currentStep = 1;

    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new CardLayout(0, 0));
    {
        JPanel panel_Step1 = new JPanel();
        contentPanel.add(panel_Step1, "card_step1");
        panel_Step1.setLayout(new BorderLayout(0, 0));
        JLabel lblTitle = new JLabel("STEP 1 - Video Database (the \"known\")");
        panel_Step1.add(lblTitle, BorderLayout.NORTH);
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));

        JPanel panel_1 = new JPanel();
        panel_Step1.add(panel_1, BorderLayout.CENTER);
        panel_1.setLayout(new MigLayout("", "[250px,grow][20px][250px,grow]", "[][][230px,grow][][][]"));

        JLabel lblNewLabel = new JLabel("Please select the video databases to search in:");
        panel_1.add(lblNewLabel, "cell 0 0");

        panel_1.add(lbl_refDbTitle, "cell 2 1");

        JScrollPane scrollPane_1 = new JScrollPane();
        panel_1.add(scrollPane_1, "cell 0 1 1 3,grow");
        panel_refDatabasesList.setBackground(Color.WHITE);

        scrollPane_1.setViewportView(panel_refDatabasesList);
        panel_refDatabasesList.setLayout(new MigLayout("gapy 10", "[200px]", "[][]"));

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setBorder(null);
        panel_1.add(scrollPane, "cell 2 2,grow");

        scrollPane.setViewportView(lbl_refDbFiles);

        panel_1.add(lbl_refDbMetadata, "cell 2 3");

        JButton btnNewDatabase = new JButton("New database...");
        panel_1.add(btnNewDatabase, "cell 0 4");
        btnNewDatabase.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                newDatabaseButton();
            }
        });
    }
    {
        JPanel panel_Step2 = new JPanel();
        contentPanel.add(panel_Step2, "card_step2");
        panel_Step2.setLayout(new BorderLayout(0, 0));
        JLabel lblTitle = new JLabel("STEP 2 - Query (the \"unknown\")");
        panel_Step2.add(lblTitle, BorderLayout.NORTH);
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));

        JPanel panel = new JPanel();
        panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Query",
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel_Step2.add(panel, BorderLayout.CENTER);
        panel.setLayout(
                new MigLayout("", "[160px][grow]", "[25px][grow,top][25px][grow,top][25px][grow,top][grow]"));

        ButtonGroup queryButtonGroup = new ButtonGroup();

        queryButtonGroup.add(radio_queryFile);
        radio_queryFile.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryFile, "cell 0 0");

        lbl_queryFile.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                radio_queryFile.setSelected(true);
            }
        });
        panel.add(lbl_queryFile, "flowy,cell 1 0");

        JButton btnSelectFile = new JButton("Select File...");
        btnSelectFile.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                selectFileButton();
            }
        });
        panel.add(btnSelectFile, "cell 1 0");

        JLabel lblIumageOrVideo = new JLabel("Select an image or video in the local machine.");
        panel.add(lblIumageOrVideo, "cell 1 1");

        queryButtonGroup.add(radio_queryUrl);
        radio_queryUrl.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryUrl, "cell 0 2");

        txt_queryUrl.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.setText("http://");
        panel.add(txt_queryUrl, "flowy,cell 1 2");
        txt_queryUrl.setColumns(50);

        JLabel lblUrlToA = new JLabel(
                "<html>Enter the URL to download an image or video.<br>You can use a URL like: http://www.youtube.com/watch?v=... </html>");
        panel.add(lblUrlToA, "flowy,cell 1 3");

        queryButtonGroup.add(radio_queryDb);
        radio_queryDb.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryDb, "cell 0 4");

        comboBox_queryDb.setMaximumRowCount(12);
        comboBox_queryDb.setPreferredSize(new Dimension(100, 20));
        comboBox_queryDb.setMinimumSize(new Dimension(100, 20));
        comboBox_queryDb.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if (comboBox_queryDb.getSelectedIndex() > 0)
                    radio_queryDb.setSelected(true);
                updateQueryDbDetail();
            }
        });
        comboBox_queryDb.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                if (comboBox_queryDb.getSelectedIndex() > 0)
                    radio_queryDb.setSelected(true);
                updateQueryDbDetail();
            }
        });

        panel.add(comboBox_queryDb, "flowx,cell 1 4");

        panel.add(lbl_queryDb, "cell 1 4");

        JLabel lblPleaseNopteThe = new JLabel("<html>A search is run for each video in the database.</html>");
        panel.add(lblPleaseNopteThe, "cell 1 5");

    }
    {
        JPanel panel_Step3 = new JPanel();
        contentPanel.add(panel_Step3, "card_step3");
        panel_Step3.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 3 - Search Options");
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        panel_Step3.add(lblTitle, BorderLayout.NORTH);

        JPanel panel2 = new JPanel();
        panel2.setLayout(new FlowLayout());
        panel_Step3.add(panel2, BorderLayout.CENTER);
        JPanel panel = new JPanel();
        panel2.add(panel);
        panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Basic Options",
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel.setLayout(new MigLayout("gapy 5px", "[30px][101px]", "[][][][][][][20px]"));

        ButtonGroup buttonGroup = new ButtonGroup();

        buttonGroup.add(radio_searchByGlobal);
        radio_searchByGlobal.setFont(new Font("Tahoma", Font.PLAIN, 13));
        radio_searchByGlobal.setSelected(true);
        panel.add(radio_searchByGlobal, "cell 0 0 2 1,alignx left,aligny top");

        JLabel lblNewLabel_2 = new JLabel(
                "Detects most of the copies that are visually alike to the original.");
        panel.add(lblNewLabel_2, "cell 1 1");

        JButton btnOptions = new JButton("Advanced Options...");
        btnOptions.setEnabled(false);
        panel.add(btnOptions, "cell 1 2");

        buttonGroup.add(radio_searchByLocal);
        radio_searchByLocal.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_searchByLocal, "cell 0 4 2 1,alignx left,aligny top");

        JLabel lblNewLabel_3 = new JLabel(
                "Requires more resources (disk space, search time, memory) but can detect more copies.");
        panel.add(lblNewLabel_3, "cell 1 5");

        JButton btnOptions_1 = new JButton("Advanced Options...");
        btnOptions_1.setEnabled(false);
        panel.add(btnOptions_1, "cell 1 6");

    }
    {
        JPanel panel_Step4 = new JPanel();
        contentPanel.add(panel_Step4, "card_step4");
        panel_Step4.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 4 - Search");
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        panel_Step4.add(lblTitle, BorderLayout.NORTH);

        JScrollPane scrollPane = new JScrollPane();
        panel_Step4.add(scrollPane, BorderLayout.CENTER);

        textConsole.setFont(new Font("Monospaced", Font.PLAIN, 11));
        textConsole.setForeground(Color.WHITE);
        textConsole.setBackground(Color.BLACK);
        textConsole.setEditable(false);
        textConsole.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        textConsole.setText(
                "Press 'Next' button to start the search...\nNote: Depending on the selected options, the search may take up to several hours.");
        scrollPane.setViewportView(textConsole);

        JPanel panel = new JPanel();
        panel_Step4.add(panel, BorderLayout.SOUTH);
        panel.setLayout(new GridLayout(0, 1, 0, 0));

        JSeparator separator = new JSeparator();
        separator.setPreferredSize(new Dimension(0, 1));
        panel.add(separator);
        progressBar.setStringPainted(true);
        progressBar.setPreferredSize(new Dimension(350, 20));
        panel.add(progressBar);

        lblProgress.setHorizontalAlignment(SwingConstants.CENTER);
        lblProgress.setFont(new Font("Tahoma", Font.PLAIN, 14));
        panel.add(lblProgress);
    }
    {
        JPanel panel_Step5 = new JPanel();
        contentPanel.add(panel_Step5, "card_step5");
        panel_Step5.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 5 - Results");
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        panel_Step5.add(lblTitle, BorderLayout.NORTH);

        JScrollPane scrollPane = new JScrollPane();
        panel_Step5.add(scrollPane, BorderLayout.CENTER);

        scrollPane.setViewportView(panelResults);
        panelResults.setLayout(new MigLayout("gapy 10, gapx 20",
                "[120px,center][150px,center,grow][150px,center,grow]", "[25px][]"));

    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton prevButton = new JButton("Previous");
            prevButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    previousButton();
                }
            });
            prevButton.setActionCommand("Previous");
            buttonPane.add(prevButton);
        }
        {
            JButton okButton = new JButton("Next");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    nextButton();
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    cancelButton();
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            closeWindow();
        }
    });
    updateDatabases(null);
}

From source file:org.rdv.datapanel.DigitalTabularDataPanel.java

/**
 * Initialize the container and add the header.
 * /*from w  ww.  j  a  v  a 2 s . c o m*/
 * @since 1.2
 */
private void initComponents() {
    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    panelBox = Box.createHorizontalBox();

    dataCellRenderer = new DataTableCellRenderer();
    doubleCellRenderer = new DoubleTableCellRenderer();

    showMinMaxCheckBoxGroup = new CheckBoxGroup();
    showThresholdCheckBoxGroup = new CheckBoxGroup();

    addColumn();

    mainPanel.add(panelBox, BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BorderLayout());

    JPanel offsetsPanel = new JPanel();

    useOffsetsCheckBox = new JCheckBox("Use Offsets");
    useOffsetsCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            boolean checked = ((JCheckBox) ae.getSource()).isSelected();

            useOffsetRenderer(checked);
        }
    });
    offsetsPanel.add(useOffsetsCheckBox);

    JButton takeOffsetsButton = new JButton("Take Offsets");
    takeOffsetsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            useOffsetsCheckBox.setSelected(true); // this moved from above
            // repaint
            for (int i = 0; i < columnGroupCount; i++) {
                ((DataTableModel) tableModels.get(i)).takeOffsets();
                ((DataTableModel) tableModels.get(i)).useOffsets(true);
                ((JTable) tables.get(i)).repaint();
            } // for
        } // actionPerformed ()
    }); // actionlistener
    offsetsPanel.add(takeOffsetsButton);

    buttonPanel.add(offsetsPanel, BorderLayout.WEST);

    JPanel formatPanel = new JPanel();

    decimalButton = new JToggleButton("Decimal", true);
    decimalButton.setSelected(true);
    decimalButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            useEngineeringRenderer(false);
        }
    });
    formatPanel.add(decimalButton);

    engineeringButton = new JToggleButton("Engineering");
    engineeringButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            useEngineeringRenderer(true);
        }
    });
    formatPanel.add(engineeringButton);

    ButtonGroup formatButtonGroup = new ButtonGroup();
    formatButtonGroup.add(decimalButton);
    formatButtonGroup.add(engineeringButton);

    buttonPanel.add(formatPanel, BorderLayout.EAST);

    mainPanel.add(buttonPanel, BorderLayout.SOUTH);

    mainPanel.addMouseListener(new MouseInputAdapter() {
    });

}

From source file:org.rdv.DockingDataPanelManager.java

/**
 * Creates the menu where the theme can be changed.
 *
 * @return the theme menu//from w  w  w .ja v  a2  s. co  m
 */
private JMenu createThemesMenu() {
    JMenu themesMenu = new JMenu("Themes");

    // don't get the title bar window thing

    final JCheckBoxMenuItem titleBarStyleItem = new JCheckBoxMenuItem("Title Bar Style Theme");
    titleBarStyleItem.setSelected(titleBarTheme_);
    titleBarStyleItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (!titleBarTheme_)
                properties_.addSuperObject(titleBarStyleProperties);
            else {
                // TODO this does not work to remove title bars from windows 
                properties_.removeSuperObject(titleBarStyleProperties);
            }
            titleBarTheme_ = !titleBarTheme_;
        }
    });

    themesMenu.add(titleBarStyleItem);
    themesMenu.add(new JSeparator());

    DockingWindowsTheme[] themes = { new DefaultDockingTheme(), new LookAndFeelDockingTheme(),
            new BlueHighlightDockingTheme(), new SlimFlatDockingTheme(), new GradientDockingTheme(),
            new ShapedGradientDockingTheme(), new SoftBlueIceDockingTheme(), new ClassicDockingTheme() };

    ButtonGroup group = new ButtonGroup();

    for (int i = 0; i < themes.length; i++) {
        final DockingWindowsTheme theme = themes[i];

        JRadioButtonMenuItem item = new JRadioButtonMenuItem(theme.getName());
        item.setSelected(themes[i].getClass() == currentTheme_.getClass());

        group.add(item);

        themesMenu.add(item).addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // Clear the modified properties values
                properties_.getMap().clear(true);

                setTheme(theme);
            }
        });
    }
    return themesMenu;
}