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.ut.biolab.medsavant.client.query.view.NumberSearchConditionEditorView.java

@Override
public void loadViewFromSearchConditionParameters(String encoding) throws ConditionRestorationException {

    double[] selectedValues;
    if (encoding == null) {
        selectedValues = null;/* w  ww .  j a  v a 2s. c  om*/
    } else {
        selectedValues = NumericConditionEncoder.unencodeConditions(encoding);
    }

    final double[] extremeValues = generator.getExtremeNumericValues();
    this.removeAll();

    if (extremeValues == null || (extremeValues[0] == 0 && extremeValues[1] == 0)) {
        JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
        p.add(Box.createHorizontalGlue());
        p.add(new JLabel("<html>All values are blank for this condition.</html>"));
        p.add(Box.createHorizontalGlue());
        this.add(p);
        return;
    }

    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    JPanel p = ViewUtil.getClearPanel();
    ViewUtil.applyVerticalBoxLayout(p);

    JPanel labelPanel = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(labelPanel);
    labelPanel.add(Box.createHorizontalGlue());
    labelPanel.add(new JLabel("Filtering variants where " + item.getName() + ": "));
    labelPanel.add(Box.createHorizontalGlue());
    ButtonGroup group = new ButtonGroup();
    //JRadioButton isButton = new JRadioButton("is within the following range:");
    //JRadioButton nullButton = new JRadioButton("is missing");
    //group.add(isButton);
    //group.add(nullButton);

    final JCheckBox nullButton = new JCheckBox("include missing values");

    JPanel bp = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(bp);
    p.add(labelPanel);
    p.add(bp);
    add(p);
    final DecimalRangeSlider slider = new DecimalRangeSlider();

    slider.setMajorTickSpacing(5);
    slider.setMinorTickSpacing(1);

    final JTextField fromBox = new JTextField();
    final JTextField toBox = new JTextField();

    nullButton.setSelected(NumericConditionEncoder.encodesNull(encoding));

    nullButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            encodeValue(ViewUtil.parseDoubleFromFormattedString(fromBox.getText()),
                    ViewUtil.parseDoubleFromFormattedString(toBox.getText()), extremeValues[0],
                    extremeValues[1], nullButton.isSelected());
        }
    });

    fromBox.setMaximumSize(new Dimension(10000, 24));
    toBox.setMaximumSize(new Dimension(10000, 24));
    fromBox.setPreferredSize(new Dimension(FROM_TO_WIDTH, 24));
    toBox.setPreferredSize(new Dimension(FROM_TO_WIDTH, 24));
    fromBox.setMinimumSize(new Dimension(FROM_TO_WIDTH, 24));
    toBox.setMinimumSize(new Dimension(FROM_TO_WIDTH, 24));
    fromBox.setHorizontalAlignment(JTextField.RIGHT);
    toBox.setHorizontalAlignment(JTextField.RIGHT);

    final JLabel fromLabel = new JLabel();
    final JLabel toLabel = new JLabel();

    ViewUtil.makeMini(fromLabel);
    ViewUtil.makeMini(toLabel);

    JPanel fromToContainer = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(fromToContainer);
    fromToContainer.add(Box.createHorizontalGlue());
    fromToContainer.add(fromBox);
    fromToContainer.add(new JLabel(" - "));
    fromToContainer.add(toBox);
    fromToContainer.add(Box.createHorizontalGlue());

    JPanel minMaxContainer = ViewUtil.getClearPanel();
    minMaxContainer.setLayout(new BoxLayout(minMaxContainer, BoxLayout.X_AXIS));

    JPanel sliderContainer = ViewUtil.getClearPanel();
    sliderContainer.setLayout(new BoxLayout(sliderContainer, BoxLayout.Y_AXIS));
    sliderContainer.add(slider);

    JPanel nullValueContainer = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(nullValueContainer);
    nullValueContainer.add(Box.createHorizontalGlue());
    nullValueContainer.add(nullButton);
    nullButton.setBackground(nullValueContainer.getBackground()); //fixes a windows issue.
    nullValueContainer.add(Box.createHorizontalGlue());

    JPanel labelContainer = ViewUtil.getClearPanel();
    labelContainer.setLayout(new BoxLayout(labelContainer, BoxLayout.X_AXIS));
    labelContainer.add(fromLabel);
    labelContainer.add(Box.createHorizontalGlue());
    labelContainer.add(toLabel);
    sliderContainer.add(labelContainer);
    minMaxContainer.add(Box.createHorizontalGlue());
    minMaxContainer.add(sliderContainer);
    minMaxContainer.add(Box.createHorizontalGlue());

    add(fromToContainer);
    add(minMaxContainer);
    add(nullValueContainer);
    add(Box.createVerticalBox());

    slider.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (slider.isEnabled()) {
                fromBox.setText(ViewUtil.numToString(slider.getLow()));
                toBox.setText(ViewUtil.numToString(slider.getHigh()));
                encodeValue(ViewUtil.parseDoubleFromFormattedString(fromBox.getText()),
                        ViewUtil.parseDoubleFromFormattedString(toBox.getText()), extremeValues[0],
                        extremeValues[1], nullButton.isSelected());
            }
        }
    });

    final KeyListener keyListener = new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            int key = e.getKeyCode();
            if (key == KeyEvent.VK_ENTER) {
                Range selectedRage = new Range(getNumber(fromBox.getText()), getNumber(toBox.getText()));
                setSelectedValues(slider, fromBox, toBox, selectedRage);
            }
        }

        private double getNumber(String s) {
            try {
                return Double.parseDouble(s.replaceAll(",", ""));
            } catch (NumberFormatException ignored) {
                return 0;
            }
        }
    };

    CaretListener caretListener = new CaretListener() {
        @Override
        public void caretUpdate(CaretEvent ce) {
            if (!isAdjustingSlider) {
                try {
                    encodeValue(ViewUtil.parseDoubleFromFormattedString(fromBox.getText()),
                            ViewUtil.parseDoubleFromFormattedString(toBox.getText()), extremeValues[0],
                            extremeValues[1], nullButton.isSelected());
                } catch (Exception e) {
                }
            }
        }
    };

    fromBox.addKeyListener(keyListener);

    toBox.addKeyListener(keyListener);

    fromBox.addCaretListener(caretListener);

    toBox.addCaretListener(caretListener);

    slider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            isAdjustingSlider = true;
            fromBox.setText(ViewUtil.numToString(slider.getLow()));
            toBox.setText(ViewUtil.numToString(slider.getHigh()));
            isAdjustingSlider = false;
        }
    });

    JPanel bottomContainer = new JPanel();

    bottomContainer.setLayout(new BoxLayout(bottomContainer, BoxLayout.X_AXIS));

    bottomContainer.add(Box.createHorizontalGlue());

    add(bottomContainer);

    setExtremeValues(slider, fromLabel, toLabel, fromBox, toBox, 0,
            new Range(extremeValues[0], extremeValues[1]));

    if (encoding != null) {
        double[] d = NumericConditionEncoder.unencodeConditions(encoding);
        setSelectedValues(slider, fromBox, toBox, new Range(d[0], d[1]));
    }
}

