Search in sources :

Example 26 with ButtonGroup

use of javax.swing.ButtonGroup in project jabref by JabRef.

the class ACMPortalFetcher method getOptionsPanel.

@Override
public JPanel getOptionsPanel() {
    JPanel pan = new JPanel();
    pan.setLayout(new GridLayout(0, 1));
    guideButton.setSelected(true);
    ButtonGroup group = new ButtonGroup();
    group.add(acmButton);
    group.add(guideButton);
    pan.add(absCheckBox);
    pan.add(acmButton);
    pan.add(guideButton);
    return pan;
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) ButtonGroup(javax.swing.ButtonGroup)

Example 27 with ButtonGroup

use of javax.swing.ButtonGroup in project jabref by JabRef.

the class MergeEntries method setupFieldRows.

private int setupFieldRows(JPanel mergePanel) {
    // For all fields in joint add a row and possibly radio buttons
    int row = 2;
    int maxLabelWidth = -1;
    for (String field : allFields) {
        JLabel label = boldFontLabel(new SentenceCaseFormatter().format(field));
        mergePanel.add(label, CELL_CONSTRAINTS.xy(1, (2 * row) - 1, "left, top"));
        Optional<String> leftString = leftEntry.getField(field);
        Optional<String> rightString = rightEntry.getField(field);
        if (leftString.equals(rightString)) {
            identicalFields.add(field);
        } else {
            differentFields.add(field);
        }
        maxLabelWidth = Math.max(maxLabelWidth, label.getPreferredSize().width);
        // Left text pane
        if (leftString.isPresent()) {
            JTextPane tf = new DiffHighlightingTextPane();
            mergePanel.add(tf, CELL_CONSTRAINTS.xy(3, (2 * row) - 1, "f, f"));
            leftTextPanes.put(field, tf);
        }
        // Add radio buttons if the two entries do not have identical fields
        if (identicalFields.contains(field)) {
            // Will only happen if both entries have the field and the content is identical
            mergedEntry.setField(field, leftString.get());
        } else {
            ButtonGroup group = new ButtonGroup();
            List<JRadioButton> list = new ArrayList<>(3);
            for (int k = 0; k < 3; k++) {
                JRadioButton button = new JRadioButton();
                group.add(button);
                mergePanel.add(button, CELL_CONSTRAINTS.xy(5 + (k * 2), (2 * row) - 1));
                button.addChangeListener(e -> updateAll());
                list.add(button);
            }
            radioButtons.put(field, list);
            if (leftString.isPresent()) {
                list.get(0).setSelected(true);
                if (!rightString.isPresent()) {
                    list.get(2).setEnabled(false);
                }
            } else {
                list.get(0).setEnabled(false);
                list.get(2).setSelected(true);
            }
        }
        // Right text pane
        if (rightString.isPresent()) {
            JTextPane tf = new DiffHighlightingTextPane();
            mergePanel.add(tf, CELL_CONSTRAINTS.xy(11, (2 * row) - 1, "f, f"));
            rightTextPanes.put(field, tf);
        }
        row++;
    }
    return maxLabelWidth;
}
Also used : JTextPane(javax.swing.JTextPane) JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) DiffHighlightingTextPane(org.jabref.gui.util.component.DiffHighlightingTextPane) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) SentenceCaseFormatter(org.jabref.logic.formatter.casechanger.SentenceCaseFormatter)

Example 28 with ButtonGroup

use of javax.swing.ButtonGroup in project JMRI by JMRI.

the class PositionablePopupUtil method makeColorMenu.

protected ButtonGroup makeColorMenu(JMenu colorMenu, int type) {
    ButtonGroup buttonGrp = new ButtonGroup();
    addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("Black"), Color.black, type);
    addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("DarkGray"), Color.darkGray, type);
    addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("Gray"), Color.gray, type);
    addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("LightGray"), Color.lightGray, type);
    addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("White"), Color.white, type);
    addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("Red"), Color.red, type);
    addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("Orange"), Color.orange, type);
    addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("Yellow"), Color.yellow, type);
    addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("Green"), Color.green, type);
    addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("Blue"), Color.blue, type);
    addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("Magenta"), Color.magenta, type);
    if (type == BACKGROUND_COLOR) {
        addColorMenuEntry(colorMenu, buttonGrp, Bundle.getMessage("ColorClear"), null, type);
    }
    return buttonGrp;
}
Also used : ButtonGroup(javax.swing.ButtonGroup)

