Search in sources :

Example 6 with AbstractButton

use of javax.swing.AbstractButton in project jmeter by apache.

the class JLabeledRadioI18N method resetButtons.

/**
     * Method is responsible for removing current JRadioButtons of ButtonGroup and
     * add creating the JRadioButtons and adding them to
     * the ButtonGroup.
     *
     * The resource name is used as the action command for the button model,
     * and the resource value is used to set the button label.
     *
     * @param resouces list of resource names
     * @param selected initially selected resource (if not null)
     *
     */
public void resetButtons(String[] resouces, String selected) {
    Enumeration<AbstractButton> buttons = bGroup.getElements();
    List<AbstractButton> buttonsToRemove = new ArrayList<>(this.bGroup.getButtonCount());
    while (buttons.hasMoreElements()) {
        AbstractButton abstractButton = buttons.nextElement();
        buttonsToRemove.add(abstractButton);
    }
    for (AbstractButton abstractButton : buttonsToRemove) {
        abstractButton.removeActionListener(this);
        bGroup.remove(abstractButton);
    }
    for (AbstractButton abstractButton : buttonsToRemove) {
        this.remove(abstractButton);
    }
    initButtonGroup(resouces, selected);
}
Also used : AbstractButton(javax.swing.AbstractButton) ArrayList(java.util.ArrayList)

Example 7 with AbstractButton

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

the class TrainsScheduleTableFrame method getSelectedScheduleId.

private String getSelectedScheduleId() {
    AbstractButton b;
    Enumeration<AbstractButton> en = schGroup.getElements();
    while (en.hasMoreElements()) {
        b = en.nextElement();
        if (b.isSelected()) {
            log.debug("schedule radio button " + b.getText());
            return b.getName();
        }
    }
    return null;
}
Also used : AbstractButton(javax.swing.AbstractButton)

Example 8 with AbstractButton

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

the class FamilyItemPanel method setFamily.

/**
     * Action of family radio button MultisensorItemPanel {@literal &}
     * IndicatorTOItem must overrides
     */
protected void setFamily(String family) {
    _family = family;
    if (log.isDebugEnabled()) {
        log.debug("setFamily: for type \"" + _itemType + "\", family \"" + family + "\"");
    }
    _iconFamilyPanel.remove(_iconPanel);
    _iconPanel = new JPanel(new FlowLayout());
    _iconFamilyPanel.add(_iconPanel, 0);
    HashMap<String, NamedIcon> map = ItemPalette.getIconMap(_itemType, _family);
    if (map != null) {
        _currentIconMap = map;
    }
    if (!_supressDragging) {
        _iconFamilyPanel.remove(_dragIconPanel);
        _dragIconPanel = new JPanel(new FlowLayout());
        _iconFamilyPanel.add(_dragIconPanel, 0);
        makeDndIconPanel(_currentIconMap, "BeanStateUnknown");
    }
    addIconsToPanel(_currentIconMap);
    _iconFamilyPanel.invalidate();
    hideIcons();
    Enumeration<AbstractButton> en = _familyButtonGroup.getElements();
    while (en.hasMoreElements()) {
        JRadioButton but = (JRadioButton) en.nextElement();
        if (_family != null && _family.equals(but.getText())) {
            but.setSelected(true);
            break;
        }
    }
}
Also used : JPanel(javax.swing.JPanel) NamedIcon(jmri.jmrit.catalog.NamedIcon) FlowLayout(java.awt.FlowLayout) AbstractButton(javax.swing.AbstractButton) JRadioButton(javax.swing.JRadioButton)

Example 9 with AbstractButton

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

the class WarrantRoute method makeTextBoxPanel.

/**
     * Puts label message to the Right
     *
     * @param comp    Component to put into JPanel
     * @param label   Bundle keyword for label message
     * @param tooltip Bundle keyword for tooltip message
     * @return Panel containing Component
     */
protected static JPanel makeTextBoxPanel(JComponent comp, String label, String tooltip) {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
    panel.add(Box.createHorizontalStrut(STRUT_SIZE));
    comp.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    comp.setMaximumSize(new Dimension(300, comp.getPreferredSize().height));
    comp.setMinimumSize(new Dimension(30, comp.getPreferredSize().height));
    panel.add(comp);
    if (comp instanceof JTextField || comp instanceof JComboBox) {
        comp.setBackground(Color.white);
        JLabel l = new JLabel(Bundle.getMessage(label));
        l.setAlignmentX(JComponent.LEFT_ALIGNMENT);
        l.setToolTipText(Bundle.getMessage(tooltip));
        panel.add(l);
    } else if (comp instanceof AbstractButton) {
        ((AbstractButton) comp).setText(Bundle.getMessage(label));
    }
    panel.add(Box.createHorizontalStrut(STRUT_SIZE));
    if (tooltip != null) {
        panel.setToolTipText(tooltip);
        comp.setToolTipText(Bundle.getMessage(tooltip));
    }
    panel.setMaximumSize(new Dimension(350, comp.getPreferredSize().height));
    panel.setMinimumSize(new Dimension(80, comp.getPreferredSize().height));
    return panel;
}
Also used : JPanel(javax.swing.JPanel) AbstractButton(javax.swing.AbstractButton) JComboBox(javax.swing.JComboBox) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField)

Example 10 with AbstractButton

use of javax.swing.AbstractButton in project scylla by bptlab.

the class ScalingCheckBoxIcon method paintIcon.

/**
 * Overriden paint method
 */
@Override
public void paintIcon(Component checkBox, Graphics g, int x, int y) {
    int xoff = (size) / 8;
    int yoff = (checkBox.getHeight() - size) / 2;
    int border = size / 8;
    ButtonModel checkBoxModel = ((AbstractButton) checkBox).getModel();
    g.setColor(ScyllaGUI.ColorField2);
    g.fillRect(xoff, yoff, size, size);
    g.setColor(ScyllaGUI.ColorBackground);
    if (!checkBoxModel.isRollover())
        g.drawRect(xoff, yoff, size, size);
    if (checkBoxModel.isPressed()) {
        g.setColor(ScyllaGUI.ColorField1);
        g.fillRect(border + xoff, border + yoff, size - 2 * border + 1, size - 2 * border + 1);
    } else if (checkBoxModel.isSelected()) {
        g.setColor(ScyllaGUI.ColorBackground);
        g.fillRect(border + xoff, border + yoff, size - 2 * border + 1, size - 2 * border + 1);
    }
}
Also used : AbstractButton(javax.swing.AbstractButton) ButtonModel(javax.swing.ButtonModel)

Aggregations

AbstractButton (javax.swing.AbstractButton)50 JLabel (javax.swing.JLabel)8 JPanel (javax.swing.JPanel)8 Component (java.awt.Component)7 ButtonModel (javax.swing.ButtonModel)7 JRadioButton (javax.swing.JRadioButton)5 JButton (javax.swing.JButton)4 Dimension (java.awt.Dimension)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 NotConfigurableException (org.knime.core.node.NotConfigurableException)3 FlowLayout (java.awt.FlowLayout)2 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 ActionEvent (java.awt.event.ActionEvent)2 MouseEvent (java.awt.event.MouseEvent)2 JComboBox (javax.swing.JComboBox)2 JComponent (javax.swing.JComponent)2 JFileChooser (javax.swing.JFileChooser)2 JTextField (javax.swing.JTextField)2