From source file:org.ut.biolab.medsavant.client.variant.ImportVariantsWizard.java

private AbstractWizardPage getVCFSourcePage() {
    return new DefaultWizardPage("Location of Files") {
        private JRadioButton onMyComputerButton = new JRadioButton("This computer");
        private JRadioButton onMedSavantServerButton = new JRadioButton("The MedSavant server");

        {//  w ww .ja  va2  s  . co m
            ButtonGroup g = new ButtonGroup();
            g.add(onMyComputerButton);
            g.add(onMedSavantServerButton);

            onMyComputerButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    setUploadRequired(onMyComputerButton.isSelected());
                }
            });

            onMedSavantServerButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    setUploadRequired(onMyComputerButton.isSelected());
                }
            });

            addText("The VCFs I want to import are on:");
            addComponent(onMyComputerButton);
            addComponent(onMedSavantServerButton);

            onMyComputerButton.setSelected(true);

        }

        @Override
        public void setupWizardButtons() {
            fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH);
            fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK);
            fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT);
        }
    };
}

From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.SearchSubInspector.java

@Override
public JPanel getInfoPanel() {

    bg = new ButtonGroup();

    JPanel buttonPanel = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(buttonPanel);

    googleButton = makeWhite("Google");
    googleButton.setSelected(true);//w w  w.j  a  v a  2s. c  o m
    googleButton.setOpaque(false);
    buttonPanel.add(googleButton);

    scholarButton = makeWhite("Scholar");
    scholarButton.setOpaque(false);
    buttonPanel.add(scholarButton);

    pmButton = makeWhite("PubMed");
    pmButton.setOpaque(false);
    buttonPanel.add(pmButton);

    field = new JTextField();
    field.setPreferredSize(new Dimension(200, 22));
    field.setMaximumSize(new Dimension(200, 22));

    JPanel searchContainer = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(searchContainer);

    JButton searchButton = new JButton("Search");
    searchButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            performSearchAction();
        }

    });

    searchContainer.add(field);
    searchContainer.add(searchButton);

    JPanel p = new JPanel();//ViewUtil.getClearPanel();

    p.setBorder(ViewUtil.getMediumBorder());
    ViewUtil.applyVerticalBoxLayout(p);

    p.add(buttonPanel);
    p.add(ViewUtil.centerHorizontally(searchContainer));

    return p;
}

