/* * Created on 24-Jan-2005 by Ryan McNally */ package com.ryanm.config.swing.imp; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import com.ryanm.config.Configurator; import com.ryanm.config.swing.Widget; /** * A widget for triggering an Action variable * * @author ryanm */ public class ActionWidget extends Widget implements ActionListener { private JButton button; /** * Constructs a widget for initiating an action * * @param conf * The {@link Configurator} that contains the action * @param name * The name of the action */ public ActionWidget( Configurator conf, String name ) { super( conf, name ); button = new JButton( name ); button.addActionListener( this ); setLayout( new BorderLayout() ); add( button, BorderLayout.CENTER ); setEnabled( conf.isGUIEnabled( name ) ); } /** * * */ public ActionWidget() { } public void actionPerformed( final ActionEvent e ) { applyChange( conf, name, e ); } @Override public boolean isEnabled() { return button.isEnabled(); } @Override public void setEnabled( boolean b ) { button.setEnabled( b ); } @Override public void updateValue() { // nothing to do here } @Override public void updateRange( Object range ) { } @Override public Widget newWidget( Configurator conf, String name, Class runtimeType ) { return new ActionWidget( conf, name ); } @Override public Class getType() { return void.class; } }