-
Enhancement
-
Resolution: Fixed
-
P4
-
1.2.0, 1.2.2, 1.3.0, 1.3.1, 1.3.1_06, 1.4.0, 1.4.1, 1.4.1_01, 1.4.1_03, 1.4.2, 5.0
-
b53
-
generic, x86
-
generic, linux, linux_redhat_7.2, windows_95, windows_98, windows_nt, windows_2000, windows_xp
I really like the Action interface (in fact, I'd
implemented it myself in a previous version of my
system) - but what about toggles? I'd like to be
able to define a ToggleAction that has an on/off
state. When I add it to a JToolbar, I'd get a
JToggleButton. When I add it to a JMenu, I'd get
a JCheckboxMenuItem. Setting its state to be on via
the menuitem would cause the appearance of the
JToggleButton to change automatically, etc.
The same idea could probably be extended to encompass
JRadioButton/JRadioButtonMenuItem pairs...
(Review ID: 29188)
======================================================================
Name: krT82822 Date: 01/24/2000
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)
Why does the new method "JToolBar.CreateActionComponent" return a JButton?
Because of this, it's not possible to create a JToggleButton for the action.
Suggestion: CreateActionComponent should return a JAbstractButton or, even
better, a Component (since buttons aren't the only thing usually visible in a
toolbar, and for example ComboBoxes could be associated with an action as well).
(Review ID: 100282)
======================================================================
Name: krC82822 Date: 11/02/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
Right now Action and AbstractAction provides support for creating several
controls with a common behaviour and with their enabled state synchronized, but
there is no way to have several toggle buttons synchronized in such a way. I
think it could be interesting to add ToggleAction and AbstractToggleAction, so
we could have several toggle buttons with their selected state synchronized.
The additional classes could be something like this:
package javax.swing;
public interface ToggleAction extends Action
{
boolean isSelected( );
void setSelected( boolean selected );
}
package javax.swing;
import java.io.Serializable;
import java.awt.event.*;
public abstract class AbstractToggleAction extends AbstractAction
implements ToggleAction, Cloneable, Serializable
{
protected boolean selected = false;
public AbstractToggleAction( )
{ super( ); }
public AbstractToggleAction( String name )
{ super( name ); }
public AbstractToggleAction( String name, Icon icon )
{ super( name, icon ); }
public Object clone( )
{
AbstractToggleAction copy = null;
try
{
copy = (AbstractToggleAction) super.clone( );
copy.selected = this.selected;
}
catch( CloneNotSupportedException exc )
{}
return copy;
}
public boolean isSelected( )
{ return selected; }
public void setSelected( boolean selected )
{
if( this.selected != selected )
{
this.selected = selected;
firePropertyChange( "selected", new Boolean( !this.selected ), new Boolean
( this.selected ) );
}
}
public void actionPerformed( ActionEvent e )
{
Object source = e.getSource( );
if( source instanceof AbstractButton )
{
AbstractButton button = (AbstractButton) source;
setSelected( button.isSelected( ) );
}
}
}
This classes could be used adding a setToggleAction method to JToggleButton and
JCheckboxMenuItem.
(Review ID: 111728)
======================================================================
- duplicates
-
JDK-4885827 JButton not updated when client property "hideActionText" changes.
- Closed
-
JDK-4156235 Action needs ability to handle toggle states
- Closed
-
JDK-4269932 Create buttons other than JButtons when adding actions to a JToolBar
- Closed
-
JDK-4491747 RFE: Use of Action still needs work
- Closed
-
JDK-4629461 Enhancement management of the javax.swing.Action class
- Closed
-
JDK-4751776 javax.swing.Action shoud support displayedMnemonicIndex
- Closed
-
JDK-6350748 Common icon for buttons and menus with Action.SMALL_ICON is restrictive
- Closed
- relates to
-
JDK-6397556 REGRESSION: StackOverflowError when 2 JToggleButtons within ButtonGroup bound to same Action
- Resolved