From source file:org.ut.biolab.medsavant.client.view.manage.ServerLogPage.java

@Override
public JPanel getView() {
    if (view == null) {
        view = new JPanel();
        view.setLayout(new BorderLayout());

        menuPanel = new JPanel();
        ViewUtil.applyHorizontalBoxLayout(menuPanel);

        ButtonGroup bg = new ButtonGroup();

        JRadioButton b1 = new JRadioButton("Client");
        //JRadioButton b2 = new JRadioButton("Server");
        JRadioButton b3 = new JRadioButton("Annotations");

        bg.add(b1);/*w w  w  .ja v  a 2  s  .c om*/
        //bg.add(b2);
        bg.add(b3);

        listPanel = new JPanel();
        listPanel.setLayout(new CardLayout());

        listPanel.add(getWaitPanel(), CARDNAME_WAIT);
        listPanel.add(getClientCard(), CARDNAME_CLIENT);
        //listPanel.add(getServerCard(), CARDNAME_SERVER);
        listPanel.add(getAnnotationCard(), CARDNAME_ANNOTATION);

        view.add(menuPanel, BorderLayout.NORTH);
        view.add(listPanel, BorderLayout.CENTER);

        b1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                changeToCard(CARDNAME_CLIENT);

            }
        });
        /*b2.addActionListener(new ActionListener() {
                
        public void actionPerformed(ActionEvent ae) {
            changeToCard(CARDNAME_SERVER);
        }
        });*/
        b3.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                changeToCard(CARDNAME_ANNOTATION);
            }
        });

        b3.setSelected(true);
        this.changeToCard(CARDNAME_ANNOTATION);

        JButton refreshButton = new JButton("Refresh");
        refreshButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                refreshCurrentCard();
            }
        });

        menuPanel.add(Box.createHorizontalGlue());
        menuPanel.add(b3);
        menuPanel.add(b1);
        //menuPanel.add(b2);
        menuPanel.add(refreshButton);
        menuPanel.add(Box.createHorizontalGlue());
    }
    return view;
}

From source file:org.ut.biolab.medsavant.client.view.Menu.java

