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);
}
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;
}
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;
}
}
}
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;
}
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);
}
}
Aggregations