Java Doc for ButtonModel.java in  » 6.0-JDK-Core » swing » javax » swing » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.swing.ButtonModel

All known Subclasses:   javax.swing.DefaultButtonModel,
ButtonModel
public interface ButtonModel extends ItemSelectable(Code)
State model for buttons.

This model is used for regular buttons, as well as check boxes and radio buttons, which are special kinds of buttons. In practice, a button's UI takes the responsibility of calling methods on its model to manage the state, as detailed below:

In simple terms, pressing and releasing the mouse over a regular button triggers the button and causes and ActionEvent to be fired. The same behavior can be produced via a keyboard key defined by the look and feel of the button (typically the SPACE BAR). Pressing and releasing this key while the button has focus will give the same results. For check boxes and radio buttons, the mouse or keyboard equivalent sequence just described causes the button to become selected.

In details, the state model for buttons works as follows when used with the mouse:
Pressing the mouse on top of a button makes the model both armed and pressed. As long as the mouse remains down, the model remains pressed, even if the mouse moves outside the button. On the contrary, the model is only armed while the mouse remains pressed within the bounds of the button (it can move in or out of the button, but the model is only armed during the portion of time spent within the button). A button is triggered, and an ActionEvent is fired, when the mouse is released while the model is armed - meaning when it is released over top of the button after the mouse has previously been pressed on that button (and not already released). Upon mouse release, the model becomes unarmed and unpressed.

In details, the state model for buttons works as follows when used with the keyboard:
Pressing the look and feel defined keyboard key while the button has focus makes the model both armed and pressed. As long as this key remains down, the model remains in this state. Releasing the key sets the model to unarmed and unpressed, triggers the button, and causes an ActionEvent to be fired.
version:
   1.35 05/05/07
author:
   Jeff Dinkins





Method Summary
 voidaddActionListener(ActionListener l)
     Adds an ActionListener to the model.
 voidaddChangeListener(ChangeListener l)
     Adds a ChangeListener to the model.
 voidaddItemListener(ItemListener l)
     Adds an ItemListener to the model.
public  StringgetActionCommand()
     Returns the action command string for the button.
public  intgetMnemonic()
     Gets the keyboard mnemonic for the button.
 booleanisArmed()
     Indicates partial commitment towards triggering the button.
 booleanisEnabled()
     Indicates if the button can be selected or triggered by an input device, such as a mouse pointer.
 booleanisPressed()
     Indicates if the button is pressed.
 booleanisRollover()
     Indicates that the mouse is over the button.
 booleanisSelected()
     Indicates if the button has been selected.
 voidremoveActionListener(ActionListener l)
     Removes an ActionListener from the model.
 voidremoveChangeListener(ChangeListener l)
     Removes a ChangeListener from the model.
 voidremoveItemListener(ItemListener l)
     Removes an ItemListener from the model.
public  voidsetActionCommand(String s)
     Sets the action command string that gets sent as part of the ActionEvent when the button is triggered.
public  voidsetArmed(boolean b)
     Marks the button as armed or unarmed.
public  voidsetEnabled(boolean b)
     Enables or disables the button.
public  voidsetGroup(ButtonGroup group)
     Identifies the group the button belongs to -- needed for radio buttons, which are mutually exclusive within their group.
public  voidsetMnemonic(int key)
     Sets the keyboard mnemonic (shortcut key or accelerator key) for the button.
public  voidsetPressed(boolean b)
     Sets the button to pressed or unpressed.
public  voidsetRollover(boolean b)
    
public  voidsetSelected(boolean b)
     Selects or deselects the button.



Method Detail
addActionListener
void addActionListener(ActionListener l)(Code)
Adds an ActionListener to the model.
Parameters:
  l - the listener to add



addChangeListener
void addChangeListener(ChangeListener l)(Code)
Adds a ChangeListener to the model.
Parameters:
  l - the listener to add



addItemListener
void addItemListener(ItemListener l)(Code)
Adds an ItemListener to the model.
Parameters:
  l - the listener to add



getActionCommand
public String getActionCommand()(Code)
Returns the action command string for the button. the String that identifies the generated event
See Also:   ButtonModel.setActionCommand



getMnemonic
public int getMnemonic()(Code)
Gets the keyboard mnemonic for the button. an int specifying the accelerator key
See Also:   ButtonModel.setMnemonic



isArmed
boolean isArmed()(Code)
Indicates partial commitment towards triggering the button. true if the button is armed,and ready to be triggered
See Also:   ButtonModel.setArmed



isEnabled
boolean isEnabled()(Code)
Indicates if the button can be selected or triggered by an input device, such as a mouse pointer. true if the button is enabled



isPressed
boolean isPressed()(Code)
Indicates if the button is pressed. true if the button is pressed



isRollover
boolean isRollover()(Code)
Indicates that the mouse is over the button. true if the mouse is over the button



isSelected
boolean isSelected()(Code)
Indicates if the button has been selected. Only needed for certain types of buttons - such as radio buttons and check boxes. true if the button is selected



removeActionListener
void removeActionListener(ActionListener l)(Code)
Removes an ActionListener from the model.
Parameters:
  l - the listener to remove



removeChangeListener
void removeChangeListener(ChangeListener l)(Code)
Removes a ChangeListener from the model.
Parameters:
  l - the listener to remove



removeItemListener
void removeItemListener(ItemListener l)(Code)
Removes an ItemListener from the model.
Parameters:
  l - the listener to remove



setActionCommand
public void setActionCommand(String s)(Code)
Sets the action command string that gets sent as part of the ActionEvent when the button is triggered.
Parameters:
  s - the String that identifies the generated event
See Also:   ButtonModel.getActionCommand
See Also:   java.awt.event.ActionEvent.getActionCommand



setArmed
public void setArmed(boolean b)(Code)
Marks the button as armed or unarmed.
Parameters:
  b - whether or not the button should be armed



setEnabled
public void setEnabled(boolean b)(Code)
Enables or disables the button.
Parameters:
  b - whether or not the button should be enabled
See Also:   ButtonModel.isEnabled



setGroup
public void setGroup(ButtonGroup group)(Code)
Identifies the group the button belongs to -- needed for radio buttons, which are mutually exclusive within their group.
Parameters:
  group - the ButtonGroup the button belongs to



setMnemonic
public void setMnemonic(int key)(Code)
Sets the keyboard mnemonic (shortcut key or accelerator key) for the button.
Parameters:
  key - an int specifying the accelerator key



setPressed
public void setPressed(boolean b)(Code)
Sets the button to pressed or unpressed.
Parameters:
  b - whether or not the button should be pressed
See Also:   ButtonModel.isPressed



setRollover
public void setRollover(boolean b)(Code)
Sets or clears the button's rollover state
Parameters:
  b - whether or not the button is in the rollover state
See Also:   ButtonModel.isRollover



setSelected
public void setSelected(boolean b)(Code)
Selects or deselects the button.
Parameters:
  b - true selects the button,false deselects the button



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.