public Menu(JPanel panel) {

    resetMap();/*from  www.ja  va  2  s.c  o m*/

    setLayout(new BorderLayout());

    primaryMenuButtons = new ButtonGroup();

    primaryMenu = ViewUtil.getPrimaryBannerPanel();

    secondaryMenu = new JPanel();
    secondaryMenu.setBackground(ViewUtil.getSecondaryMenuColor());

    tertiaryMenu = new JPanel();
    tertiaryMenu.setBorder(ViewUtil.getBottomLineBorder());
    tertiaryMenu.setBackground(Color.white);
    // tertiaryMenu.setBorder(ViewUtil.getMediumBorder());
    ViewUtil.applyHorizontalBoxLayout(tertiaryMenu);
    //tertiaryMenu.setMinimumSize(new Dimension(9999, 30));
    ViewUtil.applyHorizontalBoxLayout(tertiaryMenu);

    int padding = 5;

    primaryMenu.setLayout(new BoxLayout(primaryMenu, BoxLayout.X_AXIS));
    primaryMenu.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(150, 150, 150)),
            BorderFactory.createEmptyBorder(padding, padding, padding, padding)));

    primaryMenuSectionButtonContainer = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(primaryMenuSectionButtonContainer);

    NotificationsPanel n = NotificationsPanel.getNotifyPanel(NotificationsPanel.JOBS_PANEL_NAME);

    JPanel appStorePanel = ViewUtil.getClearPanel();
    JButton appStoreButton = ViewUtil
            .getIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.MENU_STORE));
    ViewUtil.applyHorizontalBoxLayout(appStorePanel);
    appStorePanel.add(ViewUtil.subTextComponent(appStoreButton, "App Store"));

    appStoreButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            MedSavantFrame.getInstance().showAppStore();
        }

    });

    int componentpadding = 10;
    primaryMenu.add(Box.createHorizontalStrut(componentpadding));
    primaryMenu.add(primaryMenuSectionButtonContainer);
    primaryMenu.add(Box.createHorizontalGlue());

    FlowLayout fl = new FlowLayout(FlowLayout.RIGHT, componentpadding, 1);
    JPanel rightSidePanel = ViewUtil.getClearPanel();
    rightSidePanel.setLayout(fl);
    rightSidePanel.add(updatesPanel);
    rightSidePanel.add(n);
    rightSidePanel.add(appStorePanel);
    rightSidePanel.add(getLoginMenuItem());
    primaryMenu.add(rightSidePanel);
    /*
    primaryMenu.add(updatesPanel);
    primaryMenu.add(ViewUtil.getMediumSeparator());
            
    primaryMenu.add(n);
    primaryMenu.add(ViewUtil.getMediumSeparator());
            
    primaryMenu.add(appStorePanel);
    primaryMenu.add(ViewUtil.getMediumSeparator());
    primaryMenu.add(getLoginMenuItem());
    */
    add(primaryMenu, BorderLayout.NORTH);

    secondaryMenu.setLayout(new BoxLayout(secondaryMenu, BoxLayout.Y_AXIS));
    //secondaryMenu.setBorder(ViewUtil.getRightLineBorder());

    secondaryMenu.setPreferredSize(new Dimension(150, 100));

    contentContainer = panel;

    ReferenceController.getInstance().addListener(new Listener<ReferenceEvent>() {
        @Override
        public void handleEvent(ReferenceEvent event) {
            if (event.getType() == ReferenceEvent.Type.CHANGED) {
                updateSections();
            }
        }
    });

    ProjectController.getInstance().addListener(new Listener<ProjectEvent>() {
        @Override
        public void handleEvent(ProjectEvent evt) {
            if (!GeneticsSection.isInitialized && evt.getType() == ProjectEvent.Type.CHANGED) {
                //once this section is initialized, referencecombobox fires
                //referencechanged event on every project change
                updateSections();
            }
        }
    });

    LoginController.getInstance().addListener(new Listener<LoginEvent>() {
        @Override
        public void handleEvent(LoginEvent evt) {
            if (evt.getType() == LoginEvent.Type.LOGGED_OUT) {
                contentContainer.removeAll();
                ViewController.getInstance().changeSubSectionTo(null);
                currentView = null;
                resetMap();
            }
        }
    });

    tertiaryMenuPanelVisibilityContainer = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(tertiaryMenuPanelVisibilityContainer);

    tertiaryMenuPanelAccessoryContainer = ViewUtil.getClearPanel();
    ViewUtil.applyHorizontalBoxLayout(tertiaryMenuPanelAccessoryContainer);

    clearMenu();
}

From source file:org.ut.biolab.medsavant.client.view.Menu.java