Example 29 with ButtonGroup

use of javax.swing.ButtonGroup in project JMRI by JMRI.

the class ControlPanelEditor method makeOptionMenu.

protected void makeOptionMenu() {
    _optionMenu = new JMenu(Bundle.getMessage("MenuOptions"));
    _menuBar.add(_optionMenu, 0);
    // use globals item
    _optionMenu.add(useGlobalFlagBox);
    useGlobalFlagBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            setUseGlobalFlag(useGlobalFlagBox.isSelected());
        }
    });
    useGlobalFlagBox.setSelected(useGlobalFlag());
    // positionable item
    _optionMenu.add(positionableBox);
    positionableBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            setAllPositionable(positionableBox.isSelected());
        }
    });
    positionableBox.setSelected(allPositionable());
    // controlable item
    _optionMenu.add(controllingBox);
    controllingBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            setAllControlling(controllingBox.isSelected());
        }
    });
    controllingBox.setSelected(allControlling());
    // hidden item
    _optionMenu.add(hiddenBox);
    hiddenBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            setShowHidden(hiddenBox.isSelected());
        }
    });
    hiddenBox.setSelected(showHidden());
    _optionMenu.add(showTooltipBox);
    showTooltipBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setAllShowTooltip(showTooltipBox.isSelected());
        }
    });
    showTooltipBox.setSelected(showTooltip());
    // Show/Hide Scroll Bars
    JMenu scrollMenu = new JMenu(Bundle.getMessage("ComboBoxScrollable"));
    _optionMenu.add(scrollMenu);
    ButtonGroup scrollGroup = new ButtonGroup();
    scrollGroup.add(scrollBoth);
    scrollMenu.add(scrollBoth);
    scrollBoth.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            setScroll(SCROLL_BOTH);
        }
    });
    scrollGroup.add(scrollNone);
    scrollMenu.add(scrollNone);
    scrollNone.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            setScroll(SCROLL_NONE);
        }
    });
    scrollGroup.add(scrollHorizontal);
    scrollMenu.add(scrollHorizontal);
    scrollHorizontal.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            setScroll(SCROLL_HORIZONTAL);
        }
    });
    scrollGroup.add(scrollVertical);
    scrollMenu.add(scrollVertical);
    scrollVertical.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            setScroll(SCROLL_VERTICAL);
        }
    });
}
Also used : ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) JMenu(javax.swing.JMenu)

Example 30 with ButtonGroup

use of javax.swing.ButtonGroup in project JMRI by JMRI.

the class ControlPanelEditor method makeSelectLevelMenu.

private JMenu makeSelectLevelMenu() {
    JMenu menu = new JMenu(Bundle.getMessage("SelectLevel"));
    ButtonGroup levelGroup = new ButtonGroup();
    JRadioButtonMenuItem button = null;
    for (int i = 0; i < 11; i++) {
        button = new JRadioButtonMenuItem(Bundle.getMessage("selectLevel", "" + i));
        levelGroup.add(button);
        menu.add(button);
        button.addActionListener(new ActionListener() {

            int j;

            ActionListener init(int k) {
                j = k;
                return this;
            }

            @Override
            public void actionPerformed(ActionEvent event) {
                selectLevel(j);
            }
        }.init(i));
    }
    return menu;
}
Also used : ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JMenu(javax.swing.JMenu) Point(java.awt.Point)

Aggregations

ButtonGroup (javax.swing.ButtonGroup)339 JPanel (javax.swing.JPanel)202 JRadioButton (javax.swing.JRadioButton)186 JLabel (javax.swing.JLabel)148 ActionEvent (java.awt.event.ActionEvent)134 ActionListener (java.awt.event.ActionListener)118 BoxLayout (javax.swing.BoxLayout)83 GridBagLayout (java.awt.GridBagLayout)81 JButton (javax.swing.JButton)75 JTextField (javax.swing.JTextField)70 JMenu (javax.swing.JMenu)69 GridBagConstraints (java.awt.GridBagConstraints)67 BorderLayout (java.awt.BorderLayout)64 Insets (java.awt.Insets)64 Dimension (java.awt.Dimension)58 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)57 FlowLayout (java.awt.FlowLayout)53 JMenuItem (javax.swing.JMenuItem)50 JCheckBox (javax.swing.JCheckBox)47 JScrollPane (javax.swing.JScrollPane)47