Java Utililty Methods JButton Settings

List of utility methods to do JButton Settings

  1. HOME
  2. Java
  3. J
  4. JButton Settings

Description

The list of methods to do JButton Settings are organized into topic(s).

Method

void addAbstractButtonListeners(AbstractButton b, Object... objs)
add Abstract Button Listeners
if (b == null)
 return;
addJContainerListeners(b, objs);
ActionListener actionListener = search(objs, ActionListener.class);
ChangeListener changeListener = search(objs, ChangeListener.class);
ItemListener itemListener = search(objs, ItemListener.class);
if (actionListener != null)
 b.addActionListener(actionListener);
...
void addActionListener(ActionListener listener, AbstractButton... buttons)
add Action Listener
for (AbstractButton button : buttons) {
 button.addActionListener(listener);
void addActionListeners(AbstractButton button, ActionListener[] listeners)
add Action Listeners
for (ActionListener listener : listeners) {
 button.addActionListener(listener);
void addActionListenerToButtons(ActionListener l, AbstractButton... components)
This Method adds a Actionlistener to Several AbstractButtons
for (AbstractButton component : components) {
 component.addActionListener(l);
void addButton(ActionListener l, Container container, String name, String cmd)
Add a button to a container with the given parameters and action listener.
JButton button = new JButton(name);
button.addActionListener(l);
button.setActionCommand(cmd);
container.add(button);
JButton addButton(Container component, String text, Icon icon, ActionListener listener, String actionCommand)
Add a new button to a given component
return addButton(component, text, icon, listener, actionCommand, 0, null);
JButton addButton(String name, JPanel panel, ActionListener action)
Create a button.
final JButton button = new JButton(name);
if (action != null) {
 button.addActionListener(action);
panel.add(button);
return button;
JButton addButtonInPanel(Container component, String text, ActionListener listener)
Add a new button to a JPanel and then add the panel to a given component
return addButtonInPanel(component, text, listener, null);
JButton addButtonToPanel(JPanel panel, Object constraints, String text)
Adds a button to a panel.
JButton button = new JButton(text);
button.setBackground(BACKGROUND);
panel.add(button, constraints);
return button;
void addMiddleButtonDragSupport(Component targetComponent)
add Middle Button Drag Support
MouseInputAdapter mia = new MouseInputAdapter() {
 int m_XDifference, m_YDifference;
 boolean m_dragging = false;
 public void mouseDragged(MouseEvent e) {
 if (!m_dragging)
 return;
 Component target = e.getComponent();
 Container c = target.getParent();
...


AltStyle によって変換されたページ (->オリジナル) /