public void addSection(SectionView section) {

    final JPanel sectionPanel = ViewUtil.getClearPanel();
    sectionPanel.setLayout(new BoxLayout(sectionPanel, BoxLayout.Y_AXIS));
    sectionPanel.setVisible(false);//from w w w  .  j  a  v a2  s. c o m

    //HoverButton sectionButton = new SectionButton(section, sectionPanel);
    //sectionButton.setSelectedColor(ViewUtil.getSecondaryMenuColor());

    final JToggleButton sectionButton = ViewUtil.getTogglableIconButton(section.getIcon());
    sectionButton.setName(section.getName());
    sectionButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    sectionButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            primaryMenuButtons.setSelected(sectionButton.getModel(), true);
            if (previousSectionPanel != null) {
                previousSectionPanel.setVisible(false);
            }
            // Act as if we clicked the first sub-section button.
            ((SubSectionButton) sectionPanel.getComponent(0)).subSectionClicked();
            sectionPanel.setVisible(true);

            previousSectionPanel = sectionPanel;
            primaryMenu.invalidate();
        }
    });

    ButtonGroup subSectionsGroup = new ButtonGroup();

    for (SubSectionView v : section.getSubSections()) {
        subSectionViews.add(v);

        SubSectionButton subSectionButton = new SubSectionButton(v, subSectionsGroup);
        sectionPanel.add(subSectionButton);
        subSectionsGroup.add(subSectionButton);

        map.put(v, subSectionButton);
    }

    primaryMenuButtons.add(sectionButton);

    sectionPanel.add(Box.createVerticalStrut(50));

    secondaryMenu.add(sectionPanel);

    primaryMenuSectionButtonContainer.add(ViewUtil.subTextComponent(sectionButton, section.getName()));
    primaryMenuSectionButtonContainer.add(ViewUtil.getLargeSeparator());

}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

/** Creates new instance. */
public IndicatorPanel() {
    ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels");
    initComponents();/*  w  ww  .  j  av a  2  s . c  o  m*/
    this.jPanel7.add(Utils.getBusyJXLayer((AutoCompleteJComboBox) this.jComboBox1));

    editor = new DefaultDrawingEditor();
    editor.add(view);

    addCreationButtonsTo(creationToolbar, editor);

    JPopupButton pb = new JPopupButton();
    pb.setItemFont(UIManager.getFont("MenuItem.font"));
    labels.configureToolBarButton(pb, "actions");
    pb.add(new GroupAction(editor));
    pb.add(new UngroupAction(editor));
    pb.addSeparator();
    pb.add(new BringToFrontAction(editor));
    pb.add(new SendToBackAction(editor));
    pb.addSeparator();
    pb.add(new SelectAllAction());
    pb.add(new SelectSameAction(editor));
    pb.addSeparator();
    pb.add(new ToggleGridAction(editor));

    JMenu m = new JMenu(labels.getString("zoom"));
    JRadioButtonMenuItem rbmi;
    ButtonGroup group = new ButtonGroup();
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.1, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.25, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.5, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.75, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.0, null)));
    rbmi.setSelected(true);
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.25, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.5, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 2, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 3, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 4, null)));
    group.add(rbmi);
    pb.add(m);
    pb.setFocusable(false);
    creationToolbar.addSeparator();
    creationToolbar.add(pb);

    view.setDrawing(createDrawing());

    stockTask = null;

    initIndicatorProjectManager();
    initModuleProjectManager();
    // Must be done after project managers had been initialized.
    initListCellRenderer();
    createToolTipTextForJTabbedPane();
}

From source file:org.yccheok.jstock.gui.JStock.java

private void initRecentCountryMenuItems() {
    Enumeration<AbstractButton> e = buttonGroup4.getElements();
    boolean hasSeperator = false;
    while (e.hasMoreElements()) {
        jMenu6.remove(e.nextElement());/*from  w  w  w  .  java  2  s .  co  m*/
        hasSeperator = true;
    }
    if (hasSeperator) {
        // Seperator.
        jMenu6.remove(0);
    }

    buttonGroup4 = new ButtonGroup();

    int index = 0;
    for (final Country country : jStockOptions.getRecentCountries()) {
        final JMenuItem mi = (JRadioButtonMenuItem) jMenu6
                .add(new JRadioButtonMenuItem(country.humanString, country.icon), index++);

        buttonGroup4.add(mi);
        mi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JStock.this.changeCountry(country);
            }
        });

        if (jStockOptions.getCountry() == country) {
            ((JRadioButtonMenuItem) mi).setSelected(true);
        }
    }

    jMenu6.add(new javax.swing.JPopupMenu.Separator(), index++);
}

From source file:org.zaproxy.zap.view.MainToolbarPanel.java

public void initialise() {
    setLayout(new java.awt.GridBagLayout());
    setPreferredSize(DisplayUtils.getScaledDimension(getMaximumSize().width, 25));
    setMaximumSize(DisplayUtils.getScaledDimension(getMaximumSize().width, 25));
    this.setBorder(BorderFactory.createEtchedBorder());

    expandButtons = new ButtonGroup();

    GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
    GridBagConstraints gridBagConstraints2 = new GridBagConstraints();

    gridBagConstraints1.gridx = 0;//from   w  w w  .java  2 s . c  o  m
    gridBagConstraints1.gridy = 0;
    gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;

    gridBagConstraints2.gridx = 1;
    gridBagConstraints2.gridy = 0;
    gridBagConstraints2.weightx = 1.0;
    gridBagConstraints2.weighty = 1.0;
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;

    JToolBar t1 = new JToolBar();
    t1.setEnabled(true);
    t1.setPreferredSize(new java.awt.Dimension(80000, 25));
    t1.setMaximumSize(new java.awt.Dimension(80000, 25));

    add(getToolbar(), gridBagConstraints1);
    add(t1, gridBagConstraints2);

    toolbar.add(getModeSelect());
    toolbar.add(getBtnNew());
    toolbar.add(getBtnOpen());
    toolbar.add(getBtnSave());
    toolbar.add(getBtnSnapshot());
    toolbar.add(getBtnSession());
    toolbar.add(getBtnOptions());

    toolbar.addSeparator();
    toolbar.add(getShowAllTabs());
    toolbar.add(getHideAllTabs());
    toolbar.add(getShowTabIconNames());
    toolbar.addSeparator();

    toolbar.add(getBtnExpandSites());
    toolbar.add(getBtnExpandReports());
    toolbar.add(getBtnExpandFull());

    toolbar.addSeparator();
}

From source file:org.zaproxy.zap.view.MessagePanelsPositionController.java

public MessagePanelsPositionController(HttpPanelRequest requestPanel, HttpPanelResponse responsePanel,
        MainFrame mainFrame, WorkbenchPanel workbenchPanel) {
    this.requestPanel = requestPanel;
    this.responsePanel = responsePanel;
    this.workbenchPanel = workbenchPanel;
    this.tabbedWork = workbenchPanel.getTabbedWork();
    this.currentPosition = MessagePanelsPosition.TABS_SIDE_BY_SIDE;

    tabsButtonView = new JToggleButton(new ChangeMessagePanelsPositionAction(
            MessagePanelsPositionController.class.getResource("/resource/icon/layout_tabbed.png"),
            MessagePanelsPosition.TABS_SIDE_BY_SIDE));
    tabsButtonView.setToolTipText(TABS_VIEW_TOOL_TIP);

    aboveButtonView = new JToggleButton(new ChangeMessagePanelsPositionAction(
            MessagePanelsPositionController.class.getResource("/resource/icon/layout_vertical_split.png"),
            MessagePanelsPosition.PANEL_ABOVE));
    aboveButtonView.setToolTipText(ABOVE_VIEW_TOOL_TIP);

    sideBySideButtonView = new JToggleButton(new ChangeMessagePanelsPositionAction(
            MessagePanelsPositionController.class.getResource("/resource/icon/layout_horizontal_split.png"),
            MessagePanelsPosition.PANELS_SIDE_BY_SIDE));
    sideBySideButtonView.setToolTipText(SIDE_BY_SIDE_VIEW_TOOL_TIP);

    ButtonGroup messageTabsPositionButtonGroup = new ButtonGroup();
    messageTabsPositionButtonGroup.add(tabsButtonView);
    messageTabsPositionButtonGroup.add(aboveButtonView);
    messageTabsPositionButtonGroup.add(sideBySideButtonView);

    tabsButtonView.setSelected(true);/*  w ww  .java2  s . c om*/

    MainToolbarPanel toolbar = mainFrame.getMainToolbarPanel();

    toolbar.addButton(tabsButtonView);
    toolbar.addButton(aboveButtonView);
    toolbar.addButton(sideBySideButtonView);

    toolbar.addSeparator();

    splitTabbedPanel = new TabbedPanel();
    splitTabbedPanel.setAlternativeParent(mainFrame.getPaneDisplay());
    splitTabbedPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}