|
Generated by JDiff |
||||||||
PREV PACKAGE NEXT PACKAGE FRAMES NO FRAMES |
This file contains all the changes in documentation in the packagejavax.swing
as colored differences. Deletions are shownlike this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.
This class provides default implementations for the JFCClass AbstractAction, constructor AbstractAction()Action
interface. Standard behaviors like the get and set methods forAction
object properties (icon text and enabled) are defined here. The developer need only subclass this abstract class and define theactionPerformed
method.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
32 0441 02/2202/9900 @author Georges Saab @see Action
Defines an Action
object with a default description string and default icon.
Class AbstractAction, constructor AbstractAction(String)Defines an Action
object with the specified description string and a default icon.
Class AbstractAction, constructor AbstractAction(String, Icon)Defines an Action
object with the specified description string and a the specified icon.
Class AbstractAction, void addPropertyChangeListener(PropertyChangeListener)Class AbstractAction, Object clone()AddAdds aPropertyChangeListener
to the listener list. The listener is registered for all properties.A
PropertyChangeEvent
will get fired in response to setting a bound property e.g.setFont
setBackground
orsetForeground
. Note that if the current component is inheriting its foreground background or font from its container then no event will be fired in response to a change in the inherited property. @param listener ThePropertyChangeListener
to be added @see Action#addPropertyChangeListener
Class AbstractAction, void firePropertyChange(String, Object, Object)CloneClones the abstract action. This gives the clone its own copy of the key/value list which is not handled for you byObject.clone()
.
Class AbstractAction, Object getValue(String)SupportSupportsforreporting bound property changes. This method can be called when a bound property has changed and it will send the appropriatePropertyChangeEvent
to any registeredPropertyChangeListeners
.
Gets theClass AbstractAction, boolean isEnabled()Object
associated with the specified key. @param key a string containing the specifiedkey
@return the bindingObject stored with this key; if there are no keys it will return
null
@see Action#getValue
Returns true if the action is enabled. @return true if the action is enabled false otherwise @see Action#isEnabledClass AbstractAction, void putValue(String, Object)
Sets theClass AbstractAction, void removePropertyChangeListener(PropertyChangeListener)Value
associated with the specified key. @param key theString
that identifies the stored object @param newValue theObject
to store using this key @see Action#putValue
RemoveRemoves aPropertyChangeListener
from the listener list. This removes aPropertyChangeListener
that was registered for all properties. @param listenerThethePropertyChangeListener
to be removed @see Action#removePropertyChangeListener
Definesthecommon behaviors forthebuttons and menu items. For further informationJButtonseeJToggleButtonHowJCheckboxto Use Buttons Check Boxes andtheRadio Buttons a section in TheJRadioButtonJavaclassesTutorial.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
101 04130 03/2214/9900 @author Jeff Dinkins
Class AbstractButton.AccessibleAbstractButton, AccessibleAction getAccessibleAction()AccessiblityThis class implements accessibility support for theAbstractButton
class. It provides an implementation of the Java Accessibility API appropriate to button and menu item user-interface elements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Get the AccessibleAction associated with this object.Class AbstractButton.AccessibleAbstractButton, int getAccessibleActionCount()if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleAction interface on behalf of itself. @return this object
Returns the number of Actions available in this object.Class AbstractButton.AccessibleAbstractButton, String getAccessibleName()If there is more than one the firstThe default behavior of a button is to have oneis theaction -"default"toggleactionthe button. @return 1 the number of Actions in this object
Class AbstractButton.AccessibleAbstractButton, AccessibleValue getAccessibleValue()GetReturns the accessible name of this object. @return the localized name of the object -- can benull
if this object does not have a name
Get the AccessibleValue associated with this object.Class AbstractButton.AccessibleAbstractButton, Number getMinimumAccessibleValue()if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleValue interface on behalf of itself. @return this object
Get the minimum value of this object as a Number. @returnAnan Integer of 0.
ExtendExtendsChangeListener
to be serializable.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Class AbstractButton, void addChangeListener(ChangeListener)addsAdds anActionListener
to the button. @param l theActionListener
to be added
Adds a ChangeListener
to the button. @param l the listener to be added
Class AbstractButton, void addItemListener(ItemListener)Class AbstractButton, int checkHorizontalKey(int, String)addsAdds anItemListener
to thecheckbox
. @param l theItemListener
to be added
Verify that key is a legal value for theClass AbstractButton, int checkVerticalKey(int, String)horizontalAlignment
properties. @param key the property value to check one of the following values:@param exception the
- SwingConstants.RIGHT (the default)
- SwingConstants.LEFT
- SwingConstants.CENTER
- SwingConstants.LEADING
- SwingConstants.TRAILING
IllegalArgumentException
detail message @exception IllegalArgumentException if keyisn'tisLEFT CENTER RIGHTnot one ofLEADINGthe legalorvaluesTRAILING.listed above @see #setHorizontalTextPosition @see #setHorizontalAlignment
Ensures that the key is a valid. Throws anClass AbstractButton, ChangeListener createChangeListener()IllegalArgumentIllegalArgumentException
exceptionexceptionotherwise. @param key the value to check one of the following values:@param exception a string to be passed to the
- SwingConstants.CENTER (the default)
- SwingConstants.TOP
- SwingConstants.BOTTOM
IllegalArgumentException
call if key is not one of the valid values listed above @exception IllegalArgumentException if key is not one of the legal values listed above
Subclasses that want to handleClass AbstractButton, void doClick()ChangeEvents
differently can override this to return anotherChangeListener
implementation. @return the newButtonChangeListener
Class AbstractButton, void doClick(int)ProgramaticallyProgrammatically perform a "click". This does the same thing as if the user had pressed and released the button.
Class AbstractButton, String getActionCommand()ProgramaticallyProgrammatically perform a "click". This does the same thing as if the user had pressed and released the button. The button stays visually "pressed" forpressTime
milliseconds. @param pressTime the time to "hold down" the button in milliseconds
Returns the action command for this button. @return the action command for this buttonClass AbstractButton, Icon getDisabledIcon()
Returns the icon used by the button when it's disabled. IfClass AbstractButton, Icon getDisabledSelectedIcon()notno disabled icon has been set the button constructs one from the default icon. <-- PENDING(jeff): the disabled icon really should be created (ifnecesarynecessary) by the L&F.--> @return thedisabledIcon
property @see #getPressedIcon @see #setDisabledIcon
Returns the icon used by the button when it's disabled and selected. If not no disabled selection icon has been set the button constructs one from the selection icon. <-- PENDING(jeff): the disabled selection icon really should be created (if necesary) by the L&F. --> @return the disabledSelectedIcon
property @see #getPressedIcon @see #setDisabledIcon
Class AbstractButton, int getHorizontalAlignment()Returns the horizontal alignment of the icon and text.Class AbstractButton, int getHorizontalTextPosition()Valid@returnkeysthehorizontalAlignment
property one of the following values:CENTER
- SwingConstants.RIGHT
(the default)- SwingConstants.LEFT
RIGHT- SwingConstants.CENTER
- SwingConstants.LEADING
- SwingConstants.TRAILING
Class AbstractButton, Icon getIcon()SetsReturns the horizontal position of the text relative to the icon.Valid@returnkeysthehorizontalTextPosition
property one of the following values:
- SwingConstants.
RIGHT (the default)- SwingConstants.LEFT
- SwingConstants.CENTER
- SwingConstants.LEADING
- SwingConstants.TRAILING
Returns the default icon. @return the default Icon
@see #setIcon
Class AbstractButton, String getLabel()Returns the label text. @return aClass AbstractButton, Insets getMargin()String
containing the label @deprecated - Replaced bygetText
()
Returns the margin between the button's border and the label. @return an Insets
object specifying the margin between the botton's border and the label @see #setMargin
Class AbstractButton, int getMnemonic()Class AbstractButton, ButtonModel getModel()GetReturns the keyboard mnemonic from the the current model. @return the keyboard mnemonic from the model
Class AbstractButton, Icon getPressedIcon()GetReturns the model that this button represents. @return themodel
property @see #setModel
Returns the pressed icon for the button. @return the pressedIcon
property @see #setPressedIcon
Class AbstractButton, Icon getRolloverIcon()Returns the rollover icon for the button. @return the rolloverIcon
property @see #setRolloverIcon
Class AbstractButton, Icon getRolloverSelectedIcon()Returns the rolloverClass AbstractButton, Icon getSelectedIcon()seletionselection icon for the button. @return therolloverSelectedIcon
property @see #setRolloverSelectedIcon
Returns the selected icon for the button. @return the selectedIcon
property @see #setSelectedIcon
Class AbstractButton, Object[] getSelectedObjects()Returns an array (length 1) containing the label orClass AbstractButton, String getText()null
if the button is not selected. @return an array containing 1 Object:--the text of the button--if the item is selected; otherwisenull
Returns the button's text. @return the buttons text @see #setTextClass AbstractButton, ButtonUI getUI()
Returns theClass AbstractButton, int getVerticalAlignment()button'sL&FcurrentobjectUIthat renders this component. @return the ButtonUI object @see #setUI
Returns the vertical alignment of the text and icon.Class AbstractButton, int getVerticalTextPosition()Valid@returnkeystheverticalAlignment
property one of the following values:
- SwingConstants.
CENTER (the default)- SwingConstants.TOP
- SwingConstants.BOTTOM
Returns the vertical position of the text relative to the icon.Class AbstractButton, boolean imageUpdate(Image, int, int, int, int, int)Valid@returnkeystheverticalTextPosition
property one of the following values:
- SwingConstants.
CENTER (the default)- SwingConstants.TOP
- SwingConstants.BOTTOM
Class AbstractButton, boolean isBorderPainted()Repaints the component when the image has changed.ThisimageUpdate method of an ImageObserveriscalled when more informationoverriddenabout an image which had been previously requested using an asynchronoustoroutine such asreturn false if thedrawImage method ofcurrent
GraphicsIconbecomes available. See the definition'sof
imageUpdateImagefor more information on thisismethod and itsnot equal toarguments.theThepassed in
imageUpdateImagemethod of
Componentimgincrementally draws an image on the component as more of the bits of the image are available. @paramIfimg thesystem property
awt.image.incrementalDrawImageis missing or has thetovaluebetruecomparedthe@paramimage is incrementally drawn Ifinfoflags flags used to repaint thesystem property has anybuttonother value thenwhen the image isnot drawn until it has been completely loaded. Also if incremental drawing is in effect the valueupdatedof the system propertyand which determine howawt.image.redrawratemuch isinterpreted as an integertogive the maximum redraw rate in milliseconds. If the system property is missing or cannotbeinterpreted as an integer the redraw rate is once every 100ms. The interpretation of the x y width and height arguments depends on the value of the infoflags argument. @param img the image being observed. @param infoflags see imageUpdate for more information.painted @param x the x coordinate.@param y the y coordinate.@paramwidthw the width.@paramheighth the height. @return true if the flags indicate that the image is completely loaded; false otherwise. @see java.awt.image.ImageObserver @see java.awt.Graphics#drawImage(java.awt.Image int int java.awt.Color java.awt.image.ImageObserver) @see java.awt.Graphics#drawImage(java.awt.Image int int java.awt.image.ImageObserver) @see java.awt.Graphics#drawImage(java.awt.Image int int int int java.awt.Color java.awt.image.ImageObserver)@see java.awt.Graphics#drawImage(java.awt.Image int int int int java.awt.image.ImageObserver)@see java.awt.image.ImageObserverComponent#imageUpdate(java.awt.Image int int int int int)@since JDK1.0
Returns whether the border should be painted. @return true if the border should be painted false otherwise @see #setBorderPaintedClass AbstractButton, boolean isContentAreaFilled()
Checks whether the "content area" of the button should be filled. @return the contentAreaFilled
property @see #setFocusPainted
Class AbstractButton, boolean isFocusPainted()Returns whether focus should be painted. @return the paintFocus
property @see #setFocusPainted
Class AbstractButton, boolean isFocusTraversable()Identifies whether or not this component can receive the focus.Class AbstractButton, boolean isRolloverEnabled()A disabled button for example would return false.@return true if this component can receive the focus
Checks whether rollover effects are enabled. @return the rolloverEnabled
property @see #setFocusPainted
Class AbstractButton, boolean isSelected()Returns the state of the button. True if the toggle button is selected false if it's not. @return true if the toggle button is selected otherwise falseClass AbstractButton, void paintBorder(Graphics)
Paint the button's border ifClass AbstractButton, String paramString()BorderPainted
property is true. @param g theGraphics
context in which to paint @see #paint @see #setBorder
Returns a string representation of thisClass AbstractButton, void removeActionListener(ActionListener)AbstractButton
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
.Overriding
paramString
to provide information about the specific new aspects of the JFC components. @return a string representation of this()AbstractButton
.
Class AbstractButton, void removeChangeListener(ChangeListener)removesRemoves anActionListener
from the button. If the listener is the currently setAction
for the button then theAction
is set tonull
. @param l the listener to be removed
Removes a ChangeListener from the button. @param l the listener to be removedClass AbstractButton, void removeItemListener(ItemListener)
Class AbstractButton, void setActionCommand(String)removesRemoves anItemListener
from the button. @param l theItemListener
to be removed
Sets the action command for this button. @param actionCommand the action command for this buttonClass AbstractButton, void setBorderPainted(boolean)
Sets whether the border should be painted. @param b if true and border property is not null
the border is painted. @see #isBorderPainted @beaninfo bound: true attribute: visualUpdate true description: Whether the border should be painted.
Class AbstractButton, void setContentAreaFilled(boolean)Sets whether the button should paint the content area or leave it transparent. If you wish to have a transparent button for example and icon only button then you should set this to false. Do not callClass AbstractButton, void setDisabledIcon(Icon)setOpaque(false)
. Whether the button follows theRepaintManager
's concept of opacity is L&F depandant.This function may cause the component's opaque property to change.
The exact behavior of calling this function varies on a component-by-component and L&F-by-L&F basis. @param b if true rollover effects should be painted
.@see #isContentAreaFilled @see #setOpaque @beaninfo bound: true attribute: visualUpdate true description: Whether the button should paint the content area or leave it transparent.
Sets the disabled icon for the button. @paramClass AbstractButton, void setDisabledSelectedIcon(Icon)gdisabledIcon the icon used as the disabled image @see #getDisabledIcon @beaninfo bound: true attribute: visualUpdate true description: The disabled icon for the button.
Sets the disabled selection icon for the button. @paramClass AbstractButton, void setEnabled(boolean)gdisabledSelectedIcon the icon used as the disabled selection image @see #getDisabledSelectedIcon @beaninfo bound: true attribute: visualUpdate true description: The disabled selection icon for the button.
Enables (or disables) the button. @param b true to enable the button otherwise falseClass AbstractButton, void setFocusPainted(boolean)
Sets whether focus should be painted. @param b if true the focus state is paintedClass AbstractButton, void setHorizontalAlignment(int).@see #isFocusPainted @beaninfo bound: true attribute: visualUpdate true description: Whether focus should be painted
Sets the horizontal alignment of the icon and text.Class AbstractButton, void setHorizontalTextPosition(int)Valid@param alignment one of the followingkeysvalues:CENTER@beaninfo bound: true enum: LEFT SwingConstants.LEFT CENTER SwingConstants.CENTER RIGHT SwingConstants.RIGHT LEADING SwingConstants.LEADING TRAILING SwingConstants.TRAILING attribute: visualUpdate true description: The horizontal alignment of the icon and text.
- SwingConstants.RIGHT
(the default)- SwingConstants.LEFT
RIGHT- SwingConstants.CENTER
- SwingConstants.LEADING
or- SwingConstants.TRAILING
Sets the horizontal position of the text relative to the icon.Class AbstractButton, void setIcon(Icon)Valid keys: RIGHT (the default) LEFT CENTER LEADING TRAILING@exception IllegalArgumentExceptionparam textPosition@beaninfoonebound:of thetrue enumfollowing values:LEFT
- SwingConstants.
LEFTRIGHTCENTER(the default)- SwingConstants.
CENTER RIGHTLEFT- SwingConstants.
RIGHT LEADINGCENTER- SwingConstants.LEADING
TRAILING- SwingConstants.TRAILING
attribute: visualUpdate true description: The horizontal position of the textrelative@exceptionto theIllegalArgumentException ificon.textPosition
Sets the button's default icon. This icon is also used as the "pressed" and "disabled" icon if there is no explicitly set pressed icon. @paramClass AbstractButton, void setLabel(String)gdefaultIcon the icon used as the default image @see #getIcon @see #setPressedIcon @beaninfo bound: true attribute: visualUpdate true description: The button's default icon
Sets the label text. @param label aClass AbstractButton, void setMargin(Insets)String
containing the text @deprecated - Replaced bysetText(text)
@beaninfo bound: true description: Replace by setText(text)
Sets space for margin between the button's border and the label. Setting toClass AbstractButton, void setMnemonic(char)null
will cause the button to use the default margin. The button's defaultBorder
object will use this value to create the proper margin. However if a non-default border is set on the button it is thatBorder
object's responsibility to create the appropriate margin space (else this property will effectively be ignored). @param m the space between the border and the label @beaninfo bound: true attribute: visualUpdate true description: The space between the button's border and the label.
Specifies the mnemonic value. @param mnemonic a char specifying the mnemonic value @beaninfo bound: true attribute: visualUpdate true description: the keyboard character mnemonicClass AbstractButton, void setMnemonic(int)
Class AbstractButton, void setModel(ButtonModel)SetSets the keyboard mnemonic on the current model. @param mnemonic the key code which represents the mnemonic @beaninfo bound: true attribute: visualUpdate true description: the keyboard character mnemonic
Class AbstractButton, void setPressedIcon(Icon)SetSets the model that this button represents. @param m theModelnewButtonModel
@see #getModel @beaninfo bound: true description: Model that the Button uses.
Sets the pressed icon for the button. @paramClass AbstractButton, void setRolloverEnabled(boolean)gpressedIcon the icon used as the "pressed" image @see #getPressedIcon @beaninfo bound: true attribute: visualUpdate true description: The pressed icon for the button.
Sets whether rollover effects should be enabled. @param b if true rollover effects should be paintedClass AbstractButton, void setRolloverIcon(Icon).@see #isRolloverEnabled @beaninfo bound: true attribute: visualUpdate true description: Whether rollover effects should be enabled.
Sets the rollover icon for the button. @paramClass AbstractButton, void setRolloverSelectedIcon(Icon)grolloverIcon the icon used as the "rollover" image @see #getRolloverIcon @beaninfo bound: true attribute: visualUpdate true description: The rollover icon for the button.
Sets the rollover selected icon for the button. @paramClass AbstractButton, void setSelected(boolean)grolloverSelectedIcon the icon used as the "selected rollover" image @see #getRolloverSelectedIcon @beaninfo bound: true attribute: visualUpdate true description: The rollover selected icon for the button.
Sets the state of the button. Note that this method does not trigger anClass AbstractButton, void setSelectedIcon(Icon)actionEvent
. CalldoClick
to perform a programatic action change. @param b true if the button is selected otherwise false()
Sets the selected icon for the button. @paramClass AbstractButton, void setUI(ButtonUI)gselectedIcon the icon used as the "selected" image @see #getSelectedIcon @beaninfo bound: true attribute: visualUpdate true description: The selected icon for the button.
Sets theClass AbstractButton, void setVerticalAlignment(int)button'sL&FUIobject that renders this component. @param ui thenewButtonUI
L&F object @see #getUI
Sets the vertical alignment of the icon and text.Class AbstractButton, void setVerticalTextPosition(int)Valid@param alignment one of the followingkeysvalues:@beaninfo bound: true enum: TOP SwingConstants.TOP CENTER SwingConstants.CENTER BOTTOM SwingConstants.BOTTOM attribute: visualUpdate true description: The vertical alignment of the icon and text.
- SwingConstants.
CENTER (the default)- SwingConstants.TOP
- SwingConstants.BOTTOM
Sets the vertical position of the text relative to the icon.Class AbstractButton, void updateUI()Valid@param alignment one of the followingkeysvalues:@beaninfo bound: true enum: TOP SwingConstants.TOP CENTER SwingConstants.CENTER BOTTOM SwingConstants.BOTTOM attribute: visualUpdate true description: The vertical position of the text relative to the icon.
- SwingConstants.
CENTER (the default)- SwingConstants.TOP
- SwingConstants.BOTTOM
Class AbstractButton, String ROLLOVER_SELECTED_ICON_CHANGED_PROPERTYGetsNotificationa newfromUItheobjectUIFactory
fromthat thedefaultL&FUIFactoryhas changed. Subtypes ofAbstractButton
should override this to update the UI. For exampleJButton
might do the following:setUI((ButtonUI)UIManager.getUI( "ButtonUI" "javax.swing.plaf.basic.BasicButtonUI" this));
Identifies a change to the icon used when theClass AbstractButton, ChangeEvent changeEventcursrorcursor is over the button and it has been selected.
Only one ChangeEvent
is needed per button instance since the event's only state is the source property. The source of events generated is always "this".
Class AbstractButton, ChangeListener changeListenerThe button'smodel'slistenerschangeListener
.
The Abstract definition for the data model the provides a List with its contents.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
19 1022 02/2702/9800 @author Hans Muller
TheClass Action, void addPropertyChangeListener(PropertyChangeListener)JFCAction
interface provides a useful extension to theActionListnerActionListener
interface in cases where the same functionality may be accessed by several controls.In addition to the
actionPerformed
method defined by theActionListener
interface this interface allows the application to define in a single place:
- One or more text strings that describe the function. These strings can be used for example to display the flyover text for a button or to set the text in a menu item.
- One or more icons that depict the function. These icons can be used for the images in a menu control or for composite
-entries in a more sophisticated user-interface.- The enabled/disabled state of the functionality. Instead of having to separately disable the menu
-item and the toolbar-button the application can disable the function that implements this interface. All components which are registered as listeners for the state-change then know to disable event-generation for that item and to modify the display accordingly.Containers in the SwingCertainset likecontainers including menus andtoolbarstool bars know how to add anAction object as well as other components using a version of the
addActionmethodobject. When anAction
object is added to such a container the container:For example both a menu item and a toolbar button could access a
- Creates a component that is appropriate for that container (a
toolbartool bar creates a button component for example).- Gets the appropriate property(s) from the
Action
object to customize the component (for example the icon image and flyover text).- Checks the intial state of the
Action
object to determine if it is enabled or disabled and renders the component in the appropriate fashion.- Registers a listener with the
Action
object so that is notified of state changes. When theAction
object changes from enabled to disabled or back the container makes the appropriate revisions to the event-generation mechanisms and renders the component accordingly.Cut
action object. The text associated with the object is specified as "Cut" and an image depicting a pair of scissors is specified as its icon. TheCut
action-object can then be added to a menu and to atoolbartool bar. Each container does the appropriate things with the object and invokes itsactionPerformed
method when the component associated with it is activated. The application can then disable or enable the application object without worrying about what user-interface components are connected to it.This interface can be added to an existing class or used to create an adapter (typically by subclassing
AbstractActionAbstractActio
). TheAction
object can then be added to multiple action-aware containers and connected to Action-capable components. The GUI controls can then be activated or deactivated all at once by invoking theAction
object'ssetEnabled
method.Note that
Action
implementations tend to be more expensive in terms of storage than a typicalActionListener
which does not offer the benefits of centralized control of functionality and broadcast of property changes. Forthisth is reason you should take care to only useActionsAction
s where their benefits are desired and useasimpleActionListener where they are notActionListeners
necessaryelsewhere. @version 1.15211002/3002/9800 @author Georges Saab @see AbstractAction
Class Action, boolean isEnabled()AddAdds aPropertyChange
listener. Containers and attached components use these methods to register interest in thisAction
object. When its enabled state or other property changes the registered listeners are informed of the change. @param listener aPropertyChangeListener
object...
Class Action, void putValue(String, Object)SetsReturns the enabled state of theAction
. When enabled any component associated with this object is active and able to fire this object'sactionPerformed
method. @return true if thisAction
is enabled
Sets one of this object's properties using the associated key. If the value has changed aClass Action, void removePropertyChangeListener(PropertyChangeListener)PropertyChangeEvent
is sent to listeners. @param key aString
containing the key @param value anObject
value
Class Action, void setEnabled(boolean)RemoveRemoves aPropertyChange
listener. @param listener aPropertyChangeListener
object...@see #addPropertyChangeListener
Class Action, String DEFAULTTestsSets the enabled state of theAction
. When enabled any component associated with this object is active and able to fire this object'sactionPerformed
method. If the value has changed aPropertyChangeEvent
is sent to listeners. @param b true to enable thisAction
false to disable it
Useful constants that can be used as the storage-retreivalretrieval key when setting or getting one of this object's properties (text or icon).
Factory class for vending standardClass BorderFactory, Border createBevelBorder(int)Border
objects.WhereeverWherever possible this factory will hand out references to sharedBorder
instances. For further information and examples see How to Use Borders a section in The Java Tutorial. @version 1.15 1023 02/2002/9800 @author David Kloba
Class BorderFactory, Border createBevelBorder(int, Color, Color)CreateCreates a beveled border of the specified type using brighter shades of the component's current background color for highlighting and darker shading for shadows. (In a lowered border shadows are on top and highlights are underneath.).@param type anintinteger specifying eitherBevelBorder.LOWERED
orBevelBorder.
@return theLOWEREDRAISEDBorder
object
Class BorderFactory, Border createBevelBorder(int, Color, Color, Color, Color)CreateCreates a beveled border of the specified type using the specified highlighting and shadowing. The outer edge of the highlighted area uses a brighter shade of the highlight color. The inner edge of the shadow area uses a brighter shade of theshadawshadow color. @param type anintinteger specifying eitherBevelBorder.LOWERED
orBevelBorder.
@param highlight aLOWEREDRAISEDColor
object for highlights @param shadow aColor
object for shadows @return theBorder
object
Class BorderFactory, CompoundBorder createCompoundBorder()CreateCreates a beveled border of the specified type using the specified colors for the inner and outer highlight and shadow areas. @param type anintinteger specifying eitherBevelBorder.LOWERED
orBevelBorder.
@param highlightOuter aLOWEREDRAISEDColor
object for the outer edge of the highlight area @param highlightInner aColor
object for the inner edge of the highlight area @param shadowOuter aColor
object for the outer edge of the shadow area @param shadowInner aColor
object for the inner edge of the shadow area @return theBorder
object
Class BorderFactory, CompoundBorder createCompoundBorder(Border, Border)CreateCreates a compound border with anull
inside edge and anull
outside edge. @return theCompoundBorder
object
Class BorderFactory, Border createEmptyBorder()CreateCreates a compound border specifying the border objects to use for the outside and inside edges. @param outsideBorder aBorder
object for the outer edge of the compound border @param insideBorder aBorder
object for the inner edge of the compound border @return theCompoundBorder
object
Creates an empty border that takes up no space. (The width of the top bottom left and right sides are all zero.) @return the Border
object
Class BorderFactory, Border createEmptyBorder(int, int, int, int)Creates an empty border that takes upClass BorderFactory, Border createEtchedBorder()nospace but which does no drawing specifying the width of the top left bottom and right sides. @param top anintinteger specifying the width of the top in pixels @param left anintinteger specifying the width of the left side in pixels @param bottom anintinteger specifying the width of the right side in pixels @param right anintinteger specifying the width of the bottom in pixels @return theBorder
object
Class BorderFactory, Border createLineBorder(Color)CreateCreates a border with an "etched" look using the component's current background color for highlighting and shading. @return theBorder
object
Creates a line border withe the specified color. @param color aClass BorderFactory, Border createLineBorder(Color, int)Color
to use for the line @return theBorder
object
Creates a line borderClass BorderFactory, Border createLoweredBevelBorder()withewith the specified color and width. The width applies to all4four sides of the border. To specify widths individually for the top bottom left and right use in int int Color)}. @param color aColor
to use for the line @param thickness anintinteger specifying the width in pixels @return theBorder
object
Class BorderFactory, MatteBorder createMatteBorder(int, int, int, int, Color)CreatedCreates a border with a lowered beveled edge using brighter shades of the component's current background color for highlighting and darker shading for shadows. (In a lowered border shadows are on top and highlights are underneath.) @return theBorder
object
Class BorderFactory, MatteBorder createMatteBorder(int, int, int, int, Icon)CreateCreates a matte-look border using a solid color. (The difference between this border and a line border is that you can specify the individual border dimensions.) @param top anintinteger specifying the width of the top in pixels @param left anintinteger specifying the width of the left side in pixels @param bottom anintinteger specifying the width of the right side in pixels @param right anintinteger specifying the width of the bottom in pixels @param color aColor
to use for the border @return theMatteBorder
object
Class BorderFactory, Border createRaisedBevelBorder()CreateCreates a matte-look border that consists of multiple tiles of a specified icon. Multiple copies of the icon are placed side-by-side to fill up the border area.Note:
If the icon doesn't load the border area is painted gray. @param top anintinteger specifying the width of the top in pixels @param left anintinteger specifying the width of the left side in pixels @param bottom anintinteger specifying the width of the right side in pixels @param right anintinteger specifying the width of the bottom in pixels @param tileIcon theIcon
object used for the border tiles @return theMatteBorder
object
Class BorderFactory, TitledBorder createTitledBorder(Border)CreatedCreates a border with a raised beveled edge using brighter shades of the component's current background color for highlighting and darker shading for shadows. (In a raised border highlights are on top and shadows are underneath.) @return theBorder
object
Class BorderFactory, TitledBorder createTitledBorder(Border, String)CreateCreates a new title border with an empty title specifying the border object using the default text position (sitting on the top line) and default justification (leftleading) and using the default font text color and border determined by the current look and feel. (The Motif and Windows look and feels use an etched border; The Java look and feeluseuses a gray border.) @param border theBorder
object to add the title to @return theTitledBorder
object
Class BorderFactory, TitledBorder createTitledBorder(Border, String, int, int)AddAdds a title to an existing border specifying the text of the title using the default positioning (sitting on the top line) and default justification (leftleading) and using the default font and text color determined by the current look and feel. @param border theBorder
object to add the title to @param title aString
containing the text of the title @return theTitledBorder
object
Class BorderFactory, TitledBorder createTitledBorder(Border, String, int, int, Font)AddAdds a title to an existing border specifying the text of the title along with its positioning using the default font and text color determined by the current look and feel. @param border theBorder
object to add the title to @param title aString
containing the text of the title @param titleJustification anintinteger specifying theleft/rightjustificationpositionof the title -- one of the following:TitledBorder.LEFT
TitledBorder.CENTER
orTitledBorder.RIGHT
TitledBorder.LEADING
TitledBorder.TRAILING
TitledBorder.DEFAULT_JUSTIFICATION
(leftleading).@param titlePosition anintinteger specifying the vertical position of the text in relation to the border -- one of the following:@return the
- TitledBorder.ABOVE_TOP
- TitledBorder.TOP (sitting on the top line)
TitledBorder.BELOW_TOP
TitledBorder.ABOVE_BOTTOM
TitledBorder.BOTTOM
(sitting on the bottom line)TitledBorder.BELOW_BOTTOM
orTitledBorder.DEFAULT_POSITION
(top).TitledBorder
object
Class BorderFactory, TitledBorder createTitledBorder(Border, String, int, int, Font, Color)AddAdds a title to an existing border specifying the text of the title along with its positioning and font using the default text color determined by the current look and feel. @param border theBorder
object to add the title to @param title aString
containing the text of the title @param titleJustification anintinteger specifying theleft/rightjustificationpositionof the title -- one of the following:TitledBorder.LEFT
TitledBorder.CENTER
orTitledBorder.RIGHT
TitledBorder.LEADING
TitledBorder.TRAILING
TitledBorder.DEFAULT_JUSTIFICATION
(leftleading).@param titlePosition anintinteger specifying the vertical position of the text in relation to the border -- one of the following:@param titleFont a Font object specifying the title font @return the TitledBorder object
- TitledBorder.ABOVE_TOP
- TitledBorder.TOP (sitting on the top line)
TitledBorder.BELOW_TOP
TitledBorder.ABOVE_BOTTOM
TitledBorder.BOTTOM
(sitting on the bottom line)TitledBorder.BELOW_BOTTOM
orTitledBorder.DEFAULT_POSITION
(top).
Class BorderFactory, TitledBorder createTitledBorder(String)AddAdds a title to an existing border specifying the text of the title along with its positioning font and color. @param border theBorder
object to add the title to @param title aString
containing the text of the title @param titleJustification anintinteger specifying theleft/rightjustificationpositionof the title -- one of the following:TitledBorder.LEFT
TitledBorder.CENTER
orTitledBorder.RIGHT
TitledBorder.LEADING
TitledBorder.TRAILING
TitledBorder.DEFAULT_JUSTIFICATION
(leftleading).@param titlePosition anintinteger specifying the vertical position of the text in relation to the border -- one of the following:@param titleFont a
- TitledBorder.ABOVE_TOP
- TitledBorder.TOP (sitting on the top line)
TitledBorder.BELOW_TOP
TitledBorder.ABOVE_BOTTOM
TitledBorder.BOTTOM
(sitting on the bottom line)TitledBorder.BELOW_BOTTOM
orTitledBorder.DEFAULT_POSITION
(top).Font
object specifying the title font @param titleColor aColor
object specifying the title color @return theTitledBorder
object
CreateCreates a new title border specifying the text of the title using the default border (etched) using the default text position (sitting on the top line) and default justification (leftleading) and using the default font and text color determined by the current look and feel. @param title aString
containing the text of the title @return theTitledBorder
object
Defines the data model used by components like Sliders and ProgressBars. Defines four interrelated integer properties: minimum maximum extent and value. These four integers define two nested ranges like this:minimum < value < value+extent < maximumThe outer range isminimum maximum
and the inner range isvalue value+extent
. The inner range must lie within the outer one i.e.value
must be less than or equal tomaximum
andvalue+extent
must greater than or equal tominimum
andmaximum
must be greater than or equal tominimum
. There are a few features of this model that one might find a little surprising. These quirks exist for the convenience of the Swing BoundedRangeModel clients like like Slider and ScrollBar.
- The minimum and maximum set methods "correct" the other three properties to acommodate their new value argument. For example setting the model's minimum may change its maximum value and extent properties (in that order) to maintain the constraints specified above.
- The value and extent set methods "correct" their argument to fit within the limits defined by the other three properties. For example if
value == maximum
setExtent(10)
would change the extent (back) to zero.- The four BoundedRangeModel values are defined as Java Beans properties however Swing ChangeEvents are used to notify clients of changes rather than PropertyChangeEvents. This was done to keep the overhead of monitoring a BoundedRangeModel low. Changes are often reported at MouseDragged rates.
For an example of specifying custom bounded range models used by sliders see The Anatomy of a Swing-Based Program in The Java Tutorial. @version 1.
19 0822 02/2602/9800 @author Hans Muller @see DefaultBoundedRangeModel
A lightweight container that uses a BoxLayout object as its layout manager. Box provides several class methods that are useful for containers using BoxLayout -- even non-Box containers.The Box class can create several kinds of invisible components that affect layout: glue struts and rigid areas. If all the components your Box contains have a fixed size you might want to use a glue component (returned by
createGlue
) to control the components' positions. If you need a fixed amount of space between two components try using a strut (createHorizontalStrut
orcreateVerticalStrut
). If you need an invisible component that always takes up the same amount of space get it by invokingcreateRigidArea
.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see BoxLayout @author Timothy Prinzing @version 1.
30 0934 03/0114/9800
Return the nth Accessible child of the object. @param i zero-based index of child @return the nth Accessible child of the objectClass Box.AccessibleBox, int getAccessibleChildrenCount()or null
Returns the number of accessible children in the object. If all of the children of this object implement AccessibleClass Box.AccessibleBox, AccessibleComponent getAccessibleComponent()thenthan this method should return the number of children of this object. @return the number of accessible children in the object= 0.
Class Box.AccessibleBox, int getAccessibleIndexInParent()GetsGet the AccessibleComponent associated with this object if one exists. Otherwise return null. @return the component
Class Box.AccessibleBox, Accessible getAccessibleParent()GetsGet the index of this object in its accessible parent. @return the index of this object in its parent= 0; -1 if this object does not have an accessible parent. @see #getAccessibleParent
Class Box.AccessibleBox, AccessibleStateSet getAccessibleStateSet()GetsGet the Accessible parent of this object. If the parent of this object implements Accessible this method should simply return getParent(). @return the Accessible parent of this object -- can be null if this object does not have an Accessible parent
Class Box.AccessibleBox, Color getBackground()GetsGet the state of this object. @return an instance of AccessibleStateSet containing the current state set of the object @see AccessibleState
Class Box.AccessibleBox, Cursor getCursor()GetsGet the background color of this object. @return the background color if supported of the object; otherwise null
Class Box.AccessibleBox, Font getFont()GetsGet the Cursor of this object. @return the Cursor if supported of the object; otherwise null
Class Box.AccessibleBox, FontMetrics getFontMetrics(Font)GetsGet the Font of this object. @return the Font if supported for the object; otherwise null
Class Box.AccessibleBox, Color getForeground()GetsGet the FontMetrics of this object. @param f the Font @return the FontMetrics if supported the object; otherwise null @see #getFont
Class Box.AccessibleBox, Locale getLocale()GetsGet the foreground color of this object. @return the foreground color if supported of the object; otherwise null
Class Box.AccessibleBox, boolean isEnabled()ReturnsReturn the locale of this object. @return the locale of this object
Class Box.AccessibleBox, boolean isFocusTraversable()DeterminesDetermine if the object is enabled. @return true if object is enabled; otherwise false
Class Box.AccessibleBox, boolean isShowing()DeterminesReturns whether this object can accept focus or not. @return true if object can accept focus; otherwise false
Class Box.AccessibleBox, boolean isVisible()DeterminesDetermine if the object is showing. This is determined by checking the visibility of the object and ancestors of the object. Note: this will return true even if the object is obscured by another (for example it happens to be underneath a menu that was pulled down). @return true if object is showing; otherwise false
Class Box.AccessibleBox, void setBackground(Color)DeterminesDetermine if the object is visible. Note: this means that the object intends to be visible; however it may not in fact be showing on the screen because one of the objects that this object is contained by is not visible. To determine if an object is showing on the screen use isShowing(). @return true if object is visible; otherwise false
Class Box.AccessibleBox, void setBounds(Rectangle)SetsSet the background color of this object. (For transparency seeisOpaque
.) @param c the new Color for the backgroundnull if@seenoneComponent#isOpaque
Sets the bounds of this object in the form of a Rectangle object. The bounds specify this object's width height and location relative to its parent. @paramClass Box.AccessibleBox, void setCursor(Cursor)rAarectangle indicating this component's bounds
Class Box.AccessibleBox, void setEnabled(boolean)SetsSet the Cursor of this object. @paramcursorc the new Cursor for the objectnull if none
Class Box.AccessibleBox, void setFont(Font)SetsSet the enabled state of the object. @param b if true enables this object; otherwise disables it
Class Box.AccessibleBox, void setForeground(Color)SetsSet the Font of this object. @param f the new Font for the objectnull if none
Class Box.AccessibleBox, void setLocation(Point)SetsSet the foreground color of this object. @param c the new Color for the foregroundnull if none
Sets the location of the object relative to the parent.Class Box.AccessibleBox, void setSize(Dimension)@param p the location to be set
Resizes this object so that it has width width and height. @param d - The dimension specifying the new size of the object.Class Box.AccessibleBox, void setVisible(boolean)
SetsSet the visible state of the object. @param b if true shows this object; otherwise hides it
Adds the specified focus listener to receive focus events from this component. @param l the focus listenerClass Box.Filler.AccessibleBoxFiller, Accessible getAccessibleChild(int)
Class Box.Filler.AccessibleBoxFiller, int getAccessibleChildrenCount()ReturnsReturn the nth Accessible child of the object. @param i zero-based index of child @return the nth Accessible child of the objectnull if none
Returns the number of accessible children in the object. If all of the children of this object implement AccessibleClass Box.Filler.AccessibleBoxFiller, AccessibleComponent getAccessibleComponent()thenthan this method should return the number of children of this object. @return the number of accessible children in the object= 0.
Class Box.Filler.AccessibleBoxFiller, int getAccessibleIndexInParent()GetsGet the AccessibleComponent associated with this object if one exists. Otherwise return null. @return the component
Class Box.Filler.AccessibleBoxFiller, Accessible getAccessibleParent()GetsGet the index of this object in its accessible parent. @return the index of this object in its parent= 0; -1 if this object does not have an accessible parent. @see #getAccessibleParent
Get the Accessible parent of this object. If the parent of this object implements Accessible this method should simply return getParent(). @return the Accessible parent of this objectClass Box.Filler.AccessibleBoxFiller, AccessibleStateSet getAccessibleStateSet();-- can be null if this object does not have an Accessible parent
Class Box.Filler.AccessibleBoxFiller, Color getBackground()GetsGet the state of this object. @return an instance of AccessibleStateSet containing the current state set of the object @see AccessibleState
Class Box.Filler.AccessibleBoxFiller, Cursor getCursor()GetsGet the background color of this object. @return the background color if supported of the object; otherwise null
Class Box.Filler.AccessibleBoxFiller, Font getFont()GetsGet the Cursor of this object. @return the Cursor if supported of the object; otherwise null
Class Box.Filler.AccessibleBoxFiller, FontMetrics getFontMetrics(Font)GetsGet the Font of this object. @return the Font if supported for the object; otherwise null
Class Box.Filler.AccessibleBoxFiller, Color getForeground()GetsGet the FontMetrics of this object. @param f the Fontnull if none@return the FontMetrics if supported the object; otherwise null @see #getFont
Class Box.Filler.AccessibleBoxFiller, Locale getLocale()GetsGet the foreground color of this object. @return the foreground color if supported of the object; otherwise null
Class Box.Filler.AccessibleBoxFiller, Point getLocationOnScreen()ReturnsReturn the locale of this object. @return the locale of this object
Returns the location of the object on the screen. @return location of object on screenClass Box.Filler.AccessibleBoxFiller, boolean isEnabled();-- can be null if this object is not on the screen
Class Box.Filler.AccessibleBoxFiller, boolean isShowing()DeterminesDetermine if the object is enabled. @return true if object is enabled; otherwise false
Class Box.Filler.AccessibleBoxFiller, boolean isVisible()DeterminesDetermine if the object is showing. This is determined by checking the visibility of the object and ancestors of the object. Note: this will return true even if the object is obscured by another (for example it happens to be underneath a menu that was pulled down). @return true if object is showing; otherwise false
Class Box.Filler.AccessibleBoxFiller, void removeFocusListener(FocusListener)DeterminesDetermine if the object is visible. Note: this means that the object intends to be visible; however it may not in fact be showing on the screen because one of the objects that this object is contained by is not visible. To determine if an object is showing on the screen use isShowing(). @return true if object is visible; otherwise false
Removes the specified focus listener so it no longer receives focus events from this component. @param l the focus listenerClass Box.Filler.AccessibleBoxFiller, void setBackground(Color)
Class Box.Filler.AccessibleBoxFiller, void setBounds(Rectangle)SetsSet the background color of this object. (For transparency seeisOpaque
.) @param c the new Color for the backgroundnull if none@s JComponentsee Component#isOpaque
Sets the bounds of this object in the form of a Rectangle object. The bounds specify this object's width height and location relative to its parent. @paramClass Box.Filler.AccessibleBoxFiller, void setCursor(Cursor)rAarectangle indicating this component's bounds
Set the Cursor of this object. @paramClass Box.Filler.AccessibleBoxFiller, void setEnabled(boolean)cursorc the new Cursor for the objectnull if none
Class Box.Filler.AccessibleBoxFiller, void setFont(Font)SetsSet the enabled state of the object. @param b if true enables this object; otherwise disables it
Class Box.Filler.AccessibleBoxFiller, void setForeground(Color)SetsSet the Font of this object. @param f the new Font for the objectnull if none
Class Box.Filler.AccessibleBoxFiller, void setLocation(Point)SetsSet the foreground color of this object. @param c the new Color for the foregroundnull if none
Sets the location of the object relative to the parent.Class Box.Filler.AccessibleBoxFiller, void setSize(Dimension)@param p the location to be set
Resizes this object so that it has width width and height. @param d - The dimension specifying the new size of the object.Class Box.Filler.AccessibleBoxFiller, void setVisible(boolean)
SetsSet the visible state of the object. @param b if true shows this object; otherwise hides it
Gets the AccessibleContext associated with thisComponentBox.Filler. For box fillers the AccessibleContext takes the form of anCreatesAccessibleBoxFiller.aA newcontextAccessibleAWTBoxFiller instance is created if necessary. @return an AccessibleBoxFiller that serves as the AccessibleContext of thisComponentBox.Filler.
GetGets the AccessibleContext associated with thisJComponentBox.Creates aFor boxes the AccessibleContext takes the form of an AccessibleBox. A newcontextAccessibleAWTBox instance is created if necessary. @return an AccessibleBox that serves as the AccessibleContext of thisJComponentBox
A layout manager that allows multiple components to be layed out either vertically or horizontally. The components will not wrap so for example a vertical arrangement of components will stay vertically arranged when the frame is resized.Class BoxLayout, int Y_AXIS
![]()
Nesting multiple panels with different combinations of horizontal and vertical gives an effect similar to GridBagLayout without the complexity. The diagram shows two panels arranged horizontally each of which contains 3 components arranged vertically.
The Box container uses BoxLayout (unlike JPanel which defaults to flow layout). You can nest multiple boxes and add components to them to get the arrangement you want.
The BoxLayout manager that places each of its managed components from left to right or from top to bottom. When you create a BoxLayout you specify whether its major axis is the X axis (which means left to right placement) or Y axis (top to bottom placement). Components are arranged from left to right (or top to bottom) in the same order as they were added to the container.
Instead of using BoxLayout directly many programs use the Box class. The Box class provides a lightweight container that uses a BoxLayout. Box also provides handy methods to help you use BoxLayout well.
BoxLayout attempts to arrange components at their preferred widths (for left to right layout) or heights (for top to bottom layout). For a left to right layout if not all the components are the same height BoxLayout attempts to make all the components as high as the highest component. If that's not possible for a particular component then BoxLayout aligns that component vertically according to the component's Y alignment. By default a component has an Y alignment of 0.5 which means that the vertical center of the component should have the same Y coordinate as the vertical centers of other components with 0.5 Y alignment.
Similarly for a vertical layout BoxLayout attempts to make all components in the column as wide as the widest component; if that fails it aligns them horizontally according to their X alignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see Box @see Component#getAlignmentX @see Component#getAlignmentY @author Timothy Prinzing @version 1.
20 1024 02/2002/9800
Specifies that components should be laid out top tobuttombottom.
This class is used to create a multiple-exclusion scope for a set of buttons. Creating a set of buttons with the sameButtonGroup
object means that turning "on" one of those buttons turns off all other buttons in the group.A
ButtonGroup
can be used withsetsany set ofJButtonobjects that inherit fromAbstractButton
. Typically a button group contains instances ofJRadioButton
JRadioButtonMenuItem
orJRadioButtonMenuItemJToggleButton
.objectsIt wouldn't make sense to put an instance ofJButton
orJMenuItem
in a button group becauseJButton
andJMenuItem
don't implement the selected state.Initially all buttons in the group are unselected. Once any button is selected one button is always selected in the group. There is no way to turn a button programmatically to "off" in order to clear the button group. To give the appearance of "none selected" add an invisible radio button to the group and then programmatically select that button to turn off all the displayed radio buttons. For example a normal button with the label "none" could be wired to select the invisible radio button.
For examples and further information on using button groups see How to Use Radio Buttons a section in The Java Tutorial.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
22 0827 02/2802/9800 @author Jeff Dinkins
State Model for buttons. This model is used forClass ButtonModel, boolean isEnabled()checkboxescheck boxes andradiobuttonsradio buttons which are special kinds of buttons as well as for normal buttons. Forcheckboxescheck boxes andradiobuttonsradio buttons pressing the mouse selects the button. For normal buttons pressing the mouse "arms" the button. Releasing the mouse over the button then initiates a button press firing its action event. Releasing the mouse elsewhere disarms the button.In use a UI will invoke #setSelected
()when a mouse click occurs over acheckboxcheck box orradiobuttonradio button. It will invoke #setArmed when the mouse is pressed over a regular button and invoke #setPressed when the mouse is released. If the mouse travels outside the button in the meantimesetArmed(false)
will tell the button not to fire when it seessetPressed
. (If the mouse travels back in the button will be rearmed.)Note:@version 1.
A button is triggered when it is both "armed" and "pressed".20 0823 02/2602/9800 @author Jeff Dinkins
Indicates if the button can be selected or pressed by an input device (such as a mouse pointer). (Class ButtonModel, boolean isSelected()Checkbox-buttonsCheck boxes are selected regular buttons are "pressed".) @return true if the button is enabled and therefore selectable (or pressable)
Indicates if the button has been selected. Only needed for certain types of buttons - such asRadioButtonradioorbuttons and checkCheckboxboxes. @return true if the button is selected
This interface defines the methods any general editor should be able to implement.Class CellEditor, boolean shouldSelectCell(EventObject)Having this interface enables complex components (the client of the editor) such as JList JTree and JTable to allow any generic editor to edit values in a table cell or tree cell etc. Without this generic editor interface JTable would have to know about specific editors such as JTextField JCheckBox JComboBox etc. In addition without this interface clients of editors such as JTable would not be able to work with any editors developed in the future by the user or a 3rd party ISV.
To use this interface a developer creating a new editor can have the new component implement the interface. Or the developer can choose a wrapper based approch and provide a companion object which implements the CellEditor interface (See JCellEditor for example). The wrapper approch is particularly useful if the user want to use a 3rd party ISV editor with JTable but the ISV didn't implement the CellEditor interface. The user can simply create an object that contains an instance of the 3rd party editor object and "translate" the CellEditor API into the 3rd party editor's API. @see javax.swing.event.CellEditorListener @version 1.
16 0819 02/2602/9800 @author Alan Chung
Tell the editor to start editing using anEvent. It is up to the editor if it want to start editing in different states depending on the exact type of anEvent. For example with a text field editor if the event is a mouse event the editor might start editing with the cursor at the clicked point. If the event is a keyboard event it might want replace the value of the text field with that first key etc. anEvent is in the invoking component's coordinate system. A null value is a valid parameter for anEvent and it is up to the editor to determine what is the default starting state. For example a text field editor might want to select all the text and start editing if anEvent is null. The editor can assume the Component returned by getCellEditorComponent() is properly installed in the clients Component hierarchy before this method is called.The return value of shouldSelectCell() is a boolean indicating whether the editing cell should be selected or not. Typically the return value is true because is most cases the editing cell should be selected. However it is useful to return false to keep the selection from changing for some types of edits. eg. A table that contains a column of check boxes the user might want to be able to change those checkboxes without altering the selection. (See Netscape Communicator for just such an example) Of course it is up to the client of the editor to use the return value but it doesn't need to if it doesn't want to. @param anEvent the event the editor should use to start editing. @return true if the editor would like the editing cell to be selected @see #isCellEditable
This class is inserted in between cell renderers and the components that use them. It just exists to thwart the repaint() and invalidate() methods which would otherwise propogate up the tree when the renderer was configured. It's used by the implementations of JTable JTree and JList. For example here's how CellRendererPane is used in the code the paints each row in a JList:cellRendererPane = new CellRendererPane(); ... Component rendererComponent = renderer.getListCellRendererComponent(); renderer.configureListCellRenderer(dataModel.getElementAt(row) row); cellRendererPane.paintComponent(g rendererComponent this x y w h);A renderer component must override isShowing() and unconditionally return true to work correctly because the Swing paint does nothing for components with isShowing false.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
28 0932 03/0114/9800 @author Hans Muller
Get the AccessibleComponent associated with this object if one exists. Otherwise return null. @return the componentClass CellRendererPane.AccessibleCellRendererPane, void setBackground(Color)
Set the background color of this object. (For transparency see isOpaque
.) @param c the new Color for the background @see Component#isOpaque
GetGets the AccessibleContext associated with this CellRendererPane. For CellRendererPanes the AccessibleContext takes the form of an AccessibleCellRendererPane. A new AccessibleCellRendererPane instance is created if necessary. @return an AccessibleCellRendererPane that serves as the AccessibleContext of this CellRendererPane
The editor component used for JComboBox components. @version 1.8 0810 02/2602/9800 @author Arnaud Weber
Graphics subclass supporting graphics debugging. Overrides most methods from Graphics. DebugGraphics objects are rarely created by hand. They are most frequently created automatically when a JComponent's debugGraphicsOptions are changed using the setDebugGraphicsOptions() method.NOTE: You must turn off double buffering to use DebugGraphics: RepaintManager repaintManager = RepaintManager.currentManager(component); repaintManager.setDoubleBufferingEnabled(false); @see JComponent#setDebugGraphicsOptions @see RepaintManager#currentManager @see RepaintManager#setDoubleBufferingEnabled @version 1.
17 1019 02/2002/9800 @author Dave Karlton
A generic implementation of BoundedRangeModel.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
32 1035 02/2602/9800 @author David Kloba @author Hans Muller @see BoundedRangeModel
The default implementation of a Button component's data model.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
26 0832 02/2802/9800 @author Jeff Dinkins
The default editor for table and tree cells.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
36 0338 02/0802/00 @authorPhilip MilneAlan Chung @authorAlanPhilipChungMilne
The default model for combo boxes. @version 1.6 0911 02/0102/9800 @author Arnaud Weber @author Tom Santos
This is an implementaion of the DesktopManager. It currently implements a the basic behaviors for managing JInternalFrames in an arbitrary parent. JInternalFrames that are not children of a JDesktop will use this component to handle their desktop-like actions. @see JDesktopPane @see JInternalFrame @version 1.Class DefaultDesktopManager, void closeFrame(JInternalFrame)24 0441 02/2202/9900 @author David Kloba @author Steve Wilson
Removes the frame and if necessary the desktopIcon fromClass DefaultDesktopManager, void deiconifyFrame(JInternalFrame)it'sits parent.
Removes the desktopIcon fromClass DefaultDesktopManager, void iconifyFrame(JInternalFrame)it'sits parent and addsit'sits frame to the parent.
Removes the frame fromClass DefaultDesktopManager, void maximizeFrame(JInternalFrame)it'sits parent and addsit'sits desktopIcon to the parent.
Resizes the frame to fillClass DefaultDesktopManager, void minimizeFrame(JInternalFrame)it'sits parents bounds.
Restores the frame back toClass DefaultDesktopManager, void openFrame(JInternalFrame)it'sits size and position prior to a maximizeFrame() call.
Normally this method will not be called. If it is it try to determine the appropriate parent from the desktopIcon of the frame. Will remove the desktopIcon fromit'sits parent if it successfully adds the frame.
Default swing focus manager implementation. @version 1.14 0415 07/2213/99 @author Arnaud Weber
Renders an item in a list.Class DefaultListCellRenderer, void revalidate()Implementation Note: This class overrides
validate
revalidate
repaint
andfirePropertyChange
solely to improve performance. If not overridden these frequently called methods would execute code paths that are unnecessary for the default list cell renderer. If you write your own renderer take care to weigh the benefits and drawbacks of overriding these methods.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
12 0417 02/2202/9900 @author Philip Milne @author Hans Muller
Class DefaultListCellRenderer, void validate()SupportOverridden fordeferredperformanceautomatic layout. Calls invalidate() and then adds this components validateRoot to a list of components that need to be validated. Validation will occur after all currently pending events have been dispatched. In other words after this method is called the first validateRoot (if any) found when walking up the containment hierarchy of this component will be validated. By default JRootPane JScrollPane and JTextField return true from isValidateRoot(). This method will automatically be called on this component when a property value changes such that size location or internal layout of this component has been affectedreasons.ThisSeeautomatic updating differs from the AWT because programs generally no longer need to invoke validate() to get the contents oftheGUI to update.Implementation@seeNotejava.awt.Component#invalidatefor@seemorejava.awtinformation.Container#validate @see #isValidateRoot @see RepaintManager#addInvalidComponent
Validates this containerOverridden for performanceand all of its subcomponentsreasons.AWT uses validate to cause a container to laySeeout its subcomponents again afterthecomponents it containsImplementationhaveNotebeen addedfor moreto or modifiedinformation.@see #validate @see Component#invalidate
This class implements the java.util.Vector API and notifies the ListDataListeners when changes occur. Presently it delegates to a Vector in a future release it will be a real Collection implementation.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
21 1026 02/0602/9800 @author Hans Muller
Default data model for list selections.Class DefaultListSelectionModel, Object clone()Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
52 0455 02/2202/9900 @author Philip Milne @author Hans Muller @see ListSelectionModel
Returns a clone ofClass DefaultListSelectionModel, void fireValueChanged(boolean)thethis selectionrecievermodel with the same selection.listenerLists
are not duplicated. @exception CloneNotSupportedException if thereceiverselection model does not both (a) implement the Cloneable interface and (b) define aclone
method.
Class DefaultListSelectionModel, void fireValueChanged(int, int)NotifyNotifies listeners that we have ended a series of adjustments.
Class DefaultListSelectionModel, void fireValueChanged(int, int, boolean)NotifyNotifiesListSelectionListeners
that the value of the selection in the closed intervalfirstIndex
lastIndex
has changed.
@param firstIndexClass DefaultListSelectionModel, boolean isLeadAnchorNotificationEnabled()Thethe first index in the interval.@paramindex1 ThelastIndex the last index in the interval.@param isAdjustingTruetrue if this is the final change in a series ofthem.adjustments @see EventListenerList
Returns the value of theClass DefaultListSelectionModel, void setLeadSelectionIndex(int)leadAnchorNotificationEnabled
flag. WhenleadAnchorNotificationEnabled
is true the model generates notification events with bounds that cover all the changes to the selection plus the changes to the lead and anchor indices. Setting the flag to false causes anorrowingnarrowing of the event's bounds to include only the elements that have been selected or deselected since the last change. Either way the model continues to maintain the lead and anchor variables internally. The default is true. @return the value of theleadAnchorNotificationEnabled
flag @see #setLeadAnchorNotificationEnabled(boolean)
Class DefaultListSelectionModel, String toString()SetSets the lead selection index ensuring that values between the anchor and the new lead are either all selected or all deselected. If the value at the anchor index is selected first clear all the values in the range [anchor oldLeadIndex] then select all the values values in the range [anchor newLeadIndex] where oldLeadIndex is the old leadIndex and newLeadIndex is the new one.If the value at the anchor index is not selected do the same thing in reverse selecting values in the old range and deslecting values in the new one.
Generate a single event for this change and notify all listeners. For the purposes of generating minimal bounds in this event do the operation in a single pass; that way the first and last index inside the ListSelectionEvent that is broadcast will refer to cells that actually changed value because of this method. If instead this operation were done in two steps the effect on the selection state would be the same but two events would be generated and the bounds around the changed values would be wider including cells that had been first cleared only to later be set.
This method can be used in the
mouseDragged
method of a UI class to extend a selection. @see #getLeadSelectionIndex @see #setAnchorSelectionIndex()
Returns a string that displays and identifies this object's properties. @return a String
representation of this object
A generic implementation of SingleSelectionModel.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
22 0925 02/0102/9800 @author Dave Moore
DesktopManager objects are owned by a JDesktopPane object. They are responsible for implementing L&F specific behaviors for the JDesktopPane. JInternalFrame implementations should delegate specific behaviors to the DesktopManager. For instance if a JInternalFrame was asked to iconify it should try:getDesktopPane().getDesktopManager().iconifyFrame(frame);This delegation allows each L&F to provide custom behaviors for desktop-specific actions. (For example how and where the internal frame's icon would appear.) @see JDesktopPane @see JInternalFrame @see JInternalFrame.JDesktopIcon @version 1.8 0810 02/2602/9800 @author David Kloba
Swing Focus Manager @version 1.9 0811 02/2602/9800 @author Arnaud Weber
An image filter that "disables" an image by turning it into a grayscale image and brightening the pixels in the image. Used by buttons to create an image for a disabled button. @author Jeff Dinkins @author Tom Ball @author Jim Graham @version 1.10 0812 02/2602/9800
An implementation of the Icon interface that paints Icons from Images. Images that are created from a URL or filename are preloaded using MediaTracker to monitor the loaded state of the image.Class ImageIcon, constructor ImageIcon(Image)For further information and examples of using image icons see How to Use Icons in The Java Tutorial.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
33 0845 03/2815/9800 @author Jeff Dinkins @author Lynn Monsanto
Creates an ImageIcon from an image object. If the image has a "comment" property that is a string then the string is used as the description of this icon. @param image the image @see #getDescription @see java.awt.Image#getPropertyClass ImageIcon, constructor ImageIcon(String)
Creates an ImageIcon from the specified file. The image will be preloaded by using MediaTracker to monitor the loading state of the image. The specified String can be a file name or a file path. When specifying a path use the Internet-standard forward-slash ("/") as a separator. (The string is converted to an URL so the forward-slash works on all systems.) For example specify:Class ImageIcon, constructor ImageIcon(URL)new ImageIcon("images/myImage.gif")(Thestringdescription isconvertedinitialized toan URL sotheforward-slash works on allfilename
systemsstring.)@param filename a String specifying a filename or path @see #getDescription
Creates an ImageIcon from the specified URL. The image will be preloaded by using MediaTracker to monitor the loaded state of the image. The icon's description is initialized to be a string representation of the URL. @param location the URL for the image @see #getDescriptionClass ImageIcon, constructor ImageIcon(URL, String)
Creates an ImageIcon from the specified URL. The image will be preloaded by using MediaTracker to monitor the loaded state of the image. @paramClass ImageIcon, constructor ImageIcon(byte[])URLlocation the URL for the image @param description a brief textual description of the image @see #ImageIcon(String)
Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format such as GIF or JPEG. Normally this array is created by reading an image using Class.getResourceAsStream() but the byte array may also be statically stored in a class. If the resulting image has a "comment" property that is a string then the string is used as the description of this icon. @param imageData an array of pixels in an image format supported by the AWT Toolkit such as GIF or JPEGClass ImageIcon, String getDescription().@see java.awt.Toolkit#createImage @see #getDescription @see java.awt.Image#getProperty
Class ImageIcon, int getIconHeight()GetGets the description of the image. This is meant to be a brief textual description of the object. For example it might be presented to a blind user to give an indication of the purpose of the image. The description may be null. @return a brief textual description of the image
Class ImageIcon, int getIconWidth()GetGets the height of theIconicon. @return the height in pixels of this icon
Class ImageIcon, Image getImage()GetGets the width of theIconicon. @return the width in pixels of this icon
ReturnsClass ImageIcon, int getImageLoadStatus()the Iconthis icon'sImage
. @return theImage
object for thisImageIcon
Returns the status of the image loading operation. @return the loading status as defined by java.awt.MediaTrackerClass ImageIcon, ImageObserver getImageObserver().@see java.awt.MediaTracker#ABORTED @see java.awt.MediaTracker#ERRORED @see java.awt.MediaTracker#COMPLETE
Class ImageIcon, void loadImage(Image)ReturnReturns theumageimage observer for the image. @return the image observer which may be null
Class ImageIcon, void paintIcon(Component, Graphics, int, int)WaitLoadsforthe image returning only when the imagetois loaded. @param image theloadimage
Paints theClass ImageIcon, void setDescription(String)Iconicon. The top-left corner of the icon is drawn at the point (x
y
) in the coordinate space of the graphics contextg
. If this icon has no image observer this method uses thec
component as the observer. @param c the component to be used as the observer if this icon has no image observer @param g the graphics context @param x the X coordinate of the icon's top-left corner @param y the Y coordinate of the icon's top-left corner
Class ImageIcon, void setImage(Image)SetSets the description of the image. This is meant to be a brief textual description of the object. For example it might be presented to a blind user to give an indication of the purpose of the image. @param description a brief textual description of the image
Class ImageIcon, void setImageObserver(ImageObserver)SetSets the image displayed by this icon. @param image the image
Class ImageIcon, String toString()SetSets the image observer for the image. Set this property if the ImageIcon contains an animated GIF so the observer is notified to update its display. For example:icon = new ImageIcon(...) button.setIcon(icon); icon.setImageObserver(button);@param observer the image observer
Returns a string representation ofthe object. In general the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommendedthat all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance the at-sign character `@' and the unsigned hexadecimal representation of the hash code of the object. In other wordsthismethod returns a string equal to the value of: getClass().getName() + '@' + Integerimage.toHexString(hashCode())@return a stringrepresentation ofrepresentingthethisobject.image
An extended version of java.applet.Applet that adds support forinterposing input and painting behavior in fronttheofJFC/Swingthecomponentappletsarchitecture.childrenYou(seecanglassPane)findsupporttask-orientedfor special childrendocumentation about usingthatJApplet
areinmanagedThebyJavaaTutorialLayeredPanein(seetherootPane)sectionandHowfor Swingto MakeMenuBarsApplets.The JApplet class is slightly incompatible with java.applet.Applet. JApplet contains a JRootPane as it's only child. The contentPane should be the parent of any children of the JApplet. This is different than java.applet.Applet e.g. to add a child to an an java.applet.Applet you'd write:
applet.add(child);However using JApplet you need to add the child to the JApplet's contentPane instead:applet.getContentPane().add(child);The same is true for setting LayoutManagers removing components listing children etc. All these methods should normally be sent to the contentPane() instead of the JApplet itself. The contentPane() will always be non-null. Attempting to set it to null will cause the JApplet to throw an exception. The default contentPane() will have a BorderLayout manager set on it.Please see the JRootPane documentation for a complete description of the contentPane glassPane and layeredPane properties.
For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JApplet key assignments.
Both Netscape Communicator and Internet Explorer 4.0 unconditionally print an error message to the Java console when an applet attempts to access the AWT system event queue. Swing applets do this once to check if access is permitted. To prevent the warning message in a production applet one can set a client property called "defeatSystemEventQueueCheck" on the JApplets RootPane to any non null value e.g: JRootPane rp = myJApplet.getRootPane(); rp.putClientProperty("defeatSystemEventQueueCheck" Boolean.TRUE); We hope that future versions of the browsers will not have this limitation and we'll be able to retire this hack.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer true attribute: containerDelegate getContentPane description: Swing's Applet subclass. @version 1.38 0442 03/2214/9900 @author Arnaud Weber
Get the AccessibleComponent associated with this object if one exists. Otherwise return null. @return the componentClass JApplet.AccessibleJApplet, AccessibleRole getAccessibleRole()
Get the role of this object. @return an instance of AccessibleRole describing the role of the objectClass JApplet.AccessibleJApplet, void setBackground(Color)@see AccessibleRole
Set the background color of this object. (For transparency see isOpaque
.) @param c the new Color for the background @see Component#isOpaque
GetGets the AccessibleContext associated with this JApplet. For JApplets the AccessibleContext takes the form of an AccessibleJApplet. A new AccessibleJApplet instance is created if necessary. @return an AccessibleJApplet that serves as the AccessibleContext of this JApplet
An implementation of a "push" button.To create a set of mutually exclusive buttons create a ButtonGroup object and use its addSeemethodHow toinclude the JButton objects in the group.UseSeeButtons CheckHowBoxesto Useand Radio Buttons in The Java Tutorial forfurtherinformation and examples of usingdocumentationbuttons.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JButton key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: An implementation of a \"push\" button. @version 1.
73 0983 03/0114/9800 @author Jeff Dinkins@see ButtonGroup
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJButton
class.role forIt providesthisan implementation of the Java Accessibility API appropriate to button user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Class JButton, void removeNotify()GetGets the AccessibleContext associated with thisJComponentJButton. For JButtons the AccessibleContext takes the form of an AccessibleJButton. A new AccessibleJButton instance is created if necessary. @return an AccessibleJButton that serves as the AccessibleContext of thisJComponentJButton @beaninfo expert: true description: The AccessibleContext associated with this Button.
NotificationOverridesJComponent.removeNotify
to check if thiscomponent that it no longer has a parentbutton is currently set as the default buttoncomponent.onWhen this method is invoked any KeyboardActionsthe RootPane and if so sets thesetRootPane'sup indefault buttontheto null to ensure thechainRootPaneofdoesn'tparent components arehold onto anremoved.invalid@seebutton#registerKeyboardActionreference.
An implementation of aCheckBoxcheck box -- an item that can be selected or deselected and which displays its state to the user.In a groupBy convention any number ofcheckboxescheck boxes inmultiple checkboxesa group can be selected. See How to UseCheckBoxesButtonc Check Boxes and Radio Buttons in The Java Tutorial forfurtherexamples and information on usingdocumentationcheck boxes.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JCheckBox key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JRadioButton @beaninfo attribute: isContainer false description: A component which can be selected or deselected. @version 1.
46 0958 03/0114/9800 @author Jeff Dinkins
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJCheckBox
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to check box user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Creates an initially unselectedClass JCheckBox, constructor JCheckBox(Icon)checkboxcheck box button with no text no icon.
Creates an initially unselectedClass JCheckBox, constructor JCheckBox(Icon, boolean)checkboxcheck box with an icon. @param icon the Icon image to display
Creates aClass JCheckBox, constructor JCheckBox(String)checkboxcheck box with an icon and specifies whether or not it is initially selected. @param icon the Icon image to display @param selected a boolean value indicating the initial selection state. Iftrue
thecheckboxcheck box is selected
Creates an initially unselectedClass JCheckBox, constructor JCheckBox(String, Icon)checkboxcheck box with text. @param text the text of thecheckboxcheck box.
Creates an initially unselectedClass JCheckBox, constructor JCheckBox(String, Icon, boolean)checkboxcheck box with the specified text and icon. @param text the text of thecheckboxcheck box. @param icon the Icon image to display
Creates aClass JCheckBox, constructor JCheckBox(String, boolean)checkboxcheck box with text and icon and specifies whether or not it is initially selected. @param text the text of thecheckboxcheck box. @param icon the Icon image to display @param selected a boolean value indicating the initial selection state. Iftrue
thecheckboxcheck box is selected
Creates aClass JCheckBox, AccessibleContext getAccessibleContext()checkboxcheck box with text and specifies whether or not it is initially selected. @param text the text of thecheckboxcheck box. @param selected a boolean value indicating the initial selection state. Iftrue
thecheckboxcheck box is selected
GetGets the AccessibleContext associated with thisJComponentJCheckBox. For JCheckBoxes the AccessibleContext takes the form of an AccessibleJCheckBox. A new AccessibleJCheckBox instance is created if necessary. @return an AccessibleJCheckBox that serves as the AccessibleContext of thisJComponentJCheckBox @beaninfo expert: true description: The AccessibleContext associated with this CheckBox.
A menu item that can be selected or deselected. If selected the menu item typically appears with a checkmark next to it. If unselected or deselected the menu item appears without a checkmark. Like a regular menu item acheckboxcheck box menu item can have either text or a graphic icon associated with it or both.Either
isSelected
/setSelected
orgetState
/setState
can be used to determine/specify the menu item's selection state.(TheSwing-standardpreferred methods areisSelected
andsetSelected
. Thesemethodswhich work for all menus and buttons. ThegetState
andsetState
methods exist for compatibility with other component sets.)For further information and examples of using check box menu items see How to Use Menus a section in The Java Tutorial. For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JCheckBoxMenuItem key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A menu item which can be selected or deselected. @version 1.
40 1147 03/0214/9800 @author Georges Saab @author David Karlton
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJCheckBoxMenuItem
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to checkbox menu item user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Creates an initially unselectedClass JCheckBoxMenuItem, constructor JCheckBoxMenuItem(Icon)checkboxMenuItemcheck box menu item with no set text or icon.
Creates an initially unselectedClass JCheckBoxMenuItem, constructor JCheckBoxMenuItem(String)checkboxMenuItemcheck box menu item with an icon. @param icon the icon of the CheckBoxMenuItem.
Creates an initially unselectedClass JCheckBoxMenuItem, constructor JCheckBoxMenuItem(String, Icon)checkboxMenuItemcheck box menu item with text. @param text the text of the CheckBoxMenuItem
Creates an initially unselectedClass JCheckBoxMenuItem, constructor JCheckBoxMenuItem(String, Icon, boolean)checkboxMenuItemcheck box menu item with the specified text and icon. @param text the text of the CheckBoxMenuItem @param icon the icon of the CheckBoxMenuItem
Creates aClass JCheckBoxMenuItem, constructor JCheckBoxMenuItem(String, boolean)checkboxMenuItemcheck box menu item with the specified text icon and selection state. @param text the text of theCheckBoxMenuItemcheck box menu item @param icon the icon of theCheckBoxMenuItemcheck box menu item @param b the selected state of thecheckboxmenuitemcheck box menu item
Creates aClass JCheckBoxMenuItem, AccessibleContext getAccessibleContext()checkboxMenuItemcheck box menu item with the specified text and selection state. @param text the text of theCheckBoxMenuItemcheck box menu item. @param b the selected state of thecheckboxmenuitemcheck box menu item
Class JCheckBoxMenuItem, Object[] getSelectedObjects()GetGets the AccessibleContext associated with thisJComponentJCheckBoxMenuItem. For JCheckBoxMenuItems the AccessibleContext takes the form of an AccessibleJCheckBoxMenuItem. A new AccessibleJCheckBoxMenuItem instance is created if necessary. @return an AccessibleJCheckBoxMenuItem that serves as the AccessibleContext of thisJComponentAccessibleJCheckBoxMenuItem
Returns an array (length 1) containing theClass JCheckBoxMenuItem, void setState(boolean)checkboxcheck box menu item label or null if thecheckboxcheck box is not selected. @return an array containing1one Object -- the text of the menu item -- if the item is selected; otherwise null
Sets the selected-state of the item. This method exists for AWT compatibility only. New code should use setSelected() instead. @param b a boolean value indicating the item's selected-state where true=selected @beaninfo description: The selection state of theCheckboxcheck box menu item hidden: true
JColorChooser
provides a pane of controls designed to allow a user to manipulate and select a color. For information about using color choosers see How to Use Color Choosers a section in The Java Tutorial.This class provides
3three levels of API:
- A static convenience method which shows a modal color-chooser dialog and returns the color selected by the user.
- A static convenience method for creating a color-chooser dialog where
ActionListeners
can be specified to be invoked when the user presses one of the dialog buttons.- The ability to create instances of
JColorChooser
panes directly (within any container).PropertyChange
listeners can be added to detect when the current "color" property changes.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.@beaninfo attribute: isContainer false description: A component that supports selecting a Color. @version 1.22 0929 03/0114/9800 @author James Gosling @author Amy Fowler @author Steve Wilson
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJColorChooser
class. Itcontextprovidesforan implementation of the Java Accessibility API appropriate to color chooserthisuser-interfaceobjectelements.
Creates a color chooser pane with the specified ColorSelectionModel
. @param initialColor the initial color set in the chooser
Class JColorChooser, JDialog createDialog(Component, String, boolean, JColorChooser, ActionListener, ActionListener)Creates and returns a new dialog containing the specifiedClass JColorChooser, AccessibleContext getAccessibleContext()ColorChooser
` pane along with "OK" "Cancel" and "Reset" buttons. If the "OK" or "Cancel" buttons are pressed the dialog is automatically hidden (but not disposed). If the "Reset" button is pressed the color-chooser's color will be reset to the color which was set the last timeshow
was invoked on the dialog and the dialog will remain showing. @param c the parent component for the dialog @param title the title for the dialog @param modal a boolean. When true the remainder of the program is inactive until the dialog is closed. @param chooserPane the color-chooser to be placed inside the dialog @param okListener the ActionListener invoked when "OK" is pressed @param cancelListener the ActionListener invoked when "Cancel" is pressed()
Class JColorChooser, String getUIClassID()GetGets the AccessibleContext associated with this JColorChooser. For color choosers the AccessibleContext takes the form of an AccessibleJColorChooser. A new AccessibleJColorChooser instance is created if necessary. @return an AccessibleJColorChooser that serves as the AccessibleContext of this JColorChooser
Returns the name of the L&F class that renders this component. @return the string "ColorChooserUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JColorChooser, String paramString()
Returns a string representation of thisClass JColorChooser, AbstractColorChooserPanel removeChooserPanel(AbstractColorChooserPanel)JColorChooser
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJColorChooser
.
Removes the Color Panel specified. @exception IllegalArgumentException if panel is not in list of known chooser panels @param name a string that specifies the panel to be removed @return the color panelClass JColorChooser, void setColor(Color)
Sets the current color of the color chooser to the specified color. This will fire a PropertyChangeEvent
for the property named "color". @param color the color to be set in the color chooser @see JComponent#addPropertyChangeListener @beaninfo bound: false hidden: false description: The current color the chooser is to display.
Class JColorChooser, void setColor(int, int, int)Sets the current color of the color chooser to the specified RGB color. Note that the values of red green and blue should be between the numbers 0 and 255 inclusive. @param r an int specifying the amount of Red @param g an int specifying the amount of Green @param b an int specifying the amount of Blue @exception IllegalArgumentException if r g b values are out of range @see java.awt.ColorClass JColorChooser, void setPreviewPanel(JComponent)
Sets the current preview panel. This will fire a PropertyChangeEvent
for the property named "previewPanel". @param color the color to be set in the color chooser @see JComponent#addPropertyChangeListener @beaninfo bound: true hidden: true description: The UI component which displays the current color.
Class JColorChooser, Color showDialog(Component, String, Color)Shows a modal color-chooser dialog and blocks until the dialog is hidden. If the user presses the "OK" button then this method hides/disposes the dialog and returns the selected color. If the user presses the "Cancel" button or closes the dialog without pressing "OK" then this method hides/disposes the dialog and returnsClass JColorChooser, void updateUI()null
. @param component the parentComponent
for the dialog @param title the String containing the dialog's title @param initialColor the initial Color set when the color-chooser is shown
Notification from theUIManager
that the L&F has changed. Replaces the current UI object with the latest version from theUIManager
. @see JComponent#updateUI
Swing'sAimplementation ofcomponent that combines aComboBoxbutton--or text field and acombinationdrop-downoflist. The user can select atext field andvalue from the drop-down listthatwhichletsappears at the user'seitherrequest.type in a value or select it from a list thatIf you make the combo box editable then the combo boxisincludes a text fielddisplayed wheninto which the useraskscanfortype aitvalue.TheForediting capability can also be disabled so thatexamples and information on using combo boxes seetheHowJComboBox acts onlyto Use ComboasBoxes adrop downsection inlistThe Java Tutorial.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JComboBox key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A combination of a text field and a drop-down list. @version 1.
57 1079 03/0814/9800 @author Arnaud Weber
Class JComboBox.AccessibleJComboBox, AccessibleAction getAccessibleAction()TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJComboBox
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to Combo Box user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Get the AccessibleAction associated with this object.Class JComboBox.AccessibleJComboBox, int getAccessibleActionCount()if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleAction interface on behalf of itself. @return this object
Returns the number of Actions available in this object.Class JComboBox.AccessibleJComboBox, Accessible getAccessibleChild(int)IfThethere is moredefaultthan one the first onebehavior of a combo box istheto"default"have one action. @return 1 the number of Actions in this object
ReturnReturns the nth Accessible child of the object. The child at index zero represents the popup. If the combo box is editable the child at index one represents the editor. @param i zero-based index of child @return the nth Accessible child of the object
The interface that defines aKeySelectionManager
. To qualify as aKeySelectionManager
the class needs to implement the method that identifies the list index given a character and the combo box data model.
Creates aClass JComboBox, constructor JComboBox(ComboBoxModel)JComboBox
with a default data model. The default data model is an empty list of objects. UseaddItem
to add items. By default the first item in the data model becomes selected. @see DefaultComboBoxModel
Creates aClass JComboBox, constructor JComboBox(Object[])JComboBox
that takesitsit's items from an existingComboBoxModel
. Since theComboBoxModel
is provided a combo box created using this constructor does not create a default combo box model and may impact how the insert remove and add methods behave. @param aModel theComboBoxModel
that provides the displayed list of items @see DefaultComboBoxModel
Creates a JComboBox
that contains the elements in the specified array. By default the first item in the array (and therefore the data model) becomes selected. @param items an array of objects to insert into the combo box @see DefaultComboBoxModel
Class JComboBox, constructor JComboBox(Vector)Creates a JComboBox
that contains the elements in the specified Vector. By default the first item in the vector and therefore the data model) becomes selected. @param items an array of vectors to insert into the combo box @see DefaultComboBoxModel
Class JComboBox, void addActionListener(ActionListener)Adds anClass JComboBox, void addItem(Object)ActionListener
. The listener will receive an action event the user finishes making a selection. @param l theActionListener
that is to be notified
Adds an item to the item list. This method works only if theClass JComboBox, void addItemListener(ItemListener)JComboBox
uses the default data model.JComboBox
uses the default data model when created with the empty constructor and no other model has been set.Warning: Focus and keyboard navigation problems may arise if you add duplicate String objects. A workaround is to add new objects instead of String objects and make sure that the toString() method is defined. For example:
comboBox.addItem(makeObj("Item 1")); comboBox.addItem(makeObj("Item 1")); ... private Object makeObj(final String item) { return new Object() { public String toString() { return item; } }; }@param anObject the Object to add to the list
Adds anClass JComboBox, void configureEditor(ComboBoxEditor, Object)ItemListener
.aListener
will receive an event when the selected item changes. @param aListener theItemListener
that is to be notified
Initializes the editor with the specified item. @param anEditor the ComboBoxEditor
that displays the list item in the combo box field and allows it to be edited @param anItem the object to display and edit in the field
Class JComboBox, KeySelectionManager createDefaultKeySelectionManager()Returns an instance of the default key-selection manager. @return the KeySelectionManager
currently used by the list @see #setKeySelectionManager
Class JComboBox, void fireActionEvent()Class JComboBox, void fireItemStateChanged(ItemEvent)NotifyNotifies all listeners that have registered interest for notification on this event type. @param e the event of interest @see EventListenerList
Class JComboBox, AccessibleContext getAccessibleContext()NotifyNotifies all listeners that have registered interest for notification on this event type. @param e the event of interest @see EventListenerList
Class JComboBox, String getActionCommand()GetGets the AccessibleContext associated with thisJComponentJComboBox. For combo boxes the AccessibleContext takes the form of an AccessibleJComboBox. A new AccessibleJComboBox instance is created if necessary. @return an AccessibleJComboBox that serves as the AccessibleContext of thisJComponentJComboBox
Returns the actionClass JComboBox, ComboBoxEditor getEditor()commnandcommand that is included in the event sent to action listeners. @return the string containing the "command" that is sent to action listeners.
Returns the editor used to paint and edit the selected item in theClass JComboBox, Object getItemAt(int)JComboBox
field. @return theComboBoxEditor
that displays the selected item
Returns the list item at the specified index. IfClass JComboBox, int getItemCount()index
is out of range (less than zero or greater than or equal to size) it will returnnull
. @param index anintinteger indicating the list position where the first item starts at zero @return theObject
at that list position; ornull
if out of range
Returns the number of items in the list. @return anClass JComboBox, KeySelectionManager getKeySelectionManager()intinteger equal to the number of items in the list
Returns the list's key-selection manager. @return the KeySelectionManager
currently in use
Class JComboBox, int getMaximumRowCount()Returns the maximum number of items the combo box can display without a scrollbar @return anClass JComboBox, ComboBoxModel getModel()intinteger specifying the maximum number of items that are displayed in the list before using a scrollbar
Returns the data model currently used by theClass JComboBox, ListCellRenderer getRenderer()JComboBox
. @return theComboBoxModel
that provides the displayed list of items
Returns the renderer used to display the selected item in theClass JComboBox, int getSelectedIndex()JComboBox
field. @return theListCellRenderer
that displays the selected item.
Returns theClass JComboBox, Object[] getSelectedObjects()index of the currently selected item infirst item in the list that matches thelistgiven item. The result is not always defined if theJComboBox
allows selected items that are not in the list. Returns -1 if there is no selected item or if the user specified an item which is not in the list. @return anboxintinteger specifying the currently selected list item where 0 specifies the first item in the list; or -1 if no item is selected or if the currently selected item is not in the list
Returns an array containing the selected item. This method is implemented for compatibility withClass JComboBox, String getUIClassID()ItemSelectable
. @returns an array ofObjects
containing one element -- the selected item
Returns the name of the L&F class that renders this component. @return the string "ComboBoxUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JComboBox, void hidePopup()
Causes the combo box to close its popup window. @see #setPopupVisibleClass JComboBox, void insertItemAt(Object, int)
Inserts an item into the item list at a given index. This method works only if theClass JComboBox, void intervalRemoved(ListDataEvent)JComboBox
uses the default data model.JComboBox
uses the default data model when created with the empty constructor and no other model has been set. @param anObject theObject
to add to the list @param index anintinteger specifying the position at which to add the item
Invoked when values have been removed from the data model. The "interval" includes the first and last values removed. @see javax.swing.event.ListDataListenerClass JComboBox, boolean isEditable()
Returns true if theClass JComboBox, boolean isFocusTraversable()JComboBox
is editable. By default a combo box is not editable. @return true if theJComboBox
is editable else false
Returns true if the component can receive the focus. In this case the component returns false if it is editable so that theClass JComboBox, boolean isPopupVisible()Editor
object receives the focus instead of the component. @return true if the component can receive the focus else false.
Class JComboBox, String paramString()DetermineDetermines the visibility of the popup.
Returns a string representation of thisClass JComboBox, void processKeyEvent(KeyEvent)JComboBox
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJComboBox
.
HandlesClass JComboBox, void removeActionListener(ActionListener)KeyEventsKeyEvent
s looking for the Tab key. If the Tab key is found the popup window is closed. @param e theKeyEvent
containing the keyboard key that was pressed
Removes anClass JComboBox, void removeAllItems()ActionListener
. @param l theActionListener
to remove
Removes all items from the item list.Class JComboBox, void removeItem(Object)This method works only if the JComboBox uses the default data model. JComboBox uses the default data model when created with the empty constructor and no other model has been set.
Removes an item from the item list. This method works only if theClass JComboBox, void removeItemAt(int)JComboBox
uses the default data model.JComboBox
uses the default data model when created with the empty constructor and no other model has been set. @param anObject the object to remove from the item list
Removes the item atClass JComboBox, void removeItemListener(ItemListener)anIndex
This method works only if theJComboBox
uses the default data model.JComboBox
uses the default data model when created with the empty constructor and no other model has been set. @param anIndex an int specifying the idex of the item to remove where 0 indicates the first item in the list
Removes anClass JComboBox, void selectedItemChanged()ItemListener
. @param aListener theItemListener
to remove
This method is called when the selected item changes. Its default implementation notifies the item listeners.Class JComboBox, void setActionCommand(String)
Sets the action commnand that should be included in the event sent to action listeners. @param aCommand a string containing the "command" that is sent to action listenersClass JComboBox, void setEditable(boolean). The; the same listener can then do different things depending on the command it receives.
Determines whether theClass JComboBox, void setEditor(ComboBoxEditor)JComboBox
field is editable. An editableJComboBox
allows the user to type into the field or selected an item from the list to initialize the field after which it can be edited. (The editing affects only the field the list item remains intact.) A non editableJComboBox
displays the selected iteminthein the field but the selection cannot be modified. @param aFlag a boolean value where true indicates that the field is editable @beaninfo bound: true preferred: true description: If true the user can type a new value in the combo box.
Sets the editor used to paint and edit the selected item in theClass JComboBox, void setEnabled(boolean)JComboBox
field. The editor is used only if the receivingJComboBox
is editable. If not editable the combo box uses the renderer to paint the selected item. @param anEditor theComboBoxEditor
that displays the selected item @see #setRenderer @beaninfo bound: true expert: true description: The editor that combo box uses to edit the current value
Enables the combo box so that items can be selected. When the combo box is disabled items cannot be selected and values cannot be typed into its field (if it is editable). @param b a boolean value where true enables the component and false disables it @beaninfo bound: true preferred: true description: Whether the combo box is enabled.Class JComboBox, void setLightWeightPopupEnabled(boolean)
When displaying the popup JComboBox
choose to use a light weight popup if it fits. This method allows you to disable this feature. You have to do disable it if your application mixes light weight and heavy weights components. @beaninfo expert: true description: When set disables using light weight popups.
Class JComboBox, void setMaximumRowCount(int)Sets the maximum number of rows theClass JComboBox, void setModel(ComboBoxModel)JComboBox
displays. If the number of objects in the model is greater than count the combo box uses a scrollbar. @param count anintinteger specifying the maximum number of items to display in the list before using a scrollbar @beaninfo bound: true preferred: true description: The maximum number of rows the popup should have
Sets the data model that theClass JComboBox, void setPopupVisible(boolean)JComboBox
uses to obtain the list of items. @param aModel theComboBoxModel
that provides the displayed list of items @beaninfo bound: true description: Model that the combo box uses to get data to display.
Class JComboBox, void setRenderer(ListCellRenderer)SetSets thevisiblityvisibility of the popup.
Sets the renderer that paints the item selected from the list in the JComboBox field. The renderer is used if the JComboBox is not editable. If it is editable the editor is used to render and edit the selected item.Class JComboBox, void setSelectedIndex(int)The default renderer displays a string obtained by calling the selected object's
toString
method. Other renderers can handle graphic images and composite items.To display the selected item
aRenderer.getListCellRendererComponent
is called passing the list object and an index of -1. @param aRenderer theListCellRenderer
that displays the selected item.@see #setEditor @beaninfo bound: true expert: true description: The renderer that paints the item selected in the list.
Selects the item at indexClass JComboBox, void setSelectedItem(Object)anIndex
. @param anIndex anintinteger specifying the list item to select where 0 specifies the first item in the list @exception IllegalArgumentException ifanIndex
<-1 oranIndex
is greater than or equal to size @beaninfo preferred: true description: The item at index is selected.
Sets the selected item in theClass JComboBox, void setUI(ComboBoxUI)JComboBox
by specifying the object in the list. IfanObject
is in the list the list displays withanObject
selected.If the object does not exist in the list the default data model selects the first item in the list.@param anObject the list object to select @beaninfo preferred: true description: Sets the selected item in the JComboBox.
Sets the L&F object that renders this component. @param ui the ComboBoxUI
L&F object @see UIDefaults#getUI @beaninfo expert: true description: The ComboBoxUI implementation that defines the combo box look and feel.
Class JComboBox, void showPopup()Causes the combo box to display its popup window. @see #setPopupVisibleClass JComboBox, void updateUI()
Notification from the UIFactory
that the L&F has changed. @see JComponent#updateUI
The base class for all Swing components except top-level containers. To use a component that inherits fromJComponent
you must place the component in a containment hierarchy whose root is a top-level Swing container. Top-level Swing containers -- such asJFrame
JDialog
andJApplet
-- are specialized components that provide a place for other Swing components to paint themselves. For an explanation of containment hierarchies see Swing Components and the Containment Hierarchy a section in The Java Tutorial.The
JComponent class provides:
For more information on these subjects see the Swing package description and The Java Tutorial section The JComponent Class.
- The base class for both standard and custom components that use the Swing architecture. A "pluggable look and feel" (
lL&fF) that can be specified by the programmer or (optionally) selected by the user at runtime.Components that areSeedesignedHow tobeSet thecombinedLook andextendedFeel inorderThetoJavacreateTutorialcustomforcomponentsmore information.- Comprehensive keystroke
-handlingthathandling.works with nestedSee the documentcomponents.KeyboardActionBindingsobjectsinforSwingsingle-pointancontrol ofarticle inprogramTheactionsSwinginitiatedConnectionby multiple componentsfor more information.ASupport for tool tips --border propertyshort descriptions thatimplicitlypop updefineswhen thecomponent'scursor lingers overinsetsa component.TheSeeabilityHow toset theUse ToolpreferredTipsminimiminandThemaximumJavasizeTutorial fora componentmore information.ToolTips --Supportshortfordescriptionsaccessibility.thatJComponent
pop up whencontains all of thecursor lingersmethodsover ain thecomponent.Accessible
Autoscrollinginterface--butautomaticitscrollingdoesn'tin a listactually implement thetableinterface.or tree that occurs whenThat is the responsibility of theuserindividualis dragging theclasses that extendmouseJComponent
.Simple easySupport fordialogcomponent-specificconstructionproperties.using staticWith themethods#putClientPropertyinandthe#getClientPropertyJOptionPane class that letmethods you can associateyouname-objectdisplay information and query thepairs with any object thatuserdescends fromJComponent
.Slow-motionAngraphics rendering using debugGraphics so you can see what isinfrastructure for painting that includes double buffering and support forbeingborders.displayed on screen andFor more information seewhetherPaintingorandnotHowit isto UsebeingBordersoverwritten.bothSupportofforwhichAccessibility.areSupportsectionsforin TheinternationalJavaLocalizationTutorial.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see KeyStroke @see Action @see #setBorder @see #registerKeyboardAction @see JOptionPane @see #setDebugGraphicsOptions @see #setToolTipText @see #setAutoscrolls @version 2.
111 03130 07/0809/0099 @author Hans Muller @author Arnaud Weber
Inner class of JComponent used to provide default support for accessibility. This class is not meant to be used directly by application developers but is instead meant only to be subclassed by component developers.Class JComponent.AccessibleJComponent, void addPropertyChangeListener(PropertyChangeListener)Due to a restriction that protected inner classes cannot be subclassed outside of a package this inner class has been made public. When this restriction is lifted for JDK1.1.7 this class will be made protected. The class used to obtain the accessible role for this object.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Class JComponent.AccessibleJComponent, Accessible getAccessibleChild(int)AddAdds a PropertyChangeListener to the listener list. @param listenerThethe PropertyChangeListener to be added
Class JComponent.AccessibleJComponent, String getAccessibleDescription()ReturnReturns the nth Accessible child of the object. @param i zero-based index of child @return the nth Accessible child of the object
Class JComponent.AccessibleJComponent, String getAccessibleName()GetGets the accessible description of this object. This should be a concise localized description of what this object is - what isit'sits meaning to the user. If the object has a tooltip the tooltip text may be an appropriate string to return assuming it contains a concise description of the object (instead of just the name of the object -e.g.for example a "Save" icon on a toolbar that had "save" as the tooltip text shouldn't return the tooltip text as the description but something like "Saves the current text document" instead). @return the localized description of the object -- can be null if this object does not have a description @see AccessibleContext#setAccessibleDescription
Class JComponent.AccessibleJComponent, AccessibleRole getAccessibleRole()GetGets the accessible name of this object. This should almost never return java.awt.Component.getName() as that generally isn't a localized name and doesn't have meaning for the user. If the object is fundamentally a text object (e.g.such as a menu item) the accessible name should be the text of the object (e.g.for example "save"). If the object has a tooltip the tooltip text may also be an appropriate String to return. @return the localized name of the object -- can be null if this object does not have a name @see AccessibleContext#setAccessibleName
Class JComponent.AccessibleJComponent, AccessibleStateSet getAccessibleStateSet()GetGets the role of this object. @return an instance of AccessibleRole describing the role of the object @see AccessibleRole
Class JComponent.AccessibleJComponent, void removePropertyChangeListener(PropertyChangeListener)GetGets the state of this object. @return an instance of AccessibleStateSet containing the current state set of the object @see AccessibleState
Class JComponent.AccessibleJComponent, void setBackground(Color)RemoveRemoves a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties. @param listenerThethe PropertyChangeListener to be removed
Set the background color of this object. (For transparency seeisOpaque
.) @param c the new Color for the background @seeJComponentComponent#isOpaque
Default JComponent constructor. This constructor does no initialization beyond calling the Container constructorClass JComponent, void addAncestorListener(AncestorListener)e.g. For example the initial layout manager is null.
Registers listener so that it will receive AncestorEvents when it or any of its ancestors move or are made visible / invisible. Events are also sent when the component or its ancestors are added or removed from theClass JComponent, void addNotify()Componentcontainment hierarchyThis method will migrate to java.awt.Component in the next major JDK release@see AncestorEvent
Class JComponent, void addPropertyChangeListener(PropertyChangeListener)NotificationNotifiestothis component that it now has a parent component. When this method is invoked the chain of parent components is set up with KeyboardAction event listeners. @see #registerKeyboardAction
Class JComponent, void addPropertyChangeListener(String, PropertyChangeListener)AddAdds a PropertyChangeListener to the listener list. The listener is registered for all properties.A PropertyChangeEvent will get fired in response to setting a bound property
e.g.such as setFont setBackground or setForeground. Note that if the current component is inheriting its foreground background or font from its container then no event will be fired in response to a change in the inherited property.This method will migrate to java.awt.Component in the next major JDK release@param listenerThethe PropertyChangeListener to be added
Class JComponent, void addVetoableChangeListener(VetoableChangeListener)AddAdds a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property. If listener is null no exception is thrown and no action is performed. @param propertyNameThethe name of the property to listen on.@param listenerThethe PropertyChangeListener to be added
Class JComponent, void computeVisibleRect(Rectangle)AddAdds a VetoableChangeListener to the listener list. The listener is registered for all properties.This method will migrate to java.awt.Component in the next major JDK release@param listenerThethe VetoableChangeListener to be added
Returns the Component's "visible rect rectangle" - the intersection of the visible rectangles for this component and all of its ancestors. The return value is stored in visibleRect
. @see #getVisibleRect
Class JComponent, boolean contains(int, int)Class JComponent, void disable()GiveGives the UI delegate an opportunity to define the precise shape of this component for the sake of mouse processing. @return true if this component logically contains x y.@see java.awt.Component#contains(int int)
Class JComponent, void firePropertyChange(String, Object, Object)@deprecatedoverriddenAs of JDKto ensure Accessibilityversion 1.1 replaced by setEnabled(boolean).support
Class JComponent, void fireVetoableChange(String, Object, Object)SupportSupportsforreporting bound property changes. If oldValue and newValue are not equal and the PropertyChangeEvent listener list isn't empty then fire a PropertyChange event to each listener. This method has an overloaded method for each primitive type. For example here's how to write a bound property set method whose value is an int:public void setFoo(int newValue) { int oldValue = foo; foo = newValue; firePropertyChange("foo" oldValue newValue); }This method will migrate to java.awt.Component in the next major JDK release@param propertyNameThethe programmatic name of the property that was changed.@param oldValueThethe old value of the property.@param newValueThethe new value of the property.@see java.beans.PropertyChangeSupport
Class JComponent, AccessibleContext getAccessibleContext()SupportSupportsforreporting constrained property changes. This method can be called when a constrained property has changed and it will send the appropriate PropertyChangeEvent to any registered VetoableChangeListeners.This method will migrate to java.awt.Component in the next major JDK release@exception PropertyVetoException when the attempt to set the property is vetoed by the receiver.
Class JComponent, ActionListener getActionForKeyStroke(KeyStroke)GetGets the AccessibleContext associated with this JComponent. @return the AccessibleContext of this JComponent
Class JComponent, float getAlignmentX()ReturnReturns the object that will perform the action registered for a given keystroke. @return the ActionListener object invoked when the keystroke occurs@see #registerKeyboardAction
OverridesClass JComponent, float getAlignmentY()Container.getAlignmentX
to return the vertical alignment. @return the value of the alignmentX property.@see #setAlignmentX @see java.awt.Component#getAlignmentX
OverridesClass JComponent, boolean getAutoscrolls()Container.getAlignmentY
to return the horizontal alignment. @return the value of the alignmentY property.@see #setAlignmentY @see java.awt.Component#getAlignmentY
Returns true if this component automatically scrolls its contents when dragged (when contained in a component that supports scrolling like JViewport). @see JViewport @see #setAutoscrollsClass JComponent, Rectangle getBounds(Rectangle)
Class JComponent, Graphics getComponentGraphics(Graphics)StoreStores the bounds of this component into "return value" rv andreturnreturns rv. If rv is null a new Rectangle is allocated. This version of getBounds() is useful if the caller wants to avoid allocating a new Rectangle object on the heap. @param rv the return value modified to thecomponentscomponent's bounds @return rv
Returns the graphics object used to paint this component. If DebugGraphics is turned on we create a new DebugGraphics object ifClass JComponent, int getConditionForKeyStroke(KeyStroke)neccessarynecessary.otherwiseOtherwise we just configure the specified graphicsobjectsobject's foreground and font. @returnAa Graphics object configured for this component
Class JComponent, int getHeight()ReturnReturns the condition that determines whether a registered action occurs in response to the specified keystroke.For Java 2 platform v1.3 a KeyStroke can be associated with more than one condition. For example 'a' could be bound for the two conditions WHEN_FOCUSED and WHEN_IN_FOCUSED_WINDOW condition. @return the action-keystroke condition
@see #registerKeyboardAction
Class JComponent, Insets getInsets()ReturnReturns the current height of this component. This method is preferable to writing component.getBounds().height or component.getSize().height because it doesn't cause any heap allocations.This method will migrate to java.awt.Component in the next major JDK release@return the current height of this component.
If a border has been set on this component returns the border's insets;Class JComponent, Insets getInsets(Insets)elseotherwise calls super.getInsets. @return the value of the insets property.@see #setBorder
Returns an Insets object containing this component's inset values. The passed-in Insets object will be reused if possible. Calling methods cannot assume that the same object will be returned however. All existing values within this object are overwritten. @param insets the Insets object which can be reusedClass JComponent, Point getLocation(Point).@see #getInsets @beaninfo expert: true
Class JComponent, Dimension getMaximumSize()StoreStores the x y origin of this component into "return value" rv andreturnreturns rv. If rv is null a new Point is allocated. This version of getLocation() is useful if the caller wants to avoid allocating a new Point object on the heap. @param rv the return value modified to thecomponentscomponent's location @return rv
If theClass JComponent, Dimension getMinimumSize()maximumSizemaximum size has been set to a non-null value justreturnreturns it. If the UIdelegatesdelegate's getMaximumSize() method returns a non null value then return that; otherwise defer to thecomponentscomponent's layout manager. @return the value of the maximumSize property. @see #setMaximumSize
If theClass JComponent, Component getNextFocusableComponent()minimumSizeminimum size has been set to a non-null value justreturnreturns it. If the UIdelegatesdelegate's getMinimumSize() method returns a non-null value then return that; otherwise defer to thecomponentscomponent's layout manager. @return the value of the minimumSize property.@see #setMinimumSize
Class JComponent, Dimension getPreferredSize()ReturnReturns the next focusable component or null if the focus manager should choose the next focusable component automatically.
If the preferredSize has been set to a non-null value justClass JComponent, KeyStroke[] getRegisteredKeyStrokes()returnreturns it. If the UIdelegatesdelegate's getPreferredSize() method returns a non nullthenvalue then return that; otherwise defer to thecomponentscomponent's layout manager. @return the value of the preferredSize property.@see #setPreferredSize
Class JComponent, Dimension getSize(Dimension)ReturnReturns the KeyStrokes that will initiate registered actions. @return an array of KeyStroke objects @see #registerKeyboardAction
Class JComponent, Point getToolTipLocation(MouseEvent)StoreStores the width/height of this component into "return value" rv andreturnreturns rv. If rv is null a new Dimension object is allocated. This version of getSize() is useful if the caller wants to avoid allocating a new Dimension object on the heap. @param rv the return value modified to thecomponentscomponent's size @return rv
Class JComponent, String getToolTipText()ReturnReturns the tooltip location inthe receivingthis component's coordinate system. If null is returned Swing will choose a location. The default implementation returns null. @param event the MouseEvent that caused the ToolTipManager to show the tooltip.
Class JComponent, String getToolTipText(MouseEvent)ReturnReturns the tooltip string that has been set with setToolTipText(). @return the text of the tool tip @see #TOOL_TIP_TEXT_KEY
Returns the string to be used as the tooltip for event. By default this returns any string set using setToolTipText(). If a component provides moreClass JComponent, Container getTopLevelAncestor()extensizeextensive API to support differing tooltips at different locations this method should be overridden.
Returns the top-level ancestor of this component (either the containing Window or Applet) or null if this component has not been added to any container. @return the top-level ContainerClass JComponent, String getUIClassID()whichthat this component is in.
Class JComponent, Rectangle getVisibleRect()ReturnReturns the UIDefaults key used to look up the name of the swing.plaf.ComponentUI class that defines the look and feel for this component. Most applications will never need to call this method. Subclasses of JComponent that support pluggable look and feel should override this method to return a UIDefaults key that maps to the ComponentUI subclass that defines their look and feel. @return The UIDefaults key for a ComponentUI subclass. @see UIDefaults#getUI @beaninfo expert: true description: UIClassID
Returns the Component's "visible rectangle" - the intersection of thisClass JComponent, int getWidth()componentscomponent's visible rectangle:new Rectangle(0 0 getWidth() getHeight());and all of its ancestors' visible Rectangles. @return the visible rectangle
Class JComponent, int getX()ReturnReturns the current width of this component. This method is preferable to writing component.getBounds().width or component.getSize().width because it doesn't cause any heap allocations.This method will migrate to java.awt.Component in the next major JDK release@return the current width of this component.
Class JComponent, int getY()ReturnReturns the current x coordinate of thecomponentscomponent's origin. This method is preferable to writing component.getBounds().x or component.getLocation().x because it doesn't cause any heap allocations.This method will migrate to java.awt.Component in the next major JDK release@return the current x coordinate of thecomponentscomponent's origin.
Class JComponent, void grabFocus()ReturnReturns the current y coordinate of thecomponentscomponent's origin. This method is preferable to writing component.getBounds().y or component.getLocation().y because it doesn't cause any heap allocations.This method will migrate to java.awt.Component in the next major JDK release@return the current y coordinate of thecomponentscomponent's origin.
Class JComponent, boolean hasFocus()SetSets the focus on the receiving component if it doesn't already have it. This method is for focus managers.youYou rarely want to call this method; use requestFocus()ensteadinstead.
Returns true if this Component has the keyboard focus.Class JComponent, boolean isDoubleBuffered()This method will migrate to java.awt.Component in the next major JDK release@return true if this Component has the keyboard focus.
Class JComponent, boolean isLightweightComponent(Component)ReturnReturns whether the receiving component should use a buffer to paint.
Returns true if this component is a lightweightClass JComponent, boolean isManagingFocus()i.e.that is if it doesn't have a native window system peer.This method will migrate to java.awt.Component in the next major JDK release@return true if this component is a lightweight
Override this method and return true if your JComponent manages focus. If your component manages focus the focus manager will handle your component's children. All key event will be sent to your key listener including TAB and SHIFT+TAB. CONTROLClass JComponent, boolean isOpaque()+TAB and CONTROL+SHIFT+TAB will move the focus to the next/or previous component.
Returns true if this component is completely opaque.Class JComponent, boolean isOptimizedDrawingEnabled()An opaque component paints every pixel within its rectangular
regionbounds. A non-opaque component paints onlysomea subset of its pixels or none at all allowing the pixels underneath it to "show through".ATherefore a component that does not fully paint its pixelsthereforeprovides a degree of transparency.Subclasses that guarantee to always completely paint their contents should override this method and return true.
This method will migrate to java.awt.Component in the next major JDK release@return true if this component is completely opaque.@see #setOpaque
Returns true if this component tiles its childrenClass JComponent, boolean isRequestFocusEnabled()i.e.-- that is if it can guarantee that the children will not overlap. The repainting system is substantially more efficient in this common case. JComponent subclasses that can't make this guaranteee.g.such as JLayeredPane should override this method to return false. @return true if thiscomponentscomponent's children don't overlap
Class JComponent, void paint(Graphics)ReturnReturns whether the receiving component can obtain the focus by calling requestFocus. @see #setRequestFocusEnabled
This method is invoked by Swing to draw components. Applications should not invoke paint directly but should instead use theClass JComponent, void paintBorder(Graphics)repaint
method to schedule the component for redrawing.This method actually delegates the work of painting to three protected methods:
paintComponent
paintBorder
andpaintChildren
. They're called in the order listed to ensure that children appear on top of component itself. Generally speaking the component and its children should not paint in the insets area allocated to the border. Subclasses can just override this method as always. A subclass that just wants to specialize the UI (look and feel)delegatesdelegate's paint method should just overridepaintComponent
. @see #paintComponent @see #paintBorder @see #paintChildren @see #getComponentGraphics @see #repaint
Class JComponent, void paintChildren(Graphics)PaintPaints the component's border. @see #paint @see #setBorder
Class JComponent, void paintComponent(Graphics)PaintPaints this component's children. If shouldUseBuffer is true no component ancestor has a buffer and the component children can use a buffer if they have one. Otherwise one ancestor has a buffer currently in use and children should not use a buffer to paint. @see #paint @see java.awt.Container#paint
If the UI delegate is non-nullClass JComponent, void paintImmediately(Rectangle)callcalls its paint method. We pass the delegate a copy of the Graphics object to protect the rest of the paint code from irrevocable changes (e.g.for example Graphics.translate()). @see #paint
Class JComponent, void paintImmediately(int, int, int, int)PaintPaints the specified region now.This method will migrate to java.awt.Component in the next major JDK release
Class JComponent, String paramString()PaintPaints the specified region in this component and all of its descendants that overlap the region immediately.It's rarely
neccessarynecessary to call this method. In most cases it's more efficient to call repaint which defers the actual painting and can collapse redundant requests into a single paint call. This method is useful if one needs to update the display while the current event is being dispatched. @see #repaint
Returns a string representation of this JComponent. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not beClass JComponent, void processComponentKeyEvent(KeyEvent)null
. @return a string representation of this JComponent.
Class JComponent, void processKeyEvent(KeyEvent)ProcessProcesses any key events that the component itself recognizes. Thiswill beis called after the focus manager and any interested listeners have been given a chance to steal away the event. This methodwill only beis calledisonly if the event has not yet been consumed. This method is called prior to the keyboard UI logic.This method is implemented to do nothing. Subclasses would normally override this method if they process some key events themselves. If the event is processed it should be consumed.
Class JComponent, void putClientProperty(Object, Object)OverrideOverrides processKeyEvent to process events.
Class JComponent, void registerKeyboardAction(ActionListener, KeyStroke, int)AddAdds an arbitrary key/value "client property" to this component.The
get/putClientProperty
methods provide access to a small per-instance hashtable. Callers can use get/putClientProperty to annotate components that were created by another modulee.g.For example a layout manager might store per child constraints this way. For example:componentA.putClientProperty("to the left of" componentB);If value is null this method will remove the property. Changes to client properties are reported with PropertyChange events. The name of the property (for the sake of PropertyChange events) iskey.toString()
.The clientProperty dictionary is not intended to support large scale extensions to JComponent nor should be it considered an alternative to subclassing when designing a new component. @see #getClientProperty @see #addPropertyChangeListener
Class JComponent, void registerKeyboardAction(ActionListener, String, KeyStroke, int)CallsThisregisterKeyboardAction(ActionListenermethodString KeyStrokeis nowcondition)obsoletewithplease use anullcombination ofgetActionMap()
andgetInputMap()
for similiarcommandbehavior.
This method is now obsolete please use a combination ofClass JComponent, void removeAncestorListener(AncestorListener)getActionMap()
andgetInputMap()
for similiar behavior. For example to bind the KeyStrokeaKeyStroke
to the ActionanAction
now use:component.getInputMap().put(aKeyStroke aCommand); component.getActionMap().put(aCommmand anAction);The above assumes you want the binding to be applicable forWHEN_FOCUSED
. To register bindings for other focus states use thegetInputMap
method that takes an integer.Register a new keyboard action. anAction will be invoked if a key event matching aKeyStroke occurs and aCondition is verified. The KeyStroke object defines a particular combination of a keyboard key and one or more modifiers (alt shift ctrl meta).
The aCommand will be set in the delivered event if specified.
The Condition can be one of:
- WHEN_FOCUSED
- The action will be invoked only when the keystroke occurs while the component has the focus.
- WHEN_IN_FOCUSED_WINDOW
- The action will be invoked when the keystroke occurs while the component has the focus or if the component is in the window that has the focus. Note that the component need not be an immediate descendent of the window -- it can be anywhere in the window's containment hierarchy. In other words whenever any component in the window has the focus the action registered with this component is invoked.
- WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
- The action will be invoked when the keystroke occurs while the component has the focus or if the component is an ancestor of the component that has the focus.
The combination of keystrokes and conditions lets you define high level (semantic) action events for a specified keystroke+modifier combination (using the KeyStroke class) and direct to a parent or child of a component that has the focus or to the component itself. In other words in any hierarchical structure of components an arbitrary key-combination can be immediately directed to the appropriate component in the hierarchy and cause a specific method to be invoked (usually by way of adapter objects).
If an action has already been registered for the receiving container with the same charCode and the same modifiers anAction will replace the action. @see KeyStroke
Unregisters listener so that it will no longer receive AncestorEventsClass JComponent, void removeNotify()This method will migrate to java.awt.Component in the next major JDK release@see #addAncestorListener
Class JComponent, void removePropertyChangeListener(PropertyChangeListener)NotificationNotifiestothis component that it no longer has a parent component. When this method is invoked any KeyboardActions set up in the the chain of parent components are removed. @see #registerKeyboardAction
Class JComponent, void removePropertyChangeListener(String, PropertyChangeListener)RemoveRemoves a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.This method will migrate to java.awt.Component in the next major JDK release@param listenerThethe PropertyChangeListener to be removed
Class JComponent, void removeVetoableChangeListener(VetoableChangeListener)RemoveRemoves a PropertyChangeListener for a specific property. If listener is null no exception is thrown and no action is performed. @param propertyNameThethe name of the property that was listened on.@param listenerThethe PropertyChangeListener to be removed
Class JComponent, boolean requestDefaultFocus()RemoveRemoves a VetoableChangeListener from the listener list. This removes a VetoableChangeListener that was registered for all properties.This method will migrate to java.awt.Component in the next major JDK release@param listenerThethe VetoableChangeListener to be removed
Class JComponent, void requestFocus()RequestRequests the focus for the component that should have the focus by default. The default implementation will recursively request the focus on the first component that is focus-traversable. @return false if the focus has not been set otherwise return true
Class JComponent, void resetKeyboardActions()SetSets focus on the receiving component if isRequestFocusEnabled returns true and the component doesn't already have focus.
Class JComponent, void revalidate()UnregisterUnregisters allkeyboardtheactionsbindings@seein#registerKeyboardActionthe first tier InputMaps and ActionMap. This has the effect of removing any local bindings and allowing the bindings defined in parent InputMap/ActionMaps (the UI is usually defined in the second tier) to persist.
Class JComponent, void scrollRectToVisible(Rectangle)SupportSupportsfordeferred automatic layout.Calls invalidate() and then adds this
componentscomponent's validateRoot to a list of components that need to be validated. Validation will occur after all currently pending events have been dispatched. In other words after this method is called the first validateRoot (if any) found when walking up the containment hierarchy of this component will be validated. By defaultJRootPane
JScrollPane
andJTextField
return true fromisValidateRoot
.()This method will automatically be called on this component when a property value changes such that size location or internal layout of this component has been affected. This automatic updating differs from the AWT because programs generally no longer need to invoke validate() to get the contents of the GUI to update.
@see java.awt.Component#invalidate @see java.awt.Container#validate @see #isValidateRoot @see RepaintManager#addInvalidComponent
Forwards the scrollRectToVisible() message to the JComponent's parent. Components that can service the request such asClass JComponent, void setAlignmentX(float)aJViewport override this method and perform the scrolling. @see JViewport
Class JComponent, void setAlignmentY(float)SetSets the the vertical alignment. @see #getAlignmentX @beaninfo description: The preferred horizontal alignment of the component.
Class JComponent, void setAutoscrolls(boolean)SetSets the the horizontal alignment. @see #getAlignmentY @beaninfo description: The preferred vertical alignment of the component.
If true this component will automatically scroll its contents when dragged if contained in a component that supports scrolling such as JViewport. @see JViewport @see #getAutoscrolls @beaninfo expert: true description: Whether this component automatically scrolls its contents when dragged.Class JComponent, void setBorder(Border)
Sets the border of this component. The Border object is responsible for defining the insets for the component (overriding any insets set directly on the component) and for optionally rendering any border decorations within the bounds of those insets. Borders should be used (rather than insets) for creating both decorative and non-decorative (Class JComponent, void setDebugGraphicsOptions(int)e.g.such as margins and padding) regions for a swing component. Compound borders can be used to nest multiple borders within a single component.This is a bound property. @param border the border to be rendered for this component @see Border @see CompoundBorder @beaninfo bound: true preferred: true attribute: visualUpdate true description: The component's border.
Enables or disables diagnostic information about every graphics operation performed within the component or one of its children. The value of debugOptions determines how the component should display this information:Class JComponent, void setDoubleBuffered(boolean)debug is bitwise OR'd into the current value. DebugGraphics.NONE_OPTION disables debugging. A value of 0 causes no changes to the debugging options. @beaninfo preferred: true enum: NONE_OPTION DebugGraphics.NONE_OPTION LOG_OPTION DebugGraphics.LOG_OPTION FLASH_OPTION DebugGraphics.FLASH_OPTION BUFFERED_OPTION DebugGraphics.BUFFERED_OPTION description: Diagnostic options for graphics operations.
- DebugGraphics.LOG_OPTION - causes a text message to be printed.
- DebugGraphics.FLASH_OPTION - causes the drawing to flash several times.
- DebugGraphics.BUFFERED_OPTION - creates an ExternalWindow that displays the operations performed on the View's offscreen buffer.
Class JComponent, void setEnabled(boolean)SetSets whether the receiving component should use a buffer to paint. If set to true all the drawing from this component will be done in an offscreen painting buffer. The offscreen painting buffer will the be copied onto the screen. Swing's painting system always use a maximum of one double buffer. If a Component is buffered and one of its ancestor is also buffered the ancestor buffer will be used.
Sets whether or not this component is enabled. A componentClass JComponent, void setMaximumSize(Dimension)whichthat is enabled may respond to user input while a componentwhichthat is not enabled cannot respond to user input. Some components may alter their visual representation when they are disabled in order to provide feedback to the user that they cannot take input. @see java.awt.Component#isEnabled @beaninfo preferred: true bound: true attribute: visualUpdate true description: The enabled state of the component.
Sets theClass JComponent, void setMinimumSize(Dimension)maximumSizemaximum size of this component to a constant value. Subsequent calls to getMaximumSize will always return this value; thecomponentscomponent's UI will not be asked to compute it. Setting themaximumSizemaximum size to null restores the default behavior. @see #getMaximumSize @beaninfo bound: true description: The maximum size of the component.
Sets theClass JComponent, void setOpaque(boolean)minimumSizeminimum size of this component to a constant value. Subsequent calls to getMinimumSize will always return this value; thecomponentscomponent's UI will not be asked to compute it. Setting theminimumSizeminimum size to null restores the default behavior. @see #getMinimumSize @beaninfo bound: true description: The minimum size of the component.
If true theClass JComponent, void setPreferredSize(Dimension)components background will be filled withcomponent paints every pixel within itsthe background colorbounds. Otherwise thebackground is transparent and whatevercomponent may not paint someisor all of its pixels allowing theunderneath willunderlying pixels to show through.The default value of this property is false for
JComponent
.This is a JavaBeans boundHowever the default value for this property on most standardJComponent
subclasses (such asJButton
andJTree
) is look-and-feel dependent. @see #isOpaque @beaninfo bound: true expert: true description: The component's opacity
Class JComponent, void setRequestFocusEnabled(boolean)SetSets the preferred size of the receiving component.ifIfpreferredSize
is null the UI will be asked for the preferred size. @beaninfo preferred: true bound: true description: The preferred size of the component.
Class JComponent, void setToolTipText(String)SetSets whether the receiving component can obtain the focus by calling requestFocus. The default value is true. Note: Setting this property to false will not prevent the focus manager from setting the focus to this component it will prevent the component from getting the focus when the focus is requested explicitly. Override isFocusTraversable and return false if the component should never get the focus. @beaninfo expert: true description: Whether the component can obtain the focus by calling requestFocus.
Registers the text to display in a tool tip. The text displays when the cursor lingers over the component.Class JComponent, void setUI(ComponentUI)See How to Use Tool Tips in The Java Tutorial for further documentation. @param text
Thethe string to display.;Ifif the text is null the tool tip is turned off for this component.@see #TOOL_TIP_TEXT_KEY @beaninfo preferred: true description: The text to display in a tool tip.
Class JComponent, void unregisterKeyboardAction(KeyStroke)SetSets the look and feel delegate for this component. JComponent subclasses generally override this method to narrow the argument typee.g. For example in JSlider:public void setUI(SliderUI newUI) { super.setUI(newUI); }
AdditionalyAdditionally JComponent subclasses must provide a getUI method that returns the correct typee.g.For example:public SliderUI getUI() { return (SliderUI)ui; }@see #updateUI @see UIManager#getLookAndFeel @see UIManager#getUI @beaninfo bound: true attribute: visualUpdate true description: The component's look and feel delegate.
Class JComponent, int UNDEFINED_CONDITIONUnregisterThis method is now obsolete. To unregister an existing binding you can either remove the binding from the ActionMap/InputMap or place a dummy binding the InputMap. Removing the binding from the InputMap allows bindings in parent InputMaps to be active whereas putting a dummy binding in the InputMap effectively disables the binding from ever happening.Unregisters
a keyboard action.@seeThis will remove the binding from the#registerKeyboardActionActionMap (if it exists) as well as the InputMaps.
Constant used by some of theClass JComponent, int WHEN_ANCESTOR_OF_FOCUSED_COMPONENTapisAPIs to mean that no condition is defined.
Constant used for registerKeyboardAction()Class JComponent, int WHEN_FOCUSEDwhichthat means that thecomandcommand should be invoked when the receiving component is an ancestor of the focused component or is itself the focused component.
Constant used for registerKeyboardAction()Class JComponent, int WHEN_IN_FOCUSED_WINDOWwhichthat means that the command should be invoked when the component has the focus.
Constant used for registerKeyboardAction()Class JComponent, AccessibleContext accessibleContextwhichthat means that the command should be invoked when the receiving component is in the window that has the focus or is itself the focused component.
---TheAccessibility SupportAccessibleContext associated---withJComponent will contain all of the methods in interface Accessible though it won't actally implement the interface - that will be up to the individual objects which extendthis JComponent.
A container used to create a multiple-document interface or a virtual desktop. You create JInternalFrame objects and add them to the JDesktopPane. JDesktopPane extends JLayeredPane to manage the potentially overlapping internal frames. It also maintains a reference to an instance of DesktopManager that is set by the UI class for the current Look and Feel (L&F).This class is normally used as the parent of JInternalFrames to provide a pluggable DesktopManager object to the JInternalFrames. The installUI of the L&F specific implementation is responsible for setting the desktopManager variable appropriately. When the parent of a JInternalFrame is a JDesktopPane it should delegate most of its behavior to the desktopManager (closing resizing etc).
For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JDesktopPane key assignments. For further documentation and examples see How to Use Internal Frames a section in The Java Tutorial.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JInternalFrame @see JInternalFrame.JDesktopIcon @see DesktopManager @version 1.
26 1036 03/1514/9800 @author David Kloba
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJDesktopPane
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to desktop pane user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
GetGets the AccessibleContext associated with thisJComponentJDesktopPane. For desktop panes the AccessibleContext takes the form of an AccessibleJDesktopPane. A new AccessibleJDesktopPane instance is created if necessary. @return an AccessibleJDesktopPane that serves as the AccessibleContext of thisJComponentJDesktopPane
The main class for creating a dialog window. You can use this class to create a custom dialog or invoke the manystaticclass methods in JOptionPane to create a variety of standard dialogs. For information about creating dialogs see The Java Tutorial section How to Make Dialogs.The
JDialog
component contains aJRootPane
asit'sits only child. ThecontentPane
should be the parent of any children of theJDialog
. From the olderjava.awt.Window
object you would normally do something like this:dialog.add(child);UsingJDialog
the proper semantic is:dialog.getContentPane().add(child);The same priniciple holds true for setting layout managers removing components listing children etc. All these methods should normally be sent to thecontentPane
instead of to theJDialog
. ThecontentPane
is always non-null
. Attempting to set it tonull
generates an exception. The defaultcontentPane
has aBorderLayout
manager set on it.Please see the
JRootPane
documentation for a complete description of thecontentPane
glassPane
andlayeredPane
components.
NOTE: For 1.1 Modal dialogs are currently constrained to only allow lightweight popup menus (JPopupMenu JComboBox JMenuBar) because of window ownership limitations in AWT1.1. This creates the further limitation of not being able to mix Swing popup components with AWT heavyweight components in a modal dialog since the heavyweight components would always overlap the lightweights potentially obscuring the popup menu. (A heavyweight component uses a native-platform component (peer) component for its implementation -- AWT components are heavyweight components.)For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JDialog key assignments.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JOptionPane @see JRootPane @beaninfo attribute: isContainer true attribute: containerDelegate getContentPane description: A toplevel window for creating dialog boxes. @version 1.
43 0451 03/2214/9900 @author David Kloba @author James Gosling @author Scott Violet
Class JDialog.AccessibleJDialog, AccessibleComponent getAccessibleComponent()TheThis classusedimplementstoaccessibility supportobtainfor theAccessibleRoleJDialog
forclass. It provides an implementation of the Java Accessibility API appropriate to dialogthisuser-interfaceobjectelements.
Get the AccessibleComponent associated with this object if one exists. Otherwise return null. @return the componentClass JDialog.AccessibleJDialog, void setBackground(Color)
Set the background color of this object. (For transparency see isOpaque
.) @param c the new Color for the background @see Component#isOpaque
Creates a non-modal dialog without a title and without a specifiedClass JDialog, constructor JDialog(Dialog)Frame
owner. A shared hidden frame will be set as the owner of theDialogdialog.
Creates a non-modal dialog without a title with the specifedClass JDialog, constructor JDialog(Dialog, String)Dialog
as its owner. @param owner theDialog
from which the dialog is displayed
Creates a non-modal dialog with the specified title and with the specified owner dialog. @param owner theClass JDialog, constructor JDialog(Dialog, String, boolean)Dialog
from which the dialog is displayed @param title theString
to display in the dialog's title bar
Creates a modal or non-modal dialog with the specified title and the specified owner frame. @param owner theClass JDialog, constructor JDialog(Dialog, boolean)dialogDialog
from which the dialog is displayed @param title theString
to display in the dialog's title bar @param modal true for a modal dialog false for one that allowsothersother windows to be active at the same time
Creates a modal or non-modal dialog without a title and with the specified owner dialog.Class JDialog, constructor JDialog(Frame)@param owner the
Dialog
from which the dialog is displayed @param modal true for a modal dialog false for one that allowsothersother windows to be active at the same time
Creates a non-modal dialog without a title with the specifedClass JDialog, constructor JDialog(Frame, String)Frame
as its owner. @param owner theFrame
from which the dialog is displayed
Creates a non-modal dialog with the specified title and with the specified owner frame. @param owner theClass JDialog, constructor JDialog(Frame, String, boolean)Frame
from which the dialog is displayed @param title theString
to display in the dialog's title bar
Creates a modal or non-modal dialog with the specified title and the specified ownerClass JDialog, constructor JDialog(Frame, boolean)frameFrame
. All constructors defer to this one.NOTE: Any popup components (
JComboBox
JPopupMenu
JMenuBar
) created within a modal dialog will be forced to be lightweight. @param owner theframeFrame
from which the dialog is displayed @param title theString
to display in the dialog's title bar @param modal true for a modal dialog false for one that allowsothersother windows to be active at the same time
Creates a modal or non-modal dialog without a title and with the specified ownerClass JDialog, void addImpl(Component, Object, int)frameFrame
. @param owner theFrame
from which the dialog is displayed @param modal true for a modal dialog false for one that allows others windows to be active at the same time
By default children may not be added directly to a this component they must be added to itsClass JDialog, JRootPane createRootPane()contentPane
instead. For example:thisComponent.getContentPane().add(child)An attempt to add to directly to this component will cause an runtime exception to be thrown if rootPaneCheckingEnabled is true. Subclasses can disable this behavior. @param comp theComponent
to be enhanced @param constraints the constraints to be respected @param index the index (an integer) @see #setRootPaneCheckingEnabled @exception Error if called withrootPaneCheckingrootPaneCheckingEnabled true
Called by the constructor methods to create the default rootPane
.
Class JDialog, void dialogInit()Called by the constructors to init the JDialog
properly.
Class JDialog, AccessibleContext getAccessibleContext()Class JDialog, Container getContentPane()GetGets the AccessibleContext associated with this JDialog. For JDialogs the AccessibleContext takes the form of an AccessibleJDialog. A new AccessibleJDialog instance is created if necessary. @return an AccessibleJDialog that serves as the AccessibleContext of this JDialog
Returns theClass JDialog, int getDefaultCloseOperation()contentPane
object for this dialog. @return thecontentPane
property @see #setContentPane @see RootPaneContainer#getContentPane
Returns the operation which occurs when the user initiates a "close" on this dialog. @return anClass JDialog, Component getGlassPane()intinteger indicating the window-close operation @see #setDefaultCloseOperation
Returns theClass JDialog, JLayeredPane getLayeredPane()glassPane
object for this dialog. @return theglassPane
property @see #setGlassPane @see RootPaneContainer#getGlassPane
Returns theClass JDialog, JRootPane getRootPane()layeredPane
object for this dialog. @return thelayeredPane
property @see #setLayeredPane @see RootPaneContainer#getLayeredPane
Returns the rootPane
object for this dialog. @see #setRootPane @see RootPaneContainer#getRootPane
Class JDialog, boolean isRootPaneCheckingEnabled()Returns true if the methodsClass JDialog, String paramString()add
andsetLayout
should be checked. @return true ifadd
andsetLayout
should be checked @see #addImpl @see #setLayout @see #setRootPaneCheckingEnabled
Returns a string representation of thisClass JDialog, void setContentPane(Container)JDialog
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJDialog
.
Sets theClass JDialog, void setDefaultCloseOperation(int)contentPane
property. This method is called by the constructor. @param contentPane thecontentPane
object for this dialog @exception java.awt.IllegalComponentStateException (a runtime exception) if the content pane parameter isnull
@see #getContentPane @see RootPaneContainer#setContentPane @beaninfo hidden: true description: The client area of the dialog where child components are normally inserted.
Sets the operation which will happen by default when the user initiates a "close" on this dialog. The possible choices are:Class JDialog, void setGlassPane(Component)
- DO_NOTHING_ON_CLOSE - do not do anything - require the program to handle the operation in the
windowClosing
method of a registeredWindowListener
object.- HIDE_ON_CLOSE - automatically hide the dialog after invoking any registered
WindowListener
objects- DISPOSE_ON_CLOSE - automatically hide and dispose the dialog after invoking any registered
WindowListener
objectsEXIT_ON_CLOSE - Exit the application by way of System.exit. Only use this in applications.The value is set to HIDE_ON_CLOSE by default. @see #addWindowListener @see #getDefaultCloseOperation @beaninfo preferred: true description: The dialog's default close operation.
Sets theClass JDialog, void setLayeredPane(JLayeredPane)glassPane
property. This method is called by the constructor. @param glassPane theglassPane
object for this dialog @see #getGlassPane @see RootPaneContainer#setGlassPane @beaninfo hidden: true description: A transparent pane used for menu rendering.
Sets theClass JDialog, void setLayout(LayoutManager)layeredPane
property. This method is called by the constructor. @param layeredPane thelayeredPane object fornewthislayeredPane
dialogproperty @exception java.awt.IllegalComponentStateException (a runtime exception) if the layered pane parameter is null @see #getLayeredPane @see RootPaneContainer#setLayeredPane @beaninfo hidden: true description: The pane which holds the various dialog layers.
By default the layout of this component may not be set the layout of itsClass JDialog, void setRootPane(JRootPane)contentPane
should be set instead. For example:thisComponent.getContentPane().setLayout(new BorderLayout())An attempt to set the layout of this component will cause an runtime exception to be thrown if rootPaneCheckingEnabled is true. Subclasses can disable this behavior. @see #setRootPaneCheckingEnabled @param manager theLayoutManager
@exception Error if called with rootPaneChecking true
Sets theClass JDialog, void setRootPaneCheckingEnabled(boolean)rootPane
property. This method is called by the constructor. @param root therootPane
object for this dialog @see #getRootPane @beaninfo hidden: true description: the RootPane object for this dialog.
If true then calls toClass JDialog, void update(Graphics)add
and()setLayout
will cause an exception to be thrown. @see #addImpl @see #setLayout @see #isRootPaneCheckingEnabled @beaninfo hidden: true description: Whether the add and setLayout methods throw exceptions when invoked.()
JustCallscallspaint(g)
. This method was overridden to prevent an unneccessary call to clear the background.
A text component to edit various kinds of content. You can find how-to information and examples of using editor panes in Using Text Components a section in The Java Tutorial.This component uses implementations of the
EditorKit
to accomplish its behavior. It effectively morphs into the proper kind of text editor for the kind of content it is given. The content type that editor is bound to at any given time is determined by theEditorKit
currently installed. If the content is set to a new URL its type is used to determine theEditorKit
that should be used to load the content.By default the following types of content are known:
- text/plain
- Plain text which is the default the type given isn't recognized. The kit used in this case is an extension of
DefaultEditorKit
that produces a wrapped plain text view.- text/html
- HTML text. The kit used in this case is the class
javax.swing.text.html.HTMLEditorKit
which provideshtmlHTML 3.2 support.- text/rtf
- RTF text. The kit used in this case is the class
javax.swing.text.rtf.RTFEditorKit
which provides a limited support of the Rich Text Format.There are several ways to load content into this component.
- The setText method can be used to initialize the component from a string. In this case the current
EditorKit
will be used and the content type will be expected to be of this type.- The read method can be used to initialize the component from a Reader. Note that if the content type is
htmlHTML relative references (e.g. for things like images) can't be resolved unless the <base> tag is used or the Base property on HTMLDocument is set. In this case the currentEditorKit
will be used and the content type will be expected to be of this type.- The setPage method can be used to initialize the component from a URL. In this case the content type will be determined from the URL and the registered
EditorKit
for that content type will be set.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JEditorPane key assignments.
Some kinds of content may provide hyperlink support by generating hyperlink events. The
htmlHTMLEditorKit
will generate hyperlink events if theJEditorPane
is not editable (i.e.JEditorPane.setEditable(false);
has been called). IfhtmlHTML frames are embedded in the document the typical response would be to change a portion of the current document. The following code fragment is a possible hyperlink listener implementation that treatshtmlHTML frame events specially and simply displays any other activated hyperlinks.
class Hyperactive implements HyperlinkListener { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane pane = (JEditorPane) e.getSource(); if (e instanceof HTMLFrameHyperlinkEvent) { HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e; HTMLDocument doc = (HTMLDocument)pane.getDocument(); doc.processHTMLFrameHyperlinkEvent(evt); } else { try { pane.setPage(e.getURL()); } catch (Throwable t) { t.printStackTrace(); } } } } }Culturally dependent information in some documents is handled through a mechanism called character encoding. Character encoding is an unambiguous mapping of the members of a character set (letters ideographs digits symbols or control functions) to specific numeric code values. It represents the way the file is stored. Example character encodings are ISO-8859-1 ISO-8859-5 Shift-jis Euc-jp and UTF-8. When the file is passed to an user agent (
JEditorPane
) it is converted to the document character set (ISO-10646 aka Unicode).There are multiple ways to get a character set mapping to happen with
JEditorPane
.
- One way is to specify the character set as a parameter of the MIME type. This will be established by a call to the setContentType method. If the content is loaded by the setPage method the content type will have been set according to the specification of the URL. It the file is loaded directly the content type would be expected to have been set prior to loading.
- Another way the character set can be specified is in the document itself. This requires reading the document prior to determining the character set that is desired. To handle this it is expected that the
EditorKit
.read operation throw aChangedCharSetException
which will be caught. The read is then restarted with a new Reader that uses the character set specified in theChangedCharSetException
(which is anIOException
).Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A text component to edit various types of content. @author Timothy Prinzing @version 1.
76 0496 03/2214/9900
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJEditorPane
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to editor pane user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
This class provides support forAccessibleHypertext
and is used in instances where theEditorKit
installed in thisJEditorPane
is an instance ofHTMLEditorKit
.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for baseline for serialized form of Swing objects.
What's returned byAccessibleJEditorPaneHTML.getAccessibleText
. Provides support for()AccessibleHypertext
in case there is an HTML document being displayed in thisJEditorPane
.
Class JEditorPane, constructor JEditorPane(String)ConstructsCreates a newJEditorPane
. The document model is set tonull
.
Creates aClass JEditorPane, constructor JEditorPane(String, String)JEditorPane
based on a string containing a URL specification. @param url the URL @exception IOException if the URL isnull
or cannot be accessed
Creates aClass JEditorPane, constructor JEditorPane(URL)JEditorPane
that has been initialized to the given text. This is a convenience constructor that calls thesetContentType
andsetText
methods. @param type mime type of the given text.@param text the text to initialize with.
Creates aClass JEditorPane, EditorKit createDefaultEditorKit()JEditorPane
based on a specified URL for input. @param initialPage the URL @exception IOException if the URL isnull
or cannot be accessed
Creates the default editor kit (PlainEditorKit
) for when the component is first created. @return the editor kit
Class JEditorPane, EditorKit createEditorKitForContentType(String)Class JEditorPane, void fireHyperlinkUpdate(HyperlinkEvent)CreateCreates a handler for the given type from the default registry of editor kits. The registry is created if necessary. If the registered class has not yet been loaded an attempt is made to dynamically load the prototype of the kit for the given type. If the type was registered with aClassLoader
thatClassLoader
will be used to load the prototype. If there was no registeredClassLoader
Class.forName
will be used to load the prototype.Once a prototype
EditorKit
instance is successfully located it is cloned and the clone is returned. @param type the content type @return the editor kit ornull
if there is nothing registered for the given type.
Notifies all listeners that have registered interest for notification on this event type. This is normally called by the currently installed EditorKit
if a content type that supports hyperlinks is currently active and there was activity with a link. The listener list is processed last to first. @param e the event @see EventListenerList
Class JEditorPane, AccessibleContext getAccessibleContext()Class JEditorPane, String getContentType()GetGets the AccessibleContext associated with this JEditorPane. For editor panes the AccessibleContext takes the form of an AccessibleJEditorPane. A newcontextAccessibleJEditorPane instance is created if necessary. @return an AccessibleJEditorPane that serves as the AccessibleContext of this JEditorPane
Gets the type of content that this editor is currently set to deal with. This is defined to be the type associated with the currently installedClass JEditorPane, EditorKit getEditorKit()EditorKit
. @return the content typenull
if no editor kit set
Fetches the currently installed kit for handling content. createDefaultEditorKit()
is called to set up a default if necessary. @return the editor kit
Class JEditorPane, EditorKit getEditorKitForContentType(String)Fetches the editor kit to use for the given type of content. This is called when a type is requested that doesn't match the currently installed type. If the component doesn't have anClass JEditorPane, URL getPage()EditorKit
registered for the given type it will try to create anEditorKit
from the defaultEditorKit
registry. If that fails aPlainEditorKit
is used on the assumption that all text documents can be represented as plain text.This method can be reimplemented to use some other kind of type registry. This can be reimplemented to use the Java Activation Framework for example. @param type the non-null content type @return the editor kit
Gets the currentClass JEditorPane, Dimension getPreferredSize()urlURL being displayed. If a URL was not specified in the creation of the document this will returnnull
and relative URL's will not be resolved. @return the URL ornull
if none
Returns the preferred size for theClass JEditorPane, boolean getScrollableTracksViewportHeight()JEditorPane
. The preferred size forJEditorPane
is slightly altered from the preferred size of the superclass. If the size of the viewport has become smaller than the minimum size of the component theScrollablescrollable definition for tracking width or height will turn to false. The default viewport layout will give the preferred size and that is not desired in the case where the scrollable is tracking. In that case the normal preferred size is adjusted to the minimum size. This allows things likehtmlHTML tables to shrink down to their minimum size and then be laid out at their minimum size refusing to shrink any further. @return aDimension
containing the preferred size
Returns true if a viewport should always force the height of thisClass JEditorPane, boolean getScrollableTracksViewportWidth()Scrollable
to match the height of the viewport. @return true if a viewport should force theScrollablesScrollable
's height to match its own.false otherwise
Returns true if a viewport should always force the width of thisClass JEditorPane, InputStream getStream(URL)Scrollable
to match the width of the viewport. @return true if a viewport should force the Scrollables width to match its own.false otherwise
Class JEditorPane, String getText()FetchFetches a stream for the givenurlURL which is about to be loaded by thesetPage
method. By default this simply opens theurlURL and returns the stream. This can be reimplemented to do useful things like fetch the stream from a cache monitor the progress of the stream etc.This method is expected to have the the side effect of
establisingestablishing the content type and therefore setting the appropriateEditorKit
to use for loading the stream.If this the stream was an http connection redirects will be followed and the resulting URL will be set as the
Document.StreamDescriptionProperty
so that relative URL's can be properly resolved. @param page the URL of the page
Returns the text contained in thisClass JEditorPane, String getUIClassID()TextComponent
in terms of the content type of this editor. If an exception is thrown while attempting to retrieve the textnull
will be returned. This is implemented to callJTextComponent.write
with aStringWriter
. @return the text @see #setText
Gets the class ID for the UI. @return theClass JEditorPane, boolean isFocusCycleRoot()IDstring("EditorPaneUI")@see JComponent#getUIClassID @see UIDefaults#getUI
Class JEditorPane, boolean isManagingFocus()OverrideMakesthisJEditorPane
method and returnbe the roottrueof a focus cycle. Thisif your component ismeans that by default tabbing within therooteditor pane will move between components of the pane such as form controls but not out ofathe pane.componentNote
tree with its own focus cyclethat this method always returns true. @see JComponent#isFocusCycleRoot @return true
Turns off tab traversal once focus is gained. @return true to indicate that the focus is being managed; or false otherwiseClass JEditorPane, String paramString()
Returns a string representation of thisClass JEditorPane, void processComponentKeyEvent(KeyEvent)JEditorPane
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJEditorPane
.
Class JEditorPane, void processKeyEvent(KeyEvent)Make sure that TABOverridden to handle processing of tab/shift tab. Ife
identifies a tab the editor pane is not editable andShift-TABhasevents get consumedcomponents then thesoFocusManager
that awtis askeddoesn'ttoattemptpass focustraversalto the next/previous component. @param e the current key event
Class JEditorPane, void read(InputStream, Object)Override processKeyEvent to processMake sure that TAB and Shift-TAB events get consumed so that awt doesn't attempt focus traversal. @param e the current key event
This method initializes from a stream. If the kit is set to be of typeClass JEditorPane, void registerEditorKitForContentType(String, String)HTMLEditorKit
and thedesc
parameter is anHTMLDocument
then it invokes theHTMLEditorKit
to initiate the read. Otherwise it calls the superclass method which loads the model as plain text. @param inThethe stream from which to readfrom@param descAnan object describing the stream.@exception IOException as thrown by the stream being used to initialize.@see JTextComponent#read @see #setDocument
Establishes the default bindings ofClass JEditorPane, void registerEditorKitForContentType(String, String, ClassLoader)type
tonameclassname
. The class will be dynamically loaded later when actually needed and can be safely changed before attempted uses to avoid loading unwanted classes. The prototypeEditorKit
will be loaded withClass.forName
when registered with this method. @param type the non-null
content type @param classname the class to load later
Establishes the default bindings ofClass JEditorPane, void replaceSelection(String)type
tonameclassname
. The class will be dynamically loaded later when actually needed using the givenClassLoader
and can be safely changed before attempted uses to avoid loading unwanted classes. @param type the non-null content type @param classname the class to load later @param loader theClassLoader
to use to load the name
Replaces the currently selected content with new content represented by the given string. If there is no selection this amounts to an insert of the given text. If there is no replacement text (i.e. the content string is empty orClass JEditorPane, void scrollToReference(String)null
) this amounts to a removal of the current selection. The replacement text will have the attributes currently defined for input. If thedocumentcomponent is not editable beep and return.Then if the document is null do nothing. If the content to insert is null or empty ignore it.This method is thread safe although most Swing methods are not. Please see Threads and Swing for more information. @param content the content to replace the selection with. This value can be
null
Class JEditorPane, void setContentType(String)ScrollScrolls the view to the given reference location (i.e.that is the value returned by theUL.getRef
method for theurlURL being displayed). By default this method only knows how to locate a reference in an HTMLDocument. The implementation calls thescrollRectToVisible
method to accomplish the actual scrolling. If scrolling to a reference location is needed for document types other thanhtmlHTML this method should be reimplemented. This method will have no effect if the component is not visible. @param reference the named location to scroll to.
Sets the type of content that this editor handles. This callsClass JEditorPane, void setEditorKit(EditorKit)getEditorKitForContentType
and thensetEditorKit
if an editor kit can be successfully located. This is mostly convenience method that can be used as an alternative to callingsetEditorKit
directly.If there is a charset definition specified as a parameter of the content type specification it will be used when loading input streams using the associated
EditorKit
. For example if the type is specified astext/html; charset=EUC-JP
the content will be loaded using theEditorKit
registered fortext/html
and the Reader provided to theEditorKit
to load unicode into the document will use theEUC-JP
charset for translating to unicode. @param type the non-null
mime type for the content editing support.@see #getContentType @beaninfo description: the type of content
Sets the currently installed kit for handling content. This is the bound property that establishes the content type of the editor. Any old kit is first deinstalled then if kit is non-Class JEditorPane, void setEditorKitForContentType(String, EditorKit)null
the new kit is installed and a default document created for it. APropertyChange
event ("editorKit") is always fired whensetEditorKit
is called.()NOTE: This has the side effect of changing the model because the
EditorKit
is the source of how a particular type of content is modeled. This method will causesetDocument
to be called on behalf of the caller toinsureensure integrity of the internal state. @param kit the desired editor behavior.@see #getEditorKit @beaninfo description: the currently installed kit for handling content bound: true expert: true
DirectlyClass JEditorPane, void setPage(String)setsets the editor kit to use for the given type. A look-and-feel implementation might use this in conjunction withcreateEditorKitForContentType
to install handlers for content types with a look-and-feel bias. @param type the non-null
content type @param k the editor kit to be set
Sets the currentClass JEditorPane, void setPage(URL)urlURL being displayed. @param url the URL for display @exception IOException for anull
or invalid URL specification
Sets the currentClass JEditorPane, void setText(String)urlURL being displayed. The content type of the pane is set and if the editor kit for the pane is non-null
then a new default document is created and the URL is read into it. If theurlURL contains and reference location the location will be scrolled to by calling thescrollToReference
method. If the desired URL is not the one currently being displayed thegetStream
method is called to give subclasses control over the stream provided.This may load either synchronously or asynchronously depending upon the document returned by the
EditorKit
. If theDocument
is of typeAbstractDocument
and has a value returned byAbstractDocument.getAsynchronousLoadPriority
that is greater than or equal to zero the page will be loaded on aseperateseparate thread using that priority.If the document is loaded synchronously it will be filled in with the stream prior to being installed into the editor with a call to
setDocument
which is bound and will fire a property change event. If anIOException
is thrown the partially loaded document will be discarded and neither the document or page property change events will be fired. If the document is successfully loaded and installed a view will be built for it by the UI which will then be scrolled if necessary and then the page property change event will be fired.If the document is loaded asynchronously the document will be installed into the editor immediately using a call to
setDocument
which will fire a document property change event then a thread will be created which will begin doing the actual loading. In this case the page property change event will not be fired by the call to this method directly but rather will be fired when the thread doing the loading has finished. Since the calling thread can not throw anIOException
in the event of failure on the other thread the page property change event will be fired when the other thread is done whether the load was successful or not. @param page the URL of the page @exception IOException for anull
or invalid page specification or exception from the stream being read.@see #getPage @beaninfo description: the URL used to set content bound: true expert: true
Sets the text of thisTextComponent
to the specified content which is expected to be in the format of the content type of this editor. For example if the type is set totext/html
the string should be specified in terms ofhtmlHTML.This is implemented to remove the contents of the current document and replace them by parsing the given string using the current
EditorKit
. This gives the semantics of the superclass by not changing out the model while supporting the content type currently set on this component. The assumption is that the previous content is relatively small and that the previous content doesn't have side effects. Both of those assumptions can be violated and cause undesirable results. To avoid this create a new documentgetEditorKit().createDefaultDocument()
and replace the existingDocument
with the new one. You are then assured the previousDocument
won't have any lingering state.
- Leaving the existing model in place means that the old view will be torn down and a new view created where replacing the document would avoid the tear down of the old view.
- Some formats (such as
htmlHTML) can install things into the document that can influence future contents. HTML can have style information embedded that would influence the next content installed unexpectedly.An alternative way to load this component with a string would be to create a StringReader and call the read method. In this case the model would be replaced after it was initialized with the contents of the string.
This method is thread safe although most Swing methods are not. Please see Threads and Swing for more information. @param t the new text to be set @see #getText @beaninfo description: the text of this component
JFileChooser
provides a simple mechanism for the user tochooserchoose a file. For information about usingJFileChooser
see How to Use File Choosers a section in The Java Tutorial.The following code pops up a file chooser
infor theusersuser's home directory thatonlysees only .jpg and .gif images:JFileChooser chooser = new JFileChooser(); // Note: source for@beaninfo attribute: isContainer false description: A component which allows for the interactive selection of a font. @version 1.ExtensionFileFilterExampleFileFilter can be found intheFileChooserDemo // underSwingSetthe demo/jfc directory inExtensionFileFilterthe Java 2 SDK Standard Edition. ExampleFileFilter filter = newExtensionFileFilterExampleFileFilter(); filter.addExtension("jpg"); filter.addExtension("gif"); filter.setDescription("JPG & GIF Images"); chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(parent); if(returnVal == JFileChooser.APPROVE_OPTION) { System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName()); }49 0465 03/2214/9900 @author Jeff Dinkins
Class JFileChooser.AccessibleJFileChooser, AccessibleRole getAccessibleRole()TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJFileChooser
class. Itcontextprovidesforan implementation of the Java Accessibility API appropriate to file chooserthisuser-interfaceobjectelements.
GetGets the role of this object. @return an instance of AccessibleRole describing the role of the object @see AccessibleRole
Class JFileChooser, constructor JFileChooser(File)CreatesConstructs aJFileChooser
pointing to the user's home directory.
Class JFileChooser, constructor JFileChooser(File, FileSystemView)CreatesConstructs aJFileChooser
using the givenFile
as the path. Passing in anull
file causes the file chooser to point to theusersuser's home directory. @paramdirectorycurrentDirectory aFile
object specifying the path to a file or directory
Class JFileChooser, constructor JFileChooser(FileSystemView)CreatesConstructs aJFileChooser
using the given current directory andFileSystemView
.
Class JFileChooser, constructor JFileChooser(String)CreatesConstructs aJFileChooser
using the givenFileSystemView
.
Class JFileChooser, constructor JFileChooser(String, FileSystemView)CreatesConstructs aJFileChooser
using the given path. Passing in anull
string causes the file chooser to point to theusersuser's home directory. @parampathcurrentDirectoryPath aString
giving the path to a file or directory
Class JFileChooser, boolean accept(File)CreatesConstructs aJFileChooser
using the given current directory path andFileSystemView
.
Returns true if the file should be displayed. @param f the File
@return true if the file should be displayed otherwise false @see FileFilter#accept
Class JFileChooser, void addActionListener(ActionListener)Class JFileChooser, void addChoosableFileFilter(FileFilter)addsAdds anActionListener
to the button. @param l the listener to be added
Adds a filter to the list of user choosable file filters. @param filter the FileFilter
to add to the choosable file filter list @beaninfo preferred: true bound: true description: Adds a filter to the list of user choosable file filters. @ see #getChoosableFileFilters @ see #removeChoosableFileFilter @ see #resetChoosableFileFilter
Class JFileChooser, void approveSelection()Called by the UI when the user hits theClass JFileChooser, void cancelSelection()approveApprove button (AKAlabeled "Open" or "Save")buttonby default). This can alsobybe called by the programmer.
Called by the UI when the userClass JFileChooser, void ensureFileIsVisible(File)hitschooses thecancelCancel button. This can also be called by the programmer.
Class JFileChooser, void fireActionPerformed(String)MakeMakes sure that the specified file is viewable and not hidden. @param f a File object
Class JFileChooser, FileFilter getAcceptAllFileFilter()NotifyNotifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. @see EventListenerList
Returns theClass JFileChooser, AccessibleContext getAccessibleContext()AcceptAll
file filter(e.g.(For example on Win32 this would be All Files (*.*)on windows).
Class JFileChooser, JComponent getAccessory()GetGets the AccessibleContext associated with this JFileChooser. For file choosers the AccessibleContext takes the form of an AccessibleJFileChooser. A new AccessibleJFileChooser instance is created if necessary. @return an AccessibleJFileChooser that serves as the AccessibleContext of this JFileChooser
Class JFileChooser, int getApproveButtonMnemonic()ReturnReturns the accessory component. @return this JFileChooser's accessory component or null @see #setAccessory
Returns the approve button's mnemonic. @return anClass JFileChooser, String getApproveButtonText()intinteger value for the mnemonic key @see #setApproveButtonMnemonic
Returns the text used in theClass JFileChooser, String getApproveButtonToolTipText()ApproveButton
in theFileChooserUI
. Ifnull
the UI object will determine the button's text. Typically this would be "Open" or "Save". @return the text used in theApproveButton
@see #setApproveButtonText @see #setDialogType @see #showDialog
Returns the tooltip text used in theClass JFileChooser, FileFilter[] getChoosableFileFilters()ApproveButton
. Ifnull
the UI object will determine the button's text. @return the text used in theApproveButton
@see #setApproveButtonText @see #setDialogType @see #showDialog
Gets the list of user choosable file filters. @return a FileFilter
array containing all the choosable file filters @ see #addChoosableFileFilter @ see #removeChoosableFileFilter @ see #resetChoosableFileFilter
Class JFileChooser, String getDescription(File)Returns the file description. @param f theClass JFileChooser, String getDialogTitle()File
@return theString
containing the file description forf
@see FileView#getDescription
Gets the string that goes in theClass JFileChooser, int getDialogType()FileChooserJFileChooser
's titlebar. @see #setDialogTitle
Returns the type of this dialog. The default isClass JFileChooser, FileFilter getFileFilter()JFileChooser.OPEN_DIALOG
. @return the type of dialog to be displayed:@see #setDialogType
- JFileChooser.
OPEN_DIALOG- JFileChooser.SAVE_DIALOG
- JFileChooser.CUSTOM_DIALOG
Returns the currently selected file filter. @return the current file filterClass JFileChooser, int getFileSelectionMode().@see #setFileFilter @see #addChoosableFileFilter
Returns the current file-selection mode.Class JFileChooser, FileSystemView getFileSystemView()@paramThe defaultanisintJFilesChooser.FILES_ONLY
.indicating@return the type ofdialogfiles to be displayed one of the following:@see #setFileSelectionMode
- JFileChooser.
FILES_ONLY- JFileChooser.DIRECTORIES_ONLY
- JFileChooser.FILES_AND_DIRECTORIES
Returns the file system view. @return the FileSystemView
object @see #setFileSystemView
Class JFileChooser, Icon getIcon(File)Returns the icon for this file or type of file depending on the system. @param f theClass JFileChooser, String getName(File)File
@return theIcon
for this file or type of file @see FileView#getIcon
Returns theClass JFileChooser, File getSelectedFile()file namefilename. @param f theFile
@return theString
containing the filename forf
@see FileView#getName
Returns the selected file. This can be set either by the programmer viaClass JFileChooser, File[] getSelectedFiles()setFile
or by a user action such as either typing the filename()intinto the UI or selecting the file from a list in the UI. @see #setSelectedFile @return the selected file
Returns a list of selected files if theClass JFileChooser, String getTypeDescription(File)filechooserfile chooser is set to allowmulti-multiple selection.
Returns the file type. @param f theClass JFileChooser, String getUIClassID()File
@return theString
containing the file type description forf
@see FileView#getTypeDescription
Returns a string that specifies the name of the L&F class that renders this component. @return the string "Class JFileChooser, boolean isDirectorySelectionEnabled()ButtonUIFileChooserUI" @see JComponent#getUIClassID @see UIDefaults#getUI @beaninfo expert: true description: A string that specifies the name of the L&F class.
Convenience call that determines if directories are selectable based on the current file selection mode. @see #setFileSelectionMode @see #getFileSelectionModeClass JFileChooser, boolean isFileHidingEnabled()
Class JFileChooser, boolean isFileSelectionEnabled()IfReturns true if hidden files are not shown in thefilechooserfile chooser; otherwise returns false. @return the status of the file hiding property @see #setFileHidingEnabled
Convenience call that determines if files are selectable based on the current file selection mode. @see #setFileSelectionMode @see #getFileSelectionModeClass JFileChooser, boolean isMultiSelectionEnabled()
Returns true if multiple files can be selected. @return true if multiple files can be selectedClass JFileChooser, boolean isTraversable(File).@see #setMultiSelectionEnabled
Returns true if the file (directory) can be visited. Returns false if the directory cannot be traversed. @param f the File
@return true if the file/directory can be traversed otherwise false @see FileView#isTraversable
Class JFileChooser, String paramString()Returns a string representation of thisClass JFileChooser, void removeActionListener(ActionListener)JFileChooser
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJFileChooser
.
Class JFileChooser, boolean removeChoosableFileFilter(FileFilter)removesRemoves anActionListener
from the button. @param l the listener to be removed
Removes a filter from the list of user choosable file filters. Returns true if the file filter was removedClass JFileChooser, void rescanCurrentDirectory();. @ see #addChoosableFileFilter @ see #getChoosableFileFilters @ see #resetChoosableFileFilter
Tells the UI to rescanClass JFileChooser, void resetChoosableFileFilters()it'sits files list from the current directory.
Resets the choosable file filter list to its starting state. Normally this removes all added file filters while leaving the AcceptAll
file filter. @see #addChoosableFileFilter @see #getChoosableFileFilters @see #removeChoosableFileFilter
Class JFileChooser, void setAccessory(JComponent)Sets the accessory component. An accessory is often used to show a preview image of the selected file; however it can be used for anything that the programmer wishesClass JFileChooser, void setApproveButtonMnemonic(char)-such as extra custom file chooser controls.Note: if there was a previous accessory you should unregister any listeners that the accessory might have registered with the file chooser. @beaninfo preferred: true bound: true description: Sets the accessory component on the
FileChooserJFileChooser.
Sets the approve button's mnemonic using a character. @paramClass JFileChooser, void setApproveButtonMnemonic(int)anmnemonic acharcharacter value for the mnemonic key @see #getApproveButtonMnemonic
Sets the approve button's mnemonic using a numeric keycode. @param mnemonic anClass JFileChooser, void setApproveButtonText(String)intinteger value for the mnemonic key @beaninfo preferred: true bound: true description: The mnemonic key accelerator for the ApproveButton. @see #getApproveButtonMnemonic
Sets the text used in theClass JFileChooser, void setApproveButtonToolTipText(String)ApproveButton
in theFileChooserUI
. @beaninfo preferred: true bound: true description: The text that goes in theAprroveButtonApproveButton. @param approveButtonText the text used in theApproveButton
@see #getApproveButtonText @see #setDialogType @see #showDialog
Sets the tooltip text used in theClass JFileChooser, void setCurrentDirectory(File)ApproveButton
. Ifnull
the UI object will determine the button's text. @beaninfo preferred: true bound: true description: The tooltip text for the ApproveButton. @return the text used in the ApproveButton @see #setApproveButtonText @see #setDialogType @see #showDialog
Sets the current directory. Passing inClass JFileChooser, void setDialogTitle(String)null
sets thefilechooserfile chooser to point to theusersuser's home directory. If the file passed in ascurrentDirectory
is not a directory the parent of the file will be used as the currentDirectory. If the parent is not traversable then it will walk up the parent tree until it finds a traversabledirecotrydirectory or hits the root of the file system. @beaninfo preferred: true bound: true description:theThe directory that theFileChooserJFileChooser is showing files of. @paramcurrentDirectorydir the current directory to point to @see #getCurrentDirectory
Sets the string that goes in theClass JFileChooser, void setDialogType(int)FileChooserJFileChooser
window's title bar. @param dialogTitle the newString
for the title bar @beaninfo preferred: true bound: true description: The title of theFileChooserJFileChooser dialog window. @see #getDialogTitle
Sets the type of this dialog. UseClass JFileChooser, void setFileFilter(FileFilter)OPEN_DIALOG
when you want to bring up afilechooserfile chooser that the user can use to open a file. Likewise useSAVE_DIALOG
for letting the user choose a file for saving. UseCUSTOM_DIALOG
when you want to use thefilechooserfile chooser in a context other than "Open" or "Save". For instance you might want to bring up afilechooserfile chooser that allows the user to choose a file to execute. Note that you normally would not need to set theFileChooserJFileChooser
to useCUSTOM_DIALOG
since a call tosetApproveButtonText
does this for you. The default dialog type isJFileChooser.OPEN_DIALOG
. @param dialogType the type of dialog to be displayed:@exception IllegalArgumentException if
- JFileChooser.
OPEN_DIALOG- JFileChooser.SAVE_DIALOG
- JFileChooser.CUSTOM_DIALOG
dialogType
is not legal @beaninfo preferred: true bound: true description: The type (open save custom) of theFileChooserJFileChooser. enum: OPEN_DIALOG JFileChooser.OPEN_DIALOG SAVE_DIALOG JFileChooser.SAVE_DIALOG CUSTOM_DIALOG JFileChooser.CUSTOM_DIALOG @see #getDialogType @see #setApproveButtonText
Sets the currentClass JFileChooser, void setFileHidingEnabled(boolean)File Filterfile filter. The file filter is used by thefilechooserfile chooser to filter out files fromview fromthe user's view. @beaninfo preferred: true bound: true description: Sets the File Filter used to filter out files of type. @param filter the new current file filter to use @see #getFileFilter
Sets file hiding on or off. If true hidden files are not shown in theClass JFileChooser, void setFileSelectionMode(int)filechooserfile chooser. The job of determining which files areshowshown is done by theFileView
. @beaninfo preferred: true bound: true description: Sets file hiding on or off. @param b the boolean value that determines whether file hiding is turned onor not.@see #isFileHidingEnabled
Sets theClass JFileChooser, void setFileSystemView(FileSystemView)FileChooserJFileChooser
to allow the user to just select files just select directories or select both files and directories. The default isJFilesChooser.FILES_ONLY
. @param mode the type of files to be displayed:@exception IllegalArgumentException if
- JFileChooser.FILES_ONLY
- JFileChooser.DIRECTORIES_ONLY
- JFileChooser.FILES_AND_DIRECTORIES
mode
is an illegal Dialog mode @beaninfo preferred: true bound: true description: Sets the types of files that theFileChooserJFileChooser can choose. enum: FILES_ONLY JFileChooser.FILES_ONLY DIRECTORIES_ONLY JFileChooser.DIRECTORIES_ONLY FILES_AND_DIRECTORIES JFileChooser.FILES_AND_DIRECTORIES @param dialogType the type of dialog to be displayed: FILES_ONLY DIRECTORIES_ONLY FILES_AND_DIRECTORIES @see #getFileSelectionMode
Sets the file system viewClass JFileChooser, void setFileView(FileView)whichthat theJFileChooser
usesto accessfor accessing andcreatecreating file systemresoucesresources such as finding the floppy drive and getting a list of root drives. @param fsv the newFileSystemView
@beaninfo expert: true bound: true description: Sets the FileSytemView used to get filesystem information. @see FileSystemView
Sets the file view to used to retrieve UI information such as the icon that represents a file or the type description of a file. @beaninfo preferred: true bound: true description: Sets the File View used to get file type information. @see #getFileViewClass JFileChooser, void setMultiSelectionEnabled(boolean)
Sets theClass JFileChooser, void setSelectedFile(File)filechooserfile chooser to allow multiple file selections.NOTE: this functionality is not yet implemented in the current L&Fs. @beaninfo bound: true description: Sets multiple file selection mode. @see #isMultiSelectionEnabled
Sets the selected file. If the file's parent directory is not the current directory changes the current directory to be the file's parent directory. @beaninfo preferred: true bound: true @see #getSelectedFile @paramClass JFileChooser, void setSelectedFiles(File[])selectedFilefile the selected file
Sets the list of selected files if theClass JFileChooser, void setup(FileSystemView)filechooserfile chooser is set to allowmulti-multiple selection. @beaninfo bound: true description:theThe list of selected files if the chooser is inmulti-multiple selection mode.
Class JFileChooser, int showDialog(Component, String)PerformPerforms common constructor initialization and setup.
Pops a custom file chooser dialog with a customClass JFileChooser, int showOpenDialog(Component)ApproveButton.approvee.gbutton.filechooser.showDialog(parentWindowFor"RunexampleApplication");thewouldfollowing codepoppops up afilechooserfile chooser with a "Run Application" button (instead of the normal "Save" or "Open" button):filechooser.showDialog(parentFrame "Run Application"); Alternatively the following codewilldoesdothe same thing:JFileChooser chooser = new JFileChooser(null); chooser.setApproveButtonText("Run Application"); chooser.showDialog(<--PENDING(jeff) - the following method should be added to the api: showDialog(Component parent);--> <--PENDING(kwalrath) - should specify modality and what "depends" means.-->thisparentFrame null);The
@param approveButtonText the text of theparent
argument determines two things: the frame on which the open dialog depends and the component whose position the look and feel should consider when placing the dialog. If the parent is aFrame
object (such as aJFrame
) then the dialog depends on the frame and the look and feel positions the dialog relative to the frame (for example centered over the frame). If the parent is a component then the dialog depends on the frame containing the component and is positioned relative to the component (for example centered over the component). If the parent isnull
then the dialog depends on no visible window and it's placed in a look-and-feel-dependent position such as the center of the screen. @param parent the parent component of the dialog; can benull
ApproveButton
@return the return state of thefilechooserfile chooser on popdown:
- JFileChooser.
CANCEL_OPTION- JFileChooser.APPROVE_OPTION
- JFileCHooser.ERROR_OPTION if an error occurs or the dialog is dismissed
Pops up an "Open File" file chooser dialog. Note that the text that appears in the approve button is determined by the L&F. @param parent the parent component of the dialog can beClass JFileChooser, int showSaveDialog(Component)null
; seeshowDialog
for details @return the return state of thefilechooserfile chooser on popdown:@see #showDialog
- JFileChooser.
CANCEL_OPTION- JFileChooser.APPROVE_OPTION
- JFileCHooser.ERROR_OPTION if an error occurs or the dialog is dismissed
Pops up a "Save File" file chooser dialog. Note that the text that appears in the approve button is determined by the L&F. @param parent the parent component of the dialog can beClass JFileChooser, void updateUI()null
; seeshowDialog
for details @return the return state of thefilechooserfile chooser on popdown:@see #showDialog
- JFileChooser.
CANCEL_OPTION- JFileChooser.APPROVE_OPTION
- JFileCHooser.ERROR_OPTION if an error occurs or the dialog is dismissed
Notification from the UIFactory
that the L&F has changed. @see JComponent#updateUI
Class JFileChooser, String ACCESSORY_CHANGED_PROPERTYSays that a different accessory component is in useClass JFileChooser, String APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY.(Forfor example to preview files.).
Identifies change in the mnemonic for the approve (yes ok) buttonClass JFileChooser, String APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY.
Identifies change in the tooltip text for the approve (yes ok) buttonClass JFileChooser, String APPROVE_SELECTION.
Instruction to approve the current selection (Class JFileChooser, String CHOOSABLE_FILE_FILTER_CHANGED_PROPERTYSamesame as pressing yes or ok.).
Identifies a change in the list of predefined file filters the user can choose from.Class JFileChooser, int CUSTOM_DIALOG
Type value indicating that theClass JFileChooser, String DIALOG_TYPE_CHANGED_PROPERTYFileChooserJFileChooser
supports a developer-specifiedsepcifiedfile operation.
Identifies a change in the type of files displayed (files only directories only or both files and directories).Class JFileChooser, int OPEN_DIALOG
Type value indicating that theClass JFileChooser, int SAVE_DIALOGFileChooserJFileChooser
supports an "Open" file operation.
Type value indicating that theClass JFileChooser, String SELECTED_FILES_CHANGED_PROPERTYFileChooserJFileChooser
supports a "Save" file operation.
Class JFileChooser, String SELECTED_FILE_CHANGED_PROPERTYIdentifesIdentifies change in user's multiple-file selection.
IdentifesIdentifies change in user's single-file selection.
An extended version ofjava.awt.Frame
that adds support forinterposing input and painting behavior in fronttheofJFC/Swingthecomponentframe'sarchitecture.childrenYou(seecanglassPane)findsupporttask-orientedfor special childrendocumentation about usingthatJFrame
areinmanagedThebyJavaaTutorialLayeredPanein(seetherootPane)sectionandHowfor Swingto MakeMenuBarsFrames.The
JFrame
class is slightly incompatible withjava.awt.Frame
. Like all other JFC/Swing top-level containers aJFrame contains a
JRootPane
asit'sits only child. ThecontentPanecontent paneshould beprovided by theparentrootof any childrenpane should asofa rule contain all the non-menu components displayed by theJFrame
. This is differentthanfromjava.awt.the AWTFrame
e.gcase. For example to add a child to an AWTFrameframe you'd write:frame.add(child);However usingJFrame
you need to add the child to theJFramesJFrame's
contentPanecontent pane instead:frame.getContentPane().add(child);The same is true for settingLayoutManagerslayout managers removing components listing childrenetcand so on. All these methods should normally be sent to thecontentPane()content pane instead of the JFrame itself. ThecontentPane()content pane will always be non-null. Attempting to set it to null will cause the JFrame to throw an exception. The defaultcontentPane()content pane will have a BorderLayout manager set on it.
Please see the JRootPane documentation for a complete description of the contentPane glassPane and layeredPane properties.Unlikeits parent classajava.awt.Frame
youacanJFrame
tell ahas someJFramenotion of how to respond when the user attempts to close the window. The default behavior is to simply hide the JFrame when the user closes the window. To change the default behavior you invoke the method #setDefaultCloseOperation.To make theJFrame
remain open unless youhandlebehave thewindow-closing event andsameexplicitly invokeas a
dispose()Frame(or exit the appinstancewhich is also pretty effective)usesetDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE)
.That makes the JFrame behave the same asFor more information on content panes and
java.awt.Frameother features that root panes provide see Using Top-Level Containers in The Java Tutorial.AIn
thirdaoptionmulti-screenletsenvironment youcompletelycandispose ofcreate atheJFrame
window when it closeson a different screeninsteaddevice.ofSee java.awt.Framemerely hiding itfor more information.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JFrame key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JRootPane @see #setDefaultCloseOperation @see java.awt.event.WindowListener#windowClosing @beaninfo attribute: isContainer true attribute: containerDelegate getContentPane description: A toplevel window which can be minimized to an icon. @version 1.
65770403/2214/9900 @author Jeff Dinkins @author Georges Saab @author David Kloba
Class JFrame.AccessibleJFrame, AccessibleComponent getAccessibleComponent()TheThis classusedimplementstoaccessibility supportobtainfor theAccessibleRoleJFrame
forclass. It provides an implementation of the Java Accessibility API appropriate to framethisuser-interfaceobjectelements.
Get the AccessibleComponent associated with this object if one exists. Otherwise return null. @return the componentClass JFrame.AccessibleJFrame, void setBackground(Color)
Set the background color of this object. (For transparency see isOpaque
.) @param c the new Color for the background @see Component#isOpaque
Constructs a newClass JFrame, constructor JFrame(String)Frameframe that is initially invisible. @see Component#setSize @see Component#setVisible
Class JFrame, void addImpl(Component, Object, int)ConstructsCreates a new initially invisibleFrame
with the specified title. @param title the title for the frame @see Component#setSize @see Component#setVisible
By default children may not be added directly toClass JFrame, JRootPane createRootPane()athis component they must be added to its contentPane instead. For example:thisComponent.getContentPane().add(child)An attempt to add to directly to this component will cause an runtime exception to be thrown. Subclasses can disable this behavior. @seeparam#setRootPaneCheckingEnabledcomp the component to be enhanced @param constraints the constraints to be respected @param index the index @exception Error if called withrootPaneChecking
true @see #setRootPaneCheckingEnabled
Called by the constructor methods to create the default rootPane
.
Class JFrame, void frameInit()Called by the constructors to init the JFrame
properly.
Class JFrame, AccessibleContext getAccessibleContext()Class JFrame, Container getContentPane()GetGets the AccessibleContext associated with this JFrame. For JFrames the AccessibleContext takes the form of an AccessibleJFrame. A new AccessibleJFrame instance is created if necessary. @return an AccessibleJFrame that serves as the AccessibleContext of this JFrame
Returns theClass JFrame, int getDefaultCloseOperation()contentPane
object for this frame. @return thecontentPane
property @see #setContentPane @see RootPaneContainer#getContentPane
Returns the operationClass JFrame, Component getGlassPane()whichthat occurs when the user initiates a "close" on this frame. @return anintinteger indicating the window-close operation @see #setDefaultCloseOperation
Returns theClass JFrame, JMenuBar getJMenuBar()glassPane
object for this frame. @return theglassPane
property @see #setGlassPane @see RootPaneContainer#getGlassPane
Returns the menubar set on this frame. @return the menubar for this frame @see #setJMenuBarClass JFrame, JLayeredPane getLayeredPane()
Returns theClass JFrame, JRootPane getRootPane()layeredPane
object for this frame. @return thelayeredPane
property @see #setLayeredPane @see RootPaneContainer#getLayeredPane
Returns theClass JFrame, boolean isRootPaneCheckingEnabled()rootPane
object for this frame. @return therootPane
property @see #setRootPane @see RootPaneContainer#getRootPane
Returns whether calls toClass JFrame, String paramString()add
andsetLayout
cause an exception to be thrown. @return true ifadd
andsetLayout
are checked; false otherwise @see #addImpl @see #setLayout @see #setRootPaneCheckingEnabled
Returns a string representation of thisClass JFrame, void setContentPane(Container)JFrame
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJFrame
.
Sets theClass JFrame, void setDefaultCloseOperation(int)contentPane
property. This method is called by the constructor. @param contentPane thecontentPane
object for this frame @exception java.awt.IllegalComponentStateException (a runtime exception) if the content pane parameter isnull
@see #getContentPane @see RootPaneContainer#setContentPane @beaninfo hidden: true description: The client area of the frame where child components are normally inserted.
Sets the operationClass JFrame, void setGlassPane(Component)whichthat will happen by default when the user initiates a "close" on this frame.The possibleYouchoices are defined inmust specify one of theWindowConstantsfollowinginterfacechoices:
DO_NOTHING_ON_CLOSE
-(defineddoinWindowConstants
):notDon't do anything-; require the program to handle the operation in thewindowClosing
method of a registeredWindowListener
object.HIDE_ON_CLOSE
-(defined inWindowConstants
):automaticallyAutomatically hide the frame after invoking any registeredWindowListener
objects.DISPOSE_ON_CLOSE
(defined in-WindowConstants
):automaticallyAutomatically hide and dispose the frame after invoking any registeredWindowListener
objects.EXIT_ON_CLOSE
(defined in-JFrame
): Exit the applicationby wayusingoftheSystem
.exit
.Onlymethod.useUse this only in applications.The value is set to
HIDE_ON_CLOSE
by default. @see #addWindowListener @see #getDefaultCloseOperation @see WindowConstants @beaninfo preferred: true enum: DO_NOTHING_ON_CLOSE WindowConstants.DO_NOTHING_ON_CLOSE HIDE_ON_CLOSE WindowConstants.HIDE_ON_CLOSE DISPOSE_ON_CLOSE WindowConstants.DISPOSE_ON_CLOSE EXIT_ON_CLOSE3JFrame.EXIT_ON_CLOSE description: The frame's default close operation.
Sets theClass JFrame, void setLayeredPane(JLayeredPane)glassPane
property. This method is called by the constructor. @param glassPane theglassPane
object for this frame @see #getGlassPane @see RootPaneContainer#setGlassPane @beaninfo hidden: true description: A transparent pane used for menu rendering.
Sets theClass JFrame, void setLayout(LayoutManager)layeredPane
property. This method is called by the constructor. @param layeredPane thelayeredPane
object for this frame @exception java.awt.IllegalComponentStateException (a runtime exception) if the layered pane parameter isnull
@see #getLayeredPane @see RootPaneContainer#setLayeredPane @beaninfo hidden: true description: The panewhichthat holds the various frame layers.
By default the layout of this component may not be set the layout of itsClass JFrame, void setRootPane(JRootPane)contentPane
should be set instead. For example:thiComponent.getContentPane().setLayout(new BorderLayout())An attempt to set the layout of this component will cause an runtime exception to be thrown. Subclasses can disable this behavior. @seeparam#setRootPaneCheckingEnabledmanager theLayoutManager
@exception Error if called withrootPaneChecking
true @see #setRootPaneCheckingEnabled
Sets theClass JFrame, void setRootPaneCheckingEnabled(boolean)rootPane
property. This method is called by the constructor. @param root therootPane
object for this frame @see #getRootPane @beaninfo hidden: true description: the RootPane object for this frame.
Determines whether calls toClass JFrame, void update(Graphics)add
andsetLayout
will cause an exception to be thrown. @param enableda boolean valuetrue if checking is to be enabled whichcausecauses the exceptions to be thrown @see #addImpl @see #setLayout @see #isRootPaneCheckingEnabled @beaninfo hidden: true description: Whether the add and setLayout methods throw exceptions when invoked.
Just callsClass JFrame, AccessibleContext accessibleContextpaint(g)
. This method was overridden to prevent anunneccessaryunnecessary call to clear the background. @param g the Graphics context in which to paint
The accessible context property.Class JFrame, JRootPane rootPane
TheClass JFrame, boolean rootPaneCheckingEnabledJRootPane
instance that manages thecontentPane
and optionalmenuBar
for this frame as well as theglassPane
. @see JRootPane @see RootPaneContainer
If true then calls toadd
andsetLayout
will cause an exception to be thrown. The default is false. @see #isRootPaneCheckingEnabled @see #setRootPaneCheckingEnabled
A lightweight object that provides many of the features of a native frame including dragging closing becoming an icon resizing title display and support for a menu bar.GenerallyForyoutask-orientedcreate an instance anddocumentation and examples ofaddusing internal framesitsee How to Use Internal Frames aJDesktopPane.sectionLookinandThefeelJavaspecific-actionsTutorial.are thenGenerally
(automaticallyyou)adddelegatedJInternalFrame
s totheaDesktopManagerJDesktopPane
.object maintained byThe UI delegates theJDesktopPanelook-and-feel-specific(asactions to theDesktopManager
setobject maintained by theUI)JDesktopPane
.The
JInternalFrame
contentPane
is where you add child components. So to create aJInternalFrame
that has a number of buttons arranged with aBorderLayout
object you might do something like this:JComponent c = (JComponent) frame.getContentPane(); c.setLayout(new BorderLayout()); c.add(new JButton() BorderLayout.NORTH); c.add(new JButton() BorderLayout.CENTER);ThecontentPane
is actually managed by an instance ofJRootPane
which also manages alayoutPane
glassPane
and optionalmenuBar
for the frame. Please see theJRootPane
documentation for a complete description of these components.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JInternalFrame key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JDesktopPane @see DesktopManager @see JInternalFrame.JDesktopIcon @see JRootPane @version 1.
93112 03/0814/00 @author David Kloba @author Rich Schiavi @beaninfo attribute: isContainer true attribute: containerDelegate getContentPane description: A frame container which is contained within another window.
Class JInternalFrame.AccessibleJInternalFrame, String getAccessibleName()TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJInternalFrame
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to internal frame user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Get the accessible name of this object.Class JInternalFrame.AccessibleJInternalFrame, AccessibleValue getAccessibleValue()This should almost never return java.awt.Component.getName() as that generally isn't a localized name and doesn't have meaning for the user. If the object is fundamentally a text object (e.g. a menu item) the accessible name should be the text of the object (e.g. "save"). If the object has a tooltip the tooltip text may also be an appropriate String to return.@return the localized name of the object -- can be null if this object does not have a name @see #setAccessibleName
Get the AccessibleValue associated with this object.if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleValue interface on behalf of itself. @return this object
Class JInternalFrame.JDesktopIcon.AccessibleJDesktopIcon, AccessibleValue getAccessibleValue()TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJInternalFrame.JDesktopIcon
class.role forIt providesthisan implementation of the Java Accessibility API appropriate to desktop icon user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Get the AccessibleValue associated with this object.if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleValue interface on behalf of itself. @return this object
GetGets the AccessibleContext associated with thisJComponentJDesktopIcon. For desktop icons the AccessibleContext takes the form of an AccessibleJDesktopIcon. A new AccessibleJDesktopIcon instance is created if necessary. @return an AccessibleJDesktopIcon that serves as the AccessibleContext of thisJComponentJDesktopIcon
Creates a non-resizable non-closable non-maximizable non-iconifiable JInternalFrame
with no title.
Class JInternalFrame, constructor JInternalFrame(String)Creates a non-resizable non-closable non-maximizable non-iconifiableClass JInternalFrame, constructor JInternalFrame(String, boolean)JInternalFrame
with the specified title. @param title theString
to display in the title bar.
Creates a non-closable non-maximizable non-iconifiableClass JInternalFrame, constructor JInternalFrame(String, boolean, boolean)JInternalFrame
with the specified title and with resizability specified. @param title theString
to display in the title bar.@param resizable if true the frame can be resized
Creates a non-maximizable non-iconifiableClass JInternalFrame, constructor JInternalFrame(String, boolean, boolean, boolean)JInternalFrame
with the specified title and with resizability and closability specified. @param title theString
to display in the title bar.@param resizable if true the frame can be resized @param closable if true the frame can be closed
Creates a non-iconifiableClass JInternalFrame, constructor JInternalFrame(String, boolean, boolean, boolean, boolean)JInternalFrame
with the specified title and with resizability closability and maximizability specified. @param title theString
to display in the title bar.@param resizable if true the frame can be resized @param closable if true the frame can be closed @param maximizable if true the frame can be maximized
Creates aClass JInternalFrame, void addImpl(Component, Object, int)JInternalFrame
with the specified title and with resizability closability maximizability and iconifiability specified. All constructors defer to this one. @param title theString
to display in the title bar.@param resizable if true the frame can be resized @param closable if true the frame can be closed @param maximizable if true the frame can be maximized @param iconifiable if true the frame can be iconified
By default children may not be added directly to a this component they must be added to itsClass JInternalFrame, JRootPane createRootPane()contentPane
instead. For example:thisComponent.getContentPane().add(child)An attempt to add to directly to this component will cause an runtime exception to be thrown. Subclasses can disable this behavior. @see #setRootPaneCheckingEnabled @exception Error if called withrootPaneCheckingisRootPaneChecking
true
Called by the constructor to set up theClass JInternalFrame, AccessibleContext getAccessibleContext()JRootPane
. @return a newJRootPane
@see JRootPane
Class JInternalFrame, Component getGlassPane()GetGets the AccessibleContext associated with thisJComponentJInternalFrame. For internal frames the AccessibleContext takes the form of an AccessibleJInternalFrame. A new AccessibleJInternalFrame instance is created if necessary. @return an AccessibleJInternalFrame that serves as the AccessibleContext of thisJComponentJInternalFrame
Returns theClass JInternalFrame, JMenuBar getJMenuBar()glassPane
object for this frame. @return theglassPane
object @see RootPaneContainer#setGlassPane
Returns the currentClass JInternalFrame, JLayeredPane getLayeredPane()JMenuBar
for thisJInternalFrame
ornull
if no menu bar has been set. @return theJMenuBar
used by this frame @see #setJMenuBar
Returns theClass JInternalFrame, JMenuBar getMenuBar()layeredPane
object for this frame. @return thelayeredPane
object @see RootPaneContainer#setLayeredPane @see RootPaneContainer#getLayeredPane
Returns the currentClass JInternalFrame, JRootPane getRootPane()JMenuBar
for thisJInternalFrame
ornull
if no menu bar has been set. @return the current menubar ornull
if none has been set @deprecated As of Swing version 1.0.3 replaced bygetJMenuBar()
.
Returns theClass JInternalFrame, String getTitle()rootPane
object for this frame. @return therootPane
property @see RootPaneContainer#getRootPane
Returns the title of theClass JInternalFrame, InternalFrameUI getUI()JInternalFrame
. @return aString
containing the frame's title @see #setTitle
Returns the L&F object that renders this component. @return the InternalFrameUI
object that renders this component
Class JInternalFrame, String getUIClassID()Returns the name of the L&F classClass JInternalFrame, boolean isClosable()thatwhich renders this component. @return the string "InternalFrameUI" @see JComponent#getUIClassID @see UIDefaults#getUI @beaninfo description: UIClassID
Returns whether this JInternalFrame
be closed by some user action. @return true if the frame can be closed
Class JInternalFrame, boolean isClosed()Returns whether this JInternalFrame
is currently closed. @return true if the frame is closed
Class JInternalFrame, boolean isIcon()Returns whether the JInternalFrame
is currently iconified. @return true if the frame is iconified
Class JInternalFrame, boolean isIconifiable()Returns whether the JInternalFrame
can be iconified by some user action. @return true if the frame can be iconified
Class JInternalFrame, boolean isMaximizable()Returns whether the JInternalFrame
can be maximized by some user action. @return true if the frame can be maximized
Class JInternalFrame, boolean isMaximum()Returns whether the JInternalFrame
is currently maximized. @return true if the frame is maximized
Class JInternalFrame, boolean isResizable()Returns whether the JInternalFrame
can be resized by some user action. @return true if the frame can be resized
Class JInternalFrame, void moveToBack()Convenience method that moves this component to position -1 ifClass JInternalFrame, void moveToFront()it'sits parent is a JLayeredPane.
Convenience method that moves this component to position 0 ifClass JInternalFrame, void setClosable(boolean)it'sits parent is a JLayeredPane.
Class JInternalFrame, void setClosed(boolean)SetSets that thisJInternalFrame
can be closed by some user action. @param b a boolean value where true means the frame can be closed @beaninfo preferred: true bound: true description: Indicates whether this frame can be closed.
Calling this method with a value ofClass JInternalFrame, void setContentPane(Container)true
to close the frame. @param b a boolean where true means "close the frame" @exception PropertyVetoException when the attempt to set the property is vetoed by thereceiver.JInternalFrame
@beaninfo bound: true constrained: true description: Indicates that the frame has been closed.
Sets thisClass JInternalFrame, void setDefaultCloseOperation(int)JInternalFrame
's content pane. @paramcontentPanec thecontentPane
object for this frame @exception java.awt.IllegalComponentStateException (a runtime exception) if the content pane parameter isnull
@see RootPaneContainer#getContentPane @beaninfo bound: true hidden: true description: The client area of the frame where child components are normally inserted.
Sets the operation which will happen by default when the user initiates a "close" on this window. The possible choices are:Class JInternalFrame, void setGlassPane(Component)
- DO_NOTHING_ON_CLOSE - do not do anything - require the program to handle the operation in the windowClosing method of a registered InternalFrameListener object.
- HIDE_ON_CLOSE - automatically hide the window after invoking any registered InternalFrameListener objects
- DISPOSE_ON_CLOSE - automatically hide and dispose the window after invoking any registered InternalFrameListener objects
EXIT_ON_CLOSE - Exit the application by way of System.exit. Only use this in applications.The value is set to
HIDEDISPOSE_ON_CLOSE by default. @see #addInternalFrameListener @see #getDefaultCloseOperation
Sets thisClass JInternalFrame, void setIcon(boolean)JInternalFrame
'sglassPane
property. @param glassPane theglassPane
object for this frame @see RootPaneContainer#getGlassPane @beaninfo bound: true hidden: true description: A transparent pane used for menu rendering.
Iconizes andClass JInternalFrame, void setIconifiable(boolean)deconizesde-iconizes the frame. @param b a boolean where true means to iconify the frame and false means todeiconifyde-iconify it @exception PropertyVetoException when the attempt to set the property is vetoed by thereceiver.JInternalFrame
@beaninfo bound: true constrained: true description: The image displayed when this frame is minimized.
Class JInternalFrame, void setJMenuBar(JMenuBar)SetSets that theJInternalFrame
can be made an icon by some user action. @param b a boolean where true means the frame can be iconified @beaninfo:preferred: truebound: truedescription: Determines whether this frame can be iconified.
Sets theClass JInternalFrame, void setLayeredPane(JLayeredPane)JMenuBar
for thisJInternalFrame
. @param m theJMenuBar
to use in this frame @see #getJMenuBar @beaninfo bound: true preferred: true description: The menubar for accessing pulldown menus from this frame.
Sets thisClass JInternalFrame, void setLayout(LayoutManager)JInternalFrame
'slayeredPane
property. @paramlayeredPanelayered thelayeredPane
object for this frame @exception java.awt.IllegalComponentStateException (a runtime exception) if the layered pane parameter isnull
@see RootPaneContainer#setLayeredPane @beaninfo hidden: true bound: true description: The pane which holds the various desktop layers.
By default the layout of this component may not be set the layout of itsClass JInternalFrame, void setMaximizable(boolean)contentPane
should be set instead. For example:An attempt to set the layout of this component will cause an runtime exception to be thrown. Subclasses can disable this behavior. @param manager thethiComponentthisComponent.getContentPane().setLayout(new BorderLayout())LayoutManager
@see #setRootPaneCheckingEnabled @exception Error if called withrootPaneCheckingisRootPaneChecking
true
Class JInternalFrame, void setMaximum(boolean)SetSets that theJInternalFrame
can be maximized by some user action. @param b a boolean where true means the frame can be maximized @beaninfo bound: true preferred: true description: Determines whether this frame can be maximized.
Maximizes and restores the frame. A maximized frame is resized to fully fit theClass JInternalFrame, void setMenuBar(JMenuBar)JDesktopPane
area associated with theJInternalFrame
. A restored frame's size is set to theJInternalFrame
's actual size. @param b a boolean where true maximizes the frame and false restores it @exception PropertyVetoException when the attempt to set the property is vetoed by thereceiver.JInternalFrame
@beaninfo bound: true constrained: true description: Indicates whether the frame is maximized.
Sets theClass JInternalFrame, void setResizable(boolean)JMenuBar
for thisJInternalFrame
. @param m theJMenuBar
to use in this frame @see #getJMenuBar @deprecated As of Swing version 1.0.3 replaced bysetJMenuBar(JMenuBar m)
.
Class JInternalFrame, void setRootPane(JRootPane)SetSets that theJInternalFrame
can be resized by some user action. @param b a boolean where true means the frame can be resized @beaninfo preferred: true bound: true description: Determines whether the frame can be resized by the user.
Class JInternalFrame, void setSelected(boolean)SetSets therootPane
property. This method is called by the constructor. @param root the newrootPane
object @beaninfo bound: true hidden: truebeaninfodescription: The rootPane used by this frame.
Selects and deselects the JInternalFrame. A JInternalFrame normally drawsClass JInternalFrame, void setTitle(String)it'sits title bar differently if it is the selected frame which indicates to the user that this internalFrame has the focus. @param selected a boolean where true means the frame is selected (currently active) and false means it is not @exception PropertyVetoException when the attempt to set the property is vetoed by the receiver. @beaninfo constrained: true bound: true description: Indicates whether this frame is currently the active frame.
Sets theClass JInternalFrame, void setUI(InternalFrameUI)JInternalFrame
title.title
may have anull
value. @see #getTitle @param title theString
to display in the title bar @beaninfo:preferred: true bound: true description: The text displayed in the title bar.
Sets the UI delegate for this JInternalFrame
. @beaninfo expert: true description: The InternalFrameUI implementation that defines the labels look and feel.
Class JInternalFrame, void setVisible(boolean)Class JInternalFrame, void updateUI()SetMakes the component visiblestateorofinvisible.theOverridesobjectComponent.setVisible
. @paramb ifaFlag trueshowsto makethisthe component visibleobject;@beaninfootherwiseattribute:hides itvisualUpdate true
Notification from theClass JInternalFrame, JRootPane rootPaneUIManager
that the L&F has changed. Replaces the current UI object with the latest version from theUIManager
. @see JComponent#updateUI
TheJRootPane
instance that manages thecontentPane
and optionalmenuBar
for this frame as well as theglassPane
. @see JRootPane @see RootPaneContainer
A display area for a short text string or an image or both. A label does not react to input events. As a result it cannot get the keyboard focus. A label can however display a keyboard alternative as a convenience for a nearby component that has a keyboard alternative but can't display it.Class JLabel, boolean imageUpdate(Image, int, int, int, int, int)A
JLabel
object can display either text an image or both. You can specify where in the label's display area the label's contents are aligned by setting the vertical and horizontal alignment. By default labels are vertically centered in their display area. Text-only labels are leading edge aligned by default; image-only labels are horizontally centered by default.You can also specify the position of the text relative to the image. By default text is on the trailing edge of the image with the text and image vertically aligned.
A label's leading and trailing edge are determined from the value of its java.awt.ComponentOrientation property. At present the default ComponentOrientation setting maps the leading edge to left and the trailing edge to right.
Finally you can use the
setIconTextGap
method to specify how many pixels should appear between the text and the image. The default is 4 pixels.See How to Use Labels in The Java Tutorial for further documentation.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A component that displays a short string and an icon. @version 1.
89 04100 02/2202/9900 @author Hans Muller
Class JLabel, void setDisabledIcon(Icon)Repaints the component when the image has changed.ThisimageUpdate method of an ImageObserver is called when more information about an image which had been previously requested using an asynchronous routine such as the drawImage method of Graphics becomes available. See the definition of imageUpdate for more information on this method and its arguments. The imageUpdate method of Component incrementally draws an image on the component as more of the bits of the image are available. If the system property awt.image.incrementalDraw is missing or has the value true the image is incrementally drawn If the system property has any other value then the imageisnot drawn until itoverridenhas been completely loaded.toAlsoreturn false ifincremental drawing is in effectthevaluecurrentofIcon'sthe system property awt.image.redrawrateImage isinterpreted as annotintegerequal togivethemaximumpassedredraw rateinmilliseconds. If the system property is missing or cannot be interpreted as an integer the redraw rate is once every 100ms. The interpretation of the x y width and height arguments depends on the value of theImage
infoflags argument. @paramimgthe image being observed. @param infoflags see imageUpdate for more information. @param x the x coordinate. @param y the y coordinate. @param width the width. @param height the height. @return true if the flags indicate that the image is completely loaded; falseotherwise. @see java.awt.image.ImageObserver @see java.awt.Graphics#drawImage(java.awt.Image int int java.awt.Color java.awt.image.ImageObserver) @see java.awt.Graphics#drawImage(java.awt.Image int int java.awt.image.ImageObserver) @see java.awt.Graphics#drawImage(java.awt.Image int int int int java.awt.Color java.awt.image.ImageObserver)@see java.awt.Graphics#drawImage(java.awt.Image int int int int java.awt.image.ImageObserver)@see java.awt.image.ImageObserverComponent#imageUpdate(java.awt.Image int int int int int)@since JDK1.0
Set the icon to be displayed if this JLabel is "disabled"i.e.(JLabel.setEnabled(false)).The default value of this property is null. @param disabledIcon the Icon to display when the component is disabled @see #getDisabledIcon @see #setEnabled @beaninfo bound: true attribute: visualUpdate true description: The icon to display if the label is disabled.
JLayeredPane adds depth to a JFC/Swing container allowing components to overlap each other when needed. An Integer object specifies each component's depth in the container where higher-numbered components sit "on top" of other components. For task-oriented documentation and examples of using layered panes see How to Use a Layered Pane a section in The Java Tutorial.
For convenience JLayeredPane divides the depth-range into several different layers. Putting a component into one of those layers makes it easy to ensure that components overlap properly without having to worry about specifying numbers for specific depths:
![]()
The JLayeredPane methods
- DEFAULT_LAYER
- The standard layer where most components go. This the bottommost layer.
- PALETTE_LAYER
- The palette layer sits over the default layer. Useful for floating toolbars and palettes so they can be positioned above other components.
- MODAL_LAYER
- The layer used for modal dialogs. They will appear on top of any toolbars palettes or standard components in the container.
- POPUP_LAYER
- The popup layer displays above dialogs. That way the popup windows associated with combo boxes tooltips and other help text will appear above the component palette or dialog that generated them.
- DRAG_LAYER
- When dragging a component reassigning it to the drag layer ensures that it is positioned over every other component in the container. When finished dragging it can be reassigned to its normal layer.
moveToFront(Component)
moveToBack(Component)
andsetPosition
can be used to reposition a component within its layer. ThesetLayer
method can also be used to change the component's current layer.Details
JLayeredPane manages it's list of children like Container but allows for the definition of a several layers within itself. Children in the same layer are managed exactly like the normal Container object with the added feature that when children components overlap children in higher layers display above the children in lower layers.Each layer is a distinct integer number. The layer attribute can be set on a Component by passing an Integer object during the add call.
For example:layeredPane.add(child JLayeredPane.DEFAULT_LAYER); or layeredPane.add(child new Integer(10));The layer attribute can also be set on a Component by callinglayeredPaneParent.setLayer(child 10)on the JLayeredPane that is the parent of component. The layer should be set before adding the child to the parent.Higher number layers display above lower number layers. So using numbers for the layers and letters for individual components a representative list order would look like this:
5a 5b 5c 2a 2b 2c 1awhere the leftmost components are closest to the top of the display.A component can be moved to the top or bottom position within its layer by calling
moveToFront
ormoveToBack
.The position of a component within a layer can also be specified directly. Valid positions range from 0 up to one less than the number of components in that layer. A value of -1 indicates the bottommost position. A value of 0 indicates the topmost position. Unlike layer numbers higher position values are lower in the display.
Note: This sequence (defined by java.awt.Container) is the reverse of the layer numbering sequence. Usually though you will useHere are some examples using the method add(Component layer position): Calling add(5x 5 -1) results in:moveToFront
moveToBack
andsetLayer
.5a 5b 5c 5x 2a 2b 2c 1aCalling add(5z 5 2) results in:5a 5b 5z 5c 5x 2a 2b 2c 1aCalling add(3a 3 7) results in:5a 5b 5z 5c 5x 3a 2a 2b 2c 1aUsing normal paint/event mechanics results in 1a appearing at the bottom and 5a being above all other components.Note: that these layers are simply a logical construct and LayoutManagers will affect all child components of this container without regard for layer settings.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
33 0937 03/0114/9800 @author David Kloba
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJLayeredPane
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to layered pane user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
GetGets the AccessibleContext associated with thisJComponentJLayeredPane. For layered panes the AccessibleContext takes the form of an AccessibleJLayeredPane. A new AccessibleJLayeredPane instance is created if necessary. @return an AccessibleJLayeredPane that serves as the AccessibleContext of thisJComponentJLayeredPane
A component that allows the user to select one or more objects from a list. A separate modelListModel
represents the contents of the list. It's easy to display an array or vector of objects using aJList
constructor that buildsanaListModel
instance for you:// Create a JList that displays the strings in data[] String[] data = {"one" "two" "freethree" "four"}; JList dataList = new JList(data); // The value of the JList model property is an object that provides // a read-only view of the data. It was constructed automatically. for(int i = 0; i
JList
doesn't support scrolling directly. To create a scrolling list you make theJList
the viewport view of aJScrollPane
. For example:e.gJScrollPane scrollPane = new JScrollPane(dataList); // Or in two steps: JScrollPane scrollPane = new JScrollPane(); scrollPane.getViewport().setView(dataList);By default the
JList
supports singleselectioni.e.modelzero or one indexallows any combination ofcanitems to be selected at a time using the constantMULTIPLE_INTERVAL_SELECTION
. The selection state is actually managed by a separate delegate object animplementationinstance ofListSelectionModel
.howeverHoweverJList
provides convenient properties for managing the selection.String[] data = {"one" "two" "freethree" "four"}; JList dataList = new JList(data); dataList.setSelectedIndex(1); // select "two" dataList.getSelectedValue(); // returns "two"The contents of a
JList
can be dynamici.e.in other words the list elements can change value and the size of the list can change after theJList
has been created. TheJList
observes changes in its model with aswing.event.ListDataListener
implementation. A correct implementation ofListModel
notifies it's listeners each time a change occurs. The changes are characterized by aswing.event.ListDataEvent
which identifies the range ofListlist indices that have been modified added or removed. Simple dynamic-contentJList
applications can use theDefaultListModel
class to store list elements. This class implements theListModel
interface and provides thejava.util.Vector
API as well. Applications that need to provide customListModel
implementations can subclassAbstractListModel
which provides basicListDataListener
support. For example:// This list model has about 2^16 elements. Enjoy scrolling. ListModel bigData = new AbstractListModel() { public int getSize() { return Short.MAX_VALUE; } public Object getElementAt(int index) { return "Index " + index; } }; JList bigDataList = newListJList(bigData); // We don't want the JList implementation to compute the width // or height of all of the list cells so we give it aStringstring // that's as big as we'll need for any cell. It uses this to // compute values for the fixedCellWidth and fixedCellHeight // properties. bigDataList.setPrototypeCellValue("Index 1234567890");
JList
uses ajava.awt.Component
provided by a delegate called thecellRendererer
to paint the visible cells in the list. The cell renderer component is used like a "rubber stamp" to paint each visible row. Each time theJList
needs to paint a cell it asks the cell renderer for the component moves it into place usingsetBounds()
and then draws it by calling its paint method. The default cell renderer uses aJLabel
component to render the string value of each component. You can substitute your own cell renderer using code like this:// Display an icon and a string for each object in the list. class MyCellRenderer extends JLabel implements ListCellRenderer { final static ImageIcon longIcon = new ImageIcon("long.gif"); final static ImageIcon shortIcon = new ImageIcon("short.gif"); // This is the only method defined by ListCellRenderer. // We just//reconfigure theJlabelJLabel each time we're called. public Component getListCellRendererComponent( JList list Object value // value to display int index // cell index boolean isSelected // is the cell selected boolean cellHasFocus) // the list and the cell have the focus { String s = value.toString(); setText(s); setIcon((s.length() > 10) longIcon : shortIcon); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setEnabled(list.isEnabled()); setFont(list.getFont()); return this; } } String[] data = {"one" "two" "freethree" "four"}; JList dataList = new JList(data); dataList.setCellRenderer(new MyCellRenderer());
JList
doesn't provide any special support for handling double or triple (or N) mouse clicks however it's easy to handle them using aMouseListener
. Use theJList
methodlocationToIndex()
to determine what cell was clicked. For example:final JList list = new JList(dataModel); MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int index = list.locationToIndex(e.getPoint()); System.out.println("Double clicked on Item " + index); } } }; list.addMouseListener(mouseListener);Note that in this example theJList variabledataList
isfinal
because it's referred to by the anonymousMouseListener
class.For the keyboard keys used by this component in the standard
Looklook andFeelfeel (L&F) renditions see the JList key assignments.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
See How to Use Lists in The Java Tutorial for further documentation. Also see the article Advanced JList Programming in The Swing Connection.
@see ListModel @see AbstractListModel @see DefaultListModel @see ListSelectionModel @see DefaultListSelectionModel @see ListCellRenderer @beaninfo attribute: isContainer false description: A component which allows for the selection of one or more objects from a list. @version 1.
65 0473 03/2214/9900 @author Hans Muller
Class JList.AccessibleJList, AccessibleSelection getAccessibleSelection()TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJList
class.role forIt providesthisan implementation of the Java Accessibility API appropriate to list user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Get the AccessibleSelection associated with this object.if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleSelection interface on behalf of itself. @return this object
Constructs a JList
with an empty model.
Class JList, constructor JList(ListModel)Class JList, constructor JList(Object[])ConstructConstructs aJList
that displays the elements in the specified non-null model. AllJList
constructors delegate to this one. @param dataModel the data model for this list @exception IllegalArgumentException ifdataModel
isnull
Class JList, constructor JList(Vector)ConstructConstructs aJList
that displays the elements in the specified array. This constructor just delegates to theListModel
constructor. @param listData the array of Objects to be loaded into the data model
Class JList, void addListSelectionListener(ListSelectionListener)ConstructConstructs aJList
that displays the elements in the specifiedVector
. This constructor just delegates to theListModel
constructor. @param listData theVector
to be loaded into the data model
Class JList, void addSelectionInterval(int, int)AddAdds a listener to the list that's notified each time a change to the selection occurs. Listeners added directly to theJList
will have theirListSelectionEvent.getSource() == this JList
(instead of theListSelectionModel
). @param listenerThetheListSelectionListener
to add.@see #getSelectionModel
Class JList, void clearSelection()SetSets the selection to be the union of the specified interval with current selection. Both the anchor and lead indices are included. It's not neccessary for anchor to be less than lead. This is a convenience method that just delegates to theselectionModel
. @param anchorThethe first index to add to the selection @param leadThethe last index to add to the selection @see ListSelectionModel#addSelectionInterval @see #setSelectionInterval @see #removeSelectionInterval @see #addListSelectionListener
Clears the selection - after calling this methodClass JList, ListSelectionModel createSelectionModel()isSelectionEmpty
will return true. This is a convenience method that just delegates to the()selectionModel
. @see ListSelectionModel#clearSelection @see #isSelectionEmpty @see #addListSelectionListener
Returns an instance ofClass JList, void ensureIndexIsVisible(int)DefaultListSelectionModel
. This method is used by the constructor to initialize theselectionModel
property. @returnThetheListSelectionModel
used by thisJList
. @see #setSelectionModel @see DefaultListSelectionModel
Class JList, void fireSelectionValueChanged(int, int, boolean)IfScrollsthis JList is being displayed withinthea JViewport andviewport to make the specified cellisn'tcompletely visible. Note for this method toscrollwork theviewportJList
must be displayed within aJViewport
. @paraman int --index the index of the cell to make visible @see JComponent#scrollRectToVisible @see #getVisibleRect
Class JList, AccessibleContext getAccessibleContext()ThisNotifiesmethod notifiesJList
ListSelectionListenersListSelectionListener
s that the selection model has changed. It's used to forwardListSelectionEvents
from theselectionModel
to theListSelectionListenersListSelectionListener
s added directly to theJList
. @param firstIndex the first selected index @param lastIndex the last selected index @param isAdjusting true if multiple changes are being made @see #addListSelectionListener @see #removeListSelectionListener @see EventListenerList
Class JList, int getAnchorSelectionIndex()GetGets the AccessibleContext associated with thisJComponentJList. For JLists the AccessibleContext takes the form of an AccessibleJList. A new AccessibleJList instance is created if necessary. @return an AccessibleJList that serves as the AccessibleContext of thisJComponentJList
Returns the first index argument from the most recentClass JList, Rectangle getCellBounds(int, int)addSelectionIntervaladdSelectionModel
orsetSelectionInterval
call. This is a convenience method that just delegates to theselectionModel
. @returnThethe index that most recently anchored an interval selection.@see ListSelectionModel#getAnchorSelectionIndex @see #addSelectionInterval @see #setSelectionInterval @see #addListSelectionListener
Returns the bounds of the specified range of items inClass JList, ListCellRenderer getCellRenderer()JList
coordinates. Returnsnull
if index isn't valid. @paramindex1index0 the index of the firstJList
cell in the range @paramindex2index1 the index of the lastJList
cell in the range @return the bounds of the indexed cells in pixels
Returns the object that renders the list items. @return the ListCellRenderer
@see #setCellRenderer
Class JList, int getFirstVisibleIndex()Class JList, int getFixedCellHeight()ReturnReturns the index of the cell in the upper left corner of theJList
or -1 if nothing is visible or the list is empty. Note that this cell may only be partially visible. @returnan int --the index of the first visible cell.@see #getLastVisibleIndex @see JComponent#getVisibleRect
Returns the fixed cellClass JList, int getFixedCellWidth()widthheight value -- the value specified by setting thefixedCellHeight
property rather than that calculated from the list elements. @return the fixed cell height in pixels @see #setFixedCellHeight
Returns the fixed cell width value -- the value specified by setting the fixedCellWidth
property rather than that calculated from the list elements. @return the fixed cell width @see #setFixedCellWidth
Class JList, int getLastVisibleIndex()Class JList, int getLeadSelectionIndex()ReturnReturns the index of the cell in the lower right corner of theJList
or -1 if nothing is visible or the list is empty. Note that this cell may only be partially visible. @returnan int --the index of the last visible cell.@see #getLastVisibleIndex @see JComponent#getVisibleRect
Returns the second index argument from the most recentClass JList, int getMaxSelectionIndex()addSelectionInterval
orsetSelectionInterval
call. This is a convenience method that just delegates to theselectionModel
. @returnThethe index that most recently ended a interval selection.@see ListSelectionModel#getLeadSelectionIndex @see #addSelectionInterval @see #setSelectionInterval @see #addListSelectionListener @beaninfo description: The lead selection index.
Returns the largest selected cell index. This is a convenience method that just delegates to theClass JList, int getMinSelectionIndex()selectionModel
. @returnThethe largest selected cell index.@see ListSelectionModel#getMaxSelectionIndex @see #addListSelectionListener
Returns the smallest selected cell index. This is a convenience method that just delegates to theClass JList, ListModel getModel()selectionModel
. @returnThethe smallest selected cell index.@see ListSelectionModel#getMinSelectionIndex @see #addListSelectionListener
Returns the data model that holds the list of items displayed by theClass JList, Dimension getPreferredScrollableViewportSize()JList
component. @return theListModel
that provides the displayed list of items @see #setModel
Class JList, Object getPrototypeCellValue()ComputeComputes the size of the viewport needed to displayvisibleRowCount
rows. This is trivial iffixedCellWidth
andfixedCellHeight
were specified. Note that they can be specified implicitly with theprototypeCellValue
property. IffixedCellWidth
wasn't specified it's computed by finding the widest list element. IffixedCellHeight
wasn't specified then we resort to heuristics:@return a dimension containing the size of the viewport needed to display
- If the model isn't empty we just multiply the height of the first row by
visibleRowCount
.- If the model is empty
i.e.(JList.getModel().getSize() == 0) then we just allocate 16 pixels per visible row and 256 pixels for the width (unless
fixedCellWidth
was set) and hope for the best.visibleRowCount
rows @see #getPreferredScrollableViewportSize @see #setPrototypeCellValue
Returns the cell width of the "prototypical cell" -- a cell used for the calculation of cell widths because it has the same value as all other list itemsClass JList, int getScrollableBlockIncrement(Rectangle, int, int)instead of forcing the calculation to inspect every item in the list. @return the value of theprototypeCellValue
property @see #setPrototypeCellValue
Returns the block increment amount. @param visibleRect the visible rectangle @param orientation HORIZONTAL or VERTICAL @param direction if < 0 then scroll UP; if > 0 then scroll DOWN @returnClass JList, boolean getScrollableTracksViewportHeight()Thethe visibleRect.height or visibleRect.width per the orientation.@see Scrollable#getScrollableUnitIncrement @throws IllegalArgumentException if visibleRect isnull
or orientation isn't one of SwingConstants.VERTICAL SwingConstants.HORIZONTAL.
Class JList, boolean getScrollableTracksViewportWidth()IfReturns true if thisJList
is displayed in aJViewport
don'tand the viewport is taller thanchangeJList
'sitspreferred height; otherwise returns false. Ifwhenfalse then don't track theviewportsviewport's heightchanges. This allows vertical scrolling if theJViewport
is itself embedded in aJScrollPane
. @returnFalse -true ifdonviewport is taller thanJlist
't track the viewportss preferred height otherwisewidth.false @see Scrollable#getScrollableTracksViewportWidthgetScrollableTracksViewportHeight
Class JList, int getScrollableUnitIncrement(Rectangle, int, int)IfReturns true if thisJList
is displayed in aJViewport
don'tand the viewport ischange itswider thanJList
's preferred width; otherwise returns false. If falsewhenthen don't track theviewportsviewport's widthchanges. This allows horizontal scrolling if theJViewport
is itself embedded in aJScrollPane
. @returnFalse -true ifdon'tviewporttrackis wider than theviewportsJList
's preferred width.otherwise false @see Scrollable#getScrollableTracksViewportWidth
Class JList, int getSelectedIndex()HorizontalReturns the distance to scroll to expose the next or previous row (for vertical scrolling) or character (for horizontal scrolling). For horizontal scrolling: return the lists font size or 1 if the font isnull
. We're using the font size instead of the width of some canonical string e.g. "m" because it's cheaper.
VerticalFor verticaL scrolling: if we're scrolling downwards (direction
is greater than 0) and the first row is completely visible with respect tovisibleRect
then return its height. If we're scrolling downwards and the first row is only partially visible return the height of the visible part of the first row. Similarly if we're scrolling upwards we return the height of the row above the first row unless the first row is partially visible.Note that the value of
visibleRect
must be the equal tothis.getVisibleRect()
. @param visibleRect the visible rectangle @param orientation HORIZONTAL or VERTICAL @param direction if < 0 then scroll UP; if > 0 then scroll DOWN @returnThethe distance in pixels to scroll to expose the next or previousrow.unit @see Scrollable#getScrollableUnitIncrement @throws IllegalArgumentException if visibleRect isnull
or orientation isn't one of SwingConstants.VERTICAL SwingConstants.HORIZONTAL.
Class JList, int[] getSelectedIndices()A convenience method that returnsReturns the first selected index. Returns; returns -1 if there is no selected item. @returnThethefirst selectedvalue ofindex.getMinSelectionIndex
@see #getMinSelectionIndex @see #addListSelectionListener
Class JList, Object getSelectedValue()ReturnReturns an array of all of the selected indices in increasing order. @returnAllall of the selected indices in increasing order.@see #removeSelectionInterval @see #addListSelectionListener
Class JList, Object[] getSelectedValues()AReturnsconvenience method that returnsthe first selected value ornull
if the selection is empty. @returnThethe first selected value.@see #getMinSelectionIndex @see #getModel @see #addListSelectionListener
Class JList, Color getSelectionBackground()ReturnReturns an array of the values for the selected cells. The returned values are sorted in increasing index order. @return the selected values @see #isSelectedIndex @see #getModel @see #addListSelectionListener
Returns the background color for selected cells. @return the Color
used for the background of selected list items @see #setSelectionBackground @see #setSelectionForeground
Class JList, Color getSelectionForeground()Returns the selection foreground color. @return the Color
object for the foreground property @see #setSelectionForeground @see #setSelectionBackground
Class JList, int getSelectionMode()Returns whether single-item or multiple-item selections are allowed. @returnClass JList, ListSelectionModel getSelectionModel()Thethe value of theselectionMode
property.@see #setSelectionMode
Returns the value of the current selection model. The selection model handles the task of making single selections selections of contiguous ranges and non-contiguous selections. @return the ListSelectionModel
that implements list selections @see #setSelectionModel @see ListSelectionModel
Class JList, ListUI getUI()Returns the look and feel (L&F) object that renders this component. @return the ListUI object that renders this componentClass JList, String getUIClassID()
Returns theClass JList, boolean getValueIsAdjusting()name of the UIFactory class that generatessuffix used to construct the name of the look and feelfor(L&F) class used to render this component. @return the string "ListUI" @see JComponent#getUIClassID @see UIDefaults#getUI
Returns the value of the data model'sClass JList, int getVisibleRowCount()isAdjusting
property. This value is true if multiple changes are being made. @return true if multiple selection-changes areoccuringoccurring as when the mouse is being dragged over the list @see ListSelectionModel#getValueIsAdjusting
Class JList, Point indexToLocation(int)ReturnReturns the preferred number of visible rows. @return anintinteger indicating the preferred number of rows to display without using ascrollbarscroll bar @see #setVisibleRowCount
Returns the origin of the specified item inClass JList, boolean isSelectedIndex(int)JList
coordinates. Returnsnull
ifindex
isn't valid. @param indexThethe index of theJList
cell.@returnThethe origin of the index'th cell.
Returns true if the specified index is selected. This is a convenience method that just delegates to theClass JList, boolean isSelectionEmpty()selectionModel
. @param index index to be queried for selection state @returnTruetrue if the specified index is selected.@see ListSelectionModel#isSelectedIndex @see #setSelectedIndex @see #addListSelectionListener
Returns true if nothing is selected. This is a convenience method that just delegates to theClass JList, int locationToIndex(Point)selectionModel
. @returnTruetrue if nothing is selected @see ListSelectionModel#isSelectionEmpty @see #clearSelection @see #addListSelectionListener
Class JList, String paramString()ConvertConverts a point inJList
coordinates to the index of the cell at that location. Returns -1 if there's no cell at the specified location. @param locationThe JList relativethe coordinates of the cell relative toJList
@return anintinteger -- the index of the cell at the given location or -1.
Returns a string representation of thisClass JList, void removeListSelectionListener(ListSelectionListener)JList
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJList
.
Class JList, void removeSelectionInterval(int, int)RemoveRemoves a listener from the list that's notified each time a change to the selection occurs. @param listenerThetheListSelectionListener
to remove.@see #addListSelectionListener @see #getSelectionModel
Class JList, void setCellRenderer(ListCellRenderer)SetSets the selection to be the set difference of the specified interval and the current selection. Both the anchor and lead indices are removed. It's not neccessary for anchor to be less than lead. This is a convenience method that just delegates to theselectionModel
. @param anchorThethe first index to remove from the selection @param leadThethe last index to remove from the selection @see ListSelectionModel#removeSelectionInterval @see #setSelectionInterval @see #addSelectionInterval @see #addListSelectionListener
Sets the delegate that's used to paint each cell in the list. IfClass JList, void setFixedCellHeight(int)prototypeCellValue
was set then thefixedCellWidth
andfixedCellHeight
properties are set as well. Only onePropertyChangeEvent
is generated however - for the"cellRenderer
property."The default value of this property is provided by the ListUI delegate i.e. by the look and feel implementation.
To see an example which sets the cell renderer see the class description above.
This is a JavaBeans bound property. @param cellRenderer the
ListCellRenderer
that paints list cells @see #getCellRenderer @beaninfo bound: true attribute: visualUpdate true description: The component used to draw the cells.
Class JList, void setFixedCellWidth(int)If this value is greater than zero it definesSets the height of every cell in the list.OtherwiseIfheight
is -1 cell heights are computed by applyinggetPreferredSize
to the()cellRenderer
component for each list element.The default value of this property is -1.
This is a JavaBeans bound property. @param height an
intinteger giving the height in pixels for all cells in this list @see #getPrototypeCellValue @see #setFixedCellWidth @see JComponent#addPropertyChangeListener @beaninfo bound: true attribute: visualUpdate true description: Defines a fixed cell height when greater than zero.
Class JList, void setListData(Object[])If this value is greater than zero itSetsdefinesthe width of every cell in the list.OtherwiseIfwidth
is -1 cell widths are computed by applyinggetPreferredSize
to the()cellRenderer
component for each list element.The default value of this property is -1.
This is a JavaBeans bound property. @param width the width in pixels for all cells in this list @see #getPrototypeCellValue @see #setFixedCellWidth @see JComponent#addPropertyChangeListener @beaninfo bound: true attribute: visualUpdate true description: Defines a fixed cell width when greater than zero.
Class JList, void setListData(Vector)AConstructsconvenience method that constructsaListModel
from an array ofObjectsobjects and then appliessetModel
to it. @param listData an array of Objects containing the items to display in the list @see #setModel
Class JList, void setModel(ListModel)AConstructsconvenience method that constructsaListModel
from aVector
and then appliessetModel
to it. @param listData aVector
containing the items to display in the list @see #setModel
Sets the model that represents the contents or "value" of the list and clears the list selection after notifyingClass JList, void setPrototypeCellValue(Object)PropertyChangeListeners
.This is a JavaBeans bound property. @param model the
ListModel
that provides the list of items for display @exception IllegalArgumentException ifmodel
isnull
@see #getModel @beaninfo bound: true attribute: visualUpdate true description: The object that contains the data to be drawn by this JList.
Class JList, void setSelectedIndex(int)IfComputesthis value is non-null it's used to computethefixedCellWidth
andfixedCellHeight
properties by configuring thecellRenderer
atto index equals zero for the specified value and then computing the renderercomponentscomponent's preferred size.This property isThese properties are useful when the list is too long to allowJList
tojustcompute the width/height of each cell and there'sis a single cell value that'sis known to occupy as much space as any of the others.
The default value of thisNote that we do setpropertythefixedCellWidth
andfixedCellHeight
properties here but only aprototypeCellValue PropertyChangeEvent
isnullfired.
ThisTois a JavaBeanssee an exampleboundwhich sets this property.Note thatsee theweclassdodescriptionsetabove.the fixedCellWidth and fixedCellHeight properties here but onlyThe default value of this property is
anull
.prototypeCellValue PropertyChangeEventThis is
fireda JavaBeans bound property. @param prototypeCellValue the value on which to basefixedCellWidth
andfixedCellHeight
@see #getPrototypeCellValue @see #setFixedCellWidth @see #setFixedCellHeight @see JComponent#addPropertyChangeListener @beaninfo bound: true attribute: visualUpdate true description: The cell prototype value used to compute cell width and height.on
Class JList, void setSelectedIndices(int[])SelectSelects a single cell. @param indexThethe index of the one cell to select @see ListSelectionModel#setSelectionInterval @see #isSelectedIndex @see #addListSelectionListener @beaninfo description: The index of the selected cell.
Class JList, void setSelectedValue(Object, boolean)SelectSelects a set of cells. @param indicesThean array of the indices of the cells to select @see ListSelectionModel#addSelectionInterval @see #isSelectedIndex @see #addListSelectionListener
Selects the specified object from the list. @param anObject theClass JList, void setSelectionBackground(Color)Objectobject to select @param shouldScroll true if the list should scroll to display the selected object if one exists; otherwise false
Class JList, void setSelectionForeground(Color)SetSets the background color for selected cells. Cell renderers can use this color to the fill selected cells.The default value of this property is defined by the look and feel implementation.
This is a JavaBeans bound property. @param selectionBackground the
Color
to use for the background of selected cells @see #getSelectionBackground @see #setSelectionForeground @see #setForeground @see #setBackground @see #setFont @beaninfo bound: true attribute: visualUpdate true description: The background color of selected cells.
Class JList, void setSelectionInterval(int, int)SetSets the foreground color for selected cells. Cell renderers can use this color to render text and graphics for selected cells.The default value of this property is defined by the look and feel implementation.
This is a JavaBeans bound property. @param selectionForeground the
Color
to use in the foreground for selected list items @see #getSelectionForeground @see #setSelectionBackground @see #setForeground @see #setBackground @see #setFont @beaninfo bound: true attribute: visualUpdate true description: The foreground color of selected cells.
Class JList, void setSelectionMode(int)SelectSelects the specified interval. Both the anchor and lead indices are included. It's not neccessary for anchor to be less than lead. This is a convenience method that just delegates to theselectionModel
. @param anchorThethe first index to select @param leadThethe last index to select @see ListSelectionModel#setSelectionInterval @see #addSelectionInterval @see #removeSelectionInterval @see #addListSelectionListener
Determines whether single-item or multiple-item selections are allowed. The followingClass JList, void setSelectionModel(ListSelectionModel)selectionMode
values are allowed:@param selectionMode an
SINGLE_SELECTION
Only one list index can be selected at a time. In this mode thesetSelectionInterval
andaddSelectionInterval
methods are equivalent andtheyonly thefirstsecond index argument is used.SINGLE_INTERVAL_SELECTION
One contiguous index interval can be selected at a time. In this modesetSelectionInterval
andaddSelectionInterval
are equivalent.MULTIPLE_INTERVAL_SELECTION
In this mode there's no restriction on what can be selected. This is the default.intinteger specifying the type of selections that are permissible @see #getSelectionMode @beaninfo description: The selection mode. enum: SINGLE_SELECTION ListSelectionModel.SINGLE_SELECTION SINGLE_INTERVAL_SELECTION ListSelectionModel.SINGLE_INTERVAL_SELECTION MULTIPLE_INTERVAL_SELECTION ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
Class JList, void setUI(ListUI)SetSets theselectionModel
for the list to a non-null
ListSelectionModel
implementation. The selection model handles the task of making single selections selections of contiguous ranges and non-contiguous selections.This is a JavaBeans bound property. @
returnparam selectionModel theListSelectionModel
that implementslistthe selections @exception IllegalArgumentException ifselectionModel
isnull
@see #getSelectionModel @beaninfo bound: true description: The selection model recording which cells are selected.
Sets the look and feel (L&F) object that renders this component. @param ui the ListUI L&F object @see UIDefaults#getUIClass JList, void setValueIsAdjusting(boolean)
Sets the data model's isAdjusting
property to true so that a single event will be generated when all of the selection events have finished (for example when the mouse is being dragged over the list in selection mode). @param b the boolean value for the property value @see ListSelectionModel#setValueIsAdjusting
Class JList, void setVisibleRowCount(int)Class JList, void updateUI()SetSets the preferred number of rows in the list that can be displayed without a scollbar as determined by the nearestJViewport
ancestor if any. The value of this property only affects the value of theJListsJList
'spreferredScrollableViewportSize
.The default value of this property is 8.
This is a JavaBeans bound property. @param visibleRowCount an
intinteger specifying the preferred number of visible rows @see #getVisibleRowCount @see JComponent#getVisibleRect @see JViewport @beaninfo bound: true attribute: visualUpdate true description: The preferred number of cells that can be displayed without ascrollbarscroll bar.
SetSets the UI property with the "ListUI" from the current default UIFactory. This method is called by theJList
constructor and to update theListslist's look and feel at runtime. @see UIManager#getUI
An implementation of a menu -- a popup window containingJMenuItem
s that is displayed when the user selects an item on theJMenuBar
. In addition toJMenuItemsJMenuItem
s aJMenu
can also containJSeparator
s.In essence a menu is a button with an associated
JPopupMenu
. When the "button" is pressed theJPopupMenu
appears. If the "button" is on theJMenuBar
the menu is a top-level window. If the "button" is another menu item then theJPopupMenu
is "pull-right" menu.For information and examples of using menus see How to Use Menus a section in The Java Tutorial. For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JMenu key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer true description: A popup window containing menu items displayed in a menu bar. @version 1.
124 09144 01/2221/0001 @author Georges Saab @author David Karlton @author Arnaud Weber @see JMenuItem @see JSeparator @see JMenuBar @see JPopupMenu
Class JMenu.AccessibleJMenu, void addAccessibleSelection(int)TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJMenu
class.role forIt providesthisan implementation of the Java Accessibility API appropriate to menu user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Selects theClass JMenu.AccessibleJMenu, Accessible getAccessibleChild(int)nthi
th menu in the menu. If that item is asub-menusubmenu it will pop up in response. If a different item is already popped up this will force it to close. If this is a sub-menu that is alreadypoppoedpopped up (selected) this method has no effect. @param i thezero-basedindex ofselectablethe item to beitemsselected @see #getAccessibleStateSet
Class JMenu.AccessibleJMenu, AccessibleSelection getAccessibleSelection()ReturnReturns the nth Accessible child of the object. @param i zero-based index of child @return the nth Accessible child of the object
Get the AccessibleSelection associated with this object.Class JMenu.AccessibleJMenu, boolean isAccessibleChildSelected(int)if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleSelection interface on behalf of itself. @return this object
Returns true if the current child of this object is selected.(i.e.that is if this child is apoppopped-edupsub-menusubmenu). @param i the zero-based index of the child in this Accessible object. @see AccessibleContext#getAccessibleChild
Class JMenu, constructor JMenu(String)CreatesConstructs a newJMenu
with no text.
Class JMenu, constructor JMenu(String, boolean)CreatesConstructs a newJMenu
with the supplied string as its text. @param sThethe text for the menu label
Class JMenu, Component add(Component)CreatesConstructs a newJMenu
with the supplied string as its text and specified as a tear-off menu or not. @param sThethe text for the menu label @param b can the menu be torn off (not yet implemented)
Appends a component to the end of this menu. Returns the component added. @param c theClass JMenu, void addMenuListener(MenuListener)Component
to add @return theComponent
added
Class JMenu, void addSeparator()AddAdds a listener for menu events. @param l the listener to be added
Class JMenu, WinListener createWinListener(JPopupMenu)AppendAppends a new separator to the end of the menu.
Class JMenu, void doClick(int)CreateCreates a window-closing listener for the popup. @param p theJPopupMenu
@return the new window-closing listener @see WinListener
ProgramaticallyClass JMenu, void fireMenuCanceled()performperforms a "click". This overrides the methodAbstractButton.doClick
in order to make the menu pop up. @param pressTime indicates the number of milliseconds the button was pressed for(int)
Class JMenu, void fireMenuDeselected()NotifyNotifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. @exception Error if there is anull
listener @see EventListenerList
Class JMenu, void fireMenuSelected()NotifyNotifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. @exception Error if there is anull
listener @see EventListenerList
Class JMenu, AccessibleContext getAccessibleContext()NotifyNotifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. @exception Error if there is anull
listener @see EventListenerList
Class JMenu, Component getComponent()GetGets the AccessibleContext associated with thisJComponentJMenu. For JMenus the AccessibleContext takes the form of an AccessibleJMenu. A new AccessibleJMenu instance is created if necessary. @return an AccessibleJMenu that serves as the AccessibleContext of thisJComponentJMenu
Class JMenu, int getDelay()ThisReturnsmethod returnsthejava.awt.Component
used to paint thisMenuElement
. The returned component is used to convert events and detect if an event is inside a menu component.
Returns the suggested delayClass JMenu, JMenuItem getItem(int)before thein millisecondsmenu'sbeforePopupMenu issubmenus are popped up or down. Each look and feel (L&F) may determine its own policy for observing thedelay
property. In most cases the delay is not observed for top level menus or while dragging.@returnThean intdefault for--delay
theis 0.numberThis method is a property ofmillisecondsthe look and feel code and is used to manage the idiosyncracies of the various UI implementations. @return thedelay property
Returns theClass JMenu, int getItemCount()JMenuItem
at the specified position. If thespecifiedcomponentpositionatpos
iscontainsnot aseparatormenuthisitemJMenunull
is returned. This method is included for AWT compatibility. @param pos anint givinginteger specifying the position @exception IllegalArgumentException if the value of<0 @return the menu item at the specified position; or
indexposnull
if the item as the specified position islessnot athanmenu0.item
Returns the number of items on the menu including separators. This method is included for AWT compatibility. @return anClass JMenu, Component getMenuComponent(int)intinteger equal to the number of items on the menu @see #getMenuComponentCount
Returns the component at positionClass JMenu, int getMenuComponentCount()n
. @param n the position of the component to be returned @return the component requested ornull
if there is no popup menu
Returns the number of components on the menu. @return anClass JMenu, Component[] getMenuComponents()intinteger--containing the number of components on the menu
Returns an array ofClass JMenu, JPopupMenu getPopupMenu()Component
s of the menu's subcomponents. Note that this returns allComponent
s in the popup menu including separators. @return an array ofComponentsComponent
s or an empty array if there is no popup menu
Returns the popupmenu associated with this menu. If there is no popupmenu it will create one.Class JMenu, MenuElement[] getSubElements()
Returns an array ofClass JMenu, String getUIClassID()MenuElement
s containing thesub-menu componentssubmenu for this menu component. If popup menu isnull
returns an empty array. This method is required to conform to theMenuElement
interface. Note that sinceJSeparator
s do not conform to theMenuElement
interface this array will only containJMenuItem
s. @return an array ofMenuElement
objects
Returns the name of the L&F class that renders this component. @return the string "MenuUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JMenu, JMenuItem insert(Action, int)
Class JMenu, JMenuItem insert(JMenuItem, int)InsertInserts a newmenuitemmenu item attached to the specifiedAction
object at a given position. @param a theAction
object for themenuitemmenu item to add @param pos anint givinginteger specifying the position at which to add the newmenuitemmenu item @exception IllegalArgumentException if the value ofpos
<0
Class JMenu, void insert(String, int)InsertInserts the specifiedJMenuitem
at a given position. @param mi theJMenuitem
to add @param pos anint givinginteger specifying the position at which to add the newJMenuitem
@return the new menu item @exception IllegalArgumentException if the value ofpos
<0
Class JMenu, void insertSeparator(int)InsertInserts a newmenuitemmenu item with the specified text at a given position. @param s the text for themenuitemmenu item to add @param pos anint givinginteger specifying the position at which to add the newmenuitemmenu item @exception IllegalArgumentException when the value ofpos
<0
Inserts a separator at the specified position. @param index anClass JMenu, boolean isMenuComponent(Component)int givinginteger specifying the position at which to insert the menu separator @exception IllegalArgumentException if the value ofindex
is less than<0.
Returns true if the specified component exists in the submenu hierarchy. @param c theClass JMenu, boolean isSelected()Component
to be tested @return true if thecomponentComponent
exists false otherwise
Returns true if the menu is currently selected (Class JMenu, boolean isTearOff()popped uphighlighted). @return true if the menu isopenselected else false
Returns true if the menu can be torn off. This method is not yet implemented. @return true if the menu can be torn off else false @exception Error if invoked -- this method is not yet implementedClass JMenu, boolean isTopLevelMenu()
Returns true if the menu is a 'top-level menu' that is if it is the direct child of a menubar. @return true if the menu is activated from the menu bar; false if the menu is activated from a menu item on another menuClass JMenu, String paramString()
Returns a string representation of thisClass JMenu, void remove(Component)JMenu
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of this JMenu.
Removes theClass JMenu, void remove(JMenuItem)Componentcomponentc
from this menu. @param c the component to be removed
Removes the specified menu item from this menu. If there is no popup menu this method will have no effect. @param item the JMenuItem
to be removed from the menu
Class JMenu, void remove(int)Removes the menu item at the specified index from this menu. @paramClass JMenu, void removeAll()indexpos the position of the item to be removed.@exception IllegalArgumentException if the value of<0 or if
indexpospos
islessgreater than0.the number of menu items
Class JMenu, void removeMenuListener(MenuListener)RemoveRemoves all menu items from this menu.
Class JMenu, void setAccelerator(KeyStroke)RemoveRemoves a listener for menu events. @param l the listener to be removed
Class JMenu, void setDelay(int)setAccelerator
is not defined for()JMenu
. UsesetMnemonic
instead. @param keyStroke the keystroke combination which will invoke the()JMenuItem
's actionlisteners without navigating the menu hierarchy @exception Error if invoked -- this method is not defined for JMenu. UsesetMnemonic
instead @beaninfo description: The keystroke combination which will invoke the JMenuItem's actionlisteners without navigating the menu hierarchy hidden: true
Sets the suggested delay before the menu'sClass JMenu, void setMenuLocation(int, int)PopupMenu
is popped up or down. Each look and feel (L&F) may determineitsit's own policy for observing the delay property. In most cases the delay is not observed for top level menus or while dragging. This method is a property of the look and feel code and is used to manage the idiosyncracies of the various UI implementations. @param d the number of milliseconds to delay @exception IllegalArgumentException ifthe value ofd
is less than 0.@beaninfo description: The delay between menu selection and making the popup menu visible expert: true
Class JMenu, void setModel(ButtonModel)SetSets the location of the popup component. @param x the x coordinate of the popup's new position @param y the y coordinate of the popup's new position
Class JMenu, void setPopupMenuVisible(boolean)SetSets the data model for the "menu button" -- the label that the user clicks to open or close the menu. @parammnewModel theButtonModel
@see #getModel @beaninfo description: The menu's model bound: true expert: true hidden: true
Class JMenu, void setSelected(boolean)SetSets the visibility of theMenumenu's popupportion.The popup may only beIfmade visible ifthe menu isitself showing onnot enabled thisthemethod will have noscreeneffect. @param b a boolean value -- true to make the menu visible false to hide it @beaninfo description: The popup menu's visibility expert: true hidden: true
Sets the selection status of the menu. @param bClass JMenu, void updateUI()a boolean value --true to select (highlight) the menuand;open itfalse tounselectde-select the menuand close it@beaninfo description: When the menu is selected its popup child is shown. expert: true hidden: true
Notification from theUIFactory
that the L&F has changed. Called to replace the UI with the latest version from theUIFactory
. @see JComponent#updateUI
An implementation of aMenuBarmenu bar. You addJMenu
objects to the menu bar to construct a menu. When the user selects aJMenu
object its associatedJPopupMenu
is displayed allowing the user to select one of theJMenuItems
on it.For information and examples of using menu bars see How to Use Menus a section in The Java Tutorial. For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JMenuBar key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer true description: A container for holding and displaying menus. @version 1.
52 0484 03/0914/9800 @author Georges Saab @author David Karlton @author Arnaud Weber @see JMenu @see JPopupMenu @see JMenuItem
Class JMenuBar.AccessibleJMenuBar, AccessibleSelection getAccessibleSelection()TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJMenuBar
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to menu bar user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Get the AccessibleSelection associated with this object.if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleSelection interface on behalf of itself. @return this object
Appends the specified menu to the end of the menu bar. @param c the JMenu
component to add @return the menu component
Class JMenuBar, void addNotify()OverridesClass JMenuBar, AccessibleContext getAccessibleContext()JComponent.addNotify
to register this menu bar with the currentKeyboardManagerkeyboard manager.
Class JMenuBar, Component getComponent()GetGets the AccessibleContext associated with thisJComponentJMenuBar. For JMenuBars the AccessibleContext takes the form of an AccessibleJMenuBar. A new AccessibleJMenuBar instance is created if necessary. @return an AccessibleJMenuBar that serves as the AccessibleContext of thisJComponentJMenuBar
Implemented to be aClass JMenuBar, Component getComponentAtIndex(int)MenuElement
. Returns this object. @return the currentComponent
(this) @see #getSubElements
Returns the component at the specified index.Class JMenuBar, int getComponentIndex(Component)This method is obsolete please use getComponent(int i) instead.@param i anintinteger specifying the position where 0=is first @return theComponent
at the position ornull
for an invalid index @deprecated replaced bygetComponent(int i)
Returns the index of the specified component. @param c theClass JMenuBar, JMenu getHelpMenu()Component
to find @return anintinteger giving the component's position where 0=is first; or -1 if it can't be found
Gets the help menu for the menu bar. This method is not yet implemented and will throw an exception. @return the JMenu
that delivers help to the user
Class JMenuBar, Insets getMargin()Returns the margin between the menubar's border and its menus. If there is no previous margin it will create a default margin with zero size. @return an Insets
object containing the margin values @see Insets
Class JMenuBar, JMenu getMenu(int)Class JMenuBar, SingleSelectionModel getSelectionModel()GetsReturns the menu at the specified position in the menu bar. @param index anintinteger giving the position in the menu bar where 0 is the first position @return theJMenu
at that position ornull
if if there is noJMenu
at that position (ie. if it is aJMenuItem
)
Returns the model object that handles single selections. @return theClass JMenuBar, MenuElement[] getSubElements()SingleSelectionModel
inpropertyuse@see SingleSelectionModel
Implemented to be aClass JMenuBar, String getUIClassID()MenuElement
-- returns the menus in this menu bar. This is the reason for implementing theMenuElement
interface -- so that the menu bar can be treated the same as other menu elements. @return an array of menu items in the menu bar.
Returns the name of the L&F class that renders this component. @return the string "MenuBarUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JMenuBar, boolean isBorderPainted()
Returns true if theClass JMenuBar, boolean isSelected()Menubar'smenu bars border should be painted. @return true if the border should be painted else false
Returns true if theClass JMenuBar, void menuSelectionChanged(boolean)MenuBarmenu bar currently has a component selected. @return true if a selection has been made else false
Implemented to be aClass JMenuBar, void paintBorder(Graphics)MenuElementMenuElemen
t
-- does nothing. @see #getSubElements
Class JMenuBar, String paramString()PaintPaints the menubar's border ifBorderPainted
property is true. @param g theGraphics
context to use for painting @see JComponent#paint @see JComponent#setBorder
Returns a string representation of thisClass JMenuBar, void processKeyEvent(KeyEvent, MenuElement[], MenuSelectionManager)JMenuBar
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJMenuBar
.
Implemented to be a MenuElement
-- does nothing. @see #getSubElements
Class JMenuBar, void processMouseEvent(MouseEvent, MenuElement[], MenuSelectionManager)Implemented to be a MenuElement
-- does nothing. @see #getSubElements
Class JMenuBar, void removeNotify()OverridesClass JMenuBar, void setBorderPainted(boolean)JComponent.removeNotify
to unregister this menu bar with the currentKeyboardManagerkeyboard manager.
Sets whether the border should be painted. @param b if true and border property is not null
the border is painted. @see #isBorderPainted @beaninfo bound: true attribute: visualUpdate true description: Whether the border should be painted.
Class JMenuBar, void setHelpMenu(JMenu)Sets the help menu that appears when the user selects the "help" option in the menu bar. This method is not yet implemented and will throw an exception. @param menu the JMenu that delivers help to the userClass JMenuBar, void setMargin(Insets)
Sets the margin between the menubar's border and its menus. Setting to null
will cause the menubar to use the default margins. @param margin an Insets object containing the margin values @see Insets @beaninfo bound: true attribute: visualUpdate true description: The space between the menubar's border and its contents
Class JMenuBar, void setSelected(Component)Sets the currently selected component producing a a change to the selection model. @param sel the Component
to select
Class JMenuBar, void setSelectionModel(SingleSelectionModel)Class JMenuBar, void updateUI()SetSets the model object to handle single selections. @param model theSingleSelectionModel
to use @see SingleSelectionModel @beaninfo bound: true description: The selection model recording which child is selected.
Notification from theUIFactory
that the L&F has changed. Called to replace the UI with the latest version from theUIFactory
. @see JComponent#updateUI
An implementation of an item in aMenuItemmenu. A menu item is essentially a button sitting in a list. When the user selects the "button" the action associated with the menu item is performed. A JMenuItem contained in a JPopupMenu performs exactly that function.For further documentation and for examples see How to Use Menus in The Java Tutorial. For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JMenuItem key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: An item which can be selected in a menu. @version 1.
77 0991 03/2214/00 @author Georges Saab @author David Karlton @see JPopupMenu @see JMenu @see JCheckBoxMenuItem @see JRadioButtonMenuItem
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJMenuItem
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to menu item user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Creates aClass JMenuItem, AccessibleContext getAccessibleContext()menuItemmenu item with the supplied text and icon. @param text the text of the MenuItem. @param icon the icon of the MenuItem.
Class JMenuItem, void setAccelerator(KeyStroke)GetGets the AccessibleContext associated with thisJComponentJMenuItem. For JMenuItems the AccessibleContext takes the form of an AccessibleJMenuItem. A new AccessibleJMenuItme instance is created if necessary. @return an AccessibleJMenuItem that serves as the AccessibleContext of thisJComponentJMenuItem
Set the key combination which invokes the Menu Item's action listeners without navigating the menu hierarchy. It is the UIs responsibility to do install the correct action. @param keyStroke the KeyStroke which will serve as an accelerator @beaninfo description: The keystroke combination which will invoke the JMenuItem's actionlisteners without navigating the menu hierarchy bound: true preferred: trueClass JMenuItem, void updateUI()
NotificationResetsfrom the UIFactory thattheL&F has changed. CalledUIto replace the UI withproperty with a value from thelatest versioncurrentfrom the UIFactorylook and feel. @see JComponent#updateUI
JOptionPane
makes it easy to pop up a standard dialog box that prompts users for a value or informs them of something. For information about usingJOptionPane
see How to Make Dialogs a section in The Java Tutorial.While the
JOptionPane
class may appear complex because of the large number of methods almost all uses of this class are one-line calls to one of the staticshowXxxDialog
methods shown below:Each of these methods also comes in a
showConfirmDialog Asks a confirming question like yes/no/cancel. showInputDialog Prompt for some input. showMessageDialog Tell the user about something that has happened. showOptionDialog The Grand Unification of the above three. showInternalXXX
flavor which uses an internal frame to hold the dialog box (see Multipl convenience methods have also been defined -- overloaded versions of the basic methods that use different parameter lists.All dialogs are modal. Each
showXxxDialog
method blocks the current thread until the user's interaction is complete.
The basic appearance of one of these dialog boxes is generally similar to the picture at the right although the various look-and-feels are ultimatly responsible for the final result.
icon message input value option buttons
Parameters:
The parameters to these methods follow consistent patterns:
- parentComponent
- Defines the
Component
that is to be the parent of this dialog box. It is used in two ways: theFrame
that contains it is used as theFrame
parent for the dialog box and its screen coordinates are used in the placement of the dialog box. In general the dialog box is placed just below the component. This parameter may benull
in which case a defaultFrame
is used as the parent and the dialog will be centered on the screen (depending on the L&F).- message
- A descriptive message to be placed in the dialog box. In the most common usage message is just a
String
orString
constant. However the type of this parameter is actuallyObject
.It'sIts interpretation depends on its type:
- Object[]
- An array of objects is interpreted as a series of messages (one per object) arranged in a vertical stack. The interpretation is recursive -- each object in the array is interpreted according to its type.
- Component
- The
Component
is displayed in the dialog.- Icon
- The
Icon
is wrapped in aJLabel
and displayed in the dialog.- others
- The object is converted to a
String
by calling itstoString
method. The result is wrapped in aJLabel
and displayed.- messageType
- Defines the style of the message. The
look&feelLook and Feel manager may lay out the dialog differently depending on this value and will often provide a default icon. The possible values are:
- ERROR_MESSAGE
- INFORMATION_MESSAGE
- WARNING_MESSAGE
- QUESTION_MESSAGE
- PLAIN_MESSAGE
- optionType
- Defines the set of option buttons that appear at the bottom of the dialog box:
You aren't limited to this set of option buttons. You can provide any buttons you want using the options parameter.
- DEFAULT_OPTION
- YES_NO_OPTION
- YES_NO_CANCEL_OPTION
- OK_CANCEL_OPTION
- options
- A more detailed description of the set of option buttons that will appear at the bottom of the dialog box. The usual value for the options parameter is an array of
StringsString
s. But the parameter type is an array ofObjects
. A button is created for each object depending onit'sits type:
- Component
- The component is added to the button row directly.
- Icon
- A
JButton
is created with this as its label.- other
- The
Object
is converted to a string using itstoString
method and the result is used to label aJButton
.- icon
- A decorative icon to be placed in the dialog box. A default value for this is determined by the
messageType
parameter.- title
- The title for the dialog box.
- initialValue
- The default selection (input value).
When the selection is changed
setValue
is invoked which generates aPropertyChangeEvent
.If a
JOptionPane
has configured to all inputsetWantsInput
the bound propertyJOptionPane.INPUT_VALUE_PROPERTY
can also be listened to to determine when the user has input or selected a value.When one of the
showXxxDialog
methods returns an integer the possible values are:YES_OPTION NO_OPTION CANCEL_OPTION OK_OPTION or CLOSED_OPTION.Examples:Direct Use:
- Show an error dialog that displays the message 'alert':
JOptionPane.showMessageDialog(null "alert" "alert" JOptionPane.ERROR_MESSAGE);
- Show an internal information dialog with the message 'information':
JOptionPane.showInternalMessageDialog(frame
INFORMATION_MESSAGE"information"
"information"
"information"JOptionPane.INFORMATION_MESSAGE);
- Show an information panel with the options yes/no and message 'choose one':
JOptionPane.showConfirmDialog(null
"choose one" "choose one" JOptionPane.YES_NO_OPTION);
- Show an internal information dialog with the options yes/no/cancel and message 'please choose one' and title information:
JOptionPane.showInternalConfirmDialog(frame
"please choose one" "information"
JOptionPane.YES_NO_CANCEL_OPTION JOptionPane.INFORMATION_MESSAGE);
- Show a warning dialog with the options OK CANCEL title 'Warning' and message 'Click OK to continue':
Object[] options = { "OK" "CANCEL" };
JOptionPane.showOptionDialog(null "Click OK to continue" "Warning"
JOptionPane.DEFAULT_OPTION JOptionPane.WARNING_MESSAGE
null options options[0]);
- Show a dialog asking the user to type in a String:
String inputValue = JOptionPane.showInputDialog("Please input a value");
- Show a dialog asking the user to select a String:
Object[] possibleValues = { "First" "Second" "Third" };
Object selectedValue = JOptionPane.showInputDialog(null
"Choose one" "Input"
JOptionPane.INFORMATION_MESSAGE null
possibleValues possibleValues[0]);
To create and use anJOptionPane
directly the standard pattern is roughly as follows:JOptionPane pane = new JOptionPane(arguments); pane.set.Xxxx(...); // Configure JDialog dialog = pane.createDialog(parentComponent title); dialog.show(); Object selectedValue = pane.getValue(); if(selectedValue == null) return CLOSED_OPTION; //If there is not an array of option buttons: if(options == null) { if(selectedValue instanceof Integer) return ((Integer)selectedValue).intValue(); return CLOSED_OPTION; } //If there is an array of option buttons: for(int counter = 0 maxCounter = options.length; counterFor the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JOptionPane key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JInternalFrame @beaninfo attribute: isContainer true description: A component which implements standard dialog box controls. @version 1.
46 0957 03/2914/9800 @author James Gosling @author Scott Violet
AccessiblityThis class implements accessibility support for theJOptionPane
class. It provides an implementation of the Java Accessibility API appropriate to option pane user-interface elements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Creates a JOptionPane
with a test message.
Class JOptionPane, constructor JOptionPane(Object)Creates a instance ofClass JOptionPane, constructor JOptionPane(Object, int)JOptionPane
to display a message using the plain-message message type and the default options delivered by the UI. @param message theObject
to display
Creates an instance ofClass JOptionPane, constructor JOptionPane(Object, int, int)JOptionPane
to display a message with the specified message type and the default options @param message theObject
to display @param messageType the type of message to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.
Creates an instance ofClass JOptionPane, constructor JOptionPane(Object, int, int, Icon)JOptionPane
to display a message with the specified message type and options. @param message theObject
to display @param messageType the type of message to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param optionType the options to display in the pane: DEFAULT_OPTION YES_NO_OPTION YES_NO_CANCEL_OPTION OK_CANCEL_OPTION
Creates an instance ofClass JOptionPane, constructor JOptionPane(Object, int, int, Icon, Object[])JOptionPane
to display a message with the specified message type options and icon. @param message theObject
to display @param messageType the type of message to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param optionType the options to display in the pane: DEFAULT_OPTION YES_NO_OPTION YES_NO_CANCEL_OPTION OK_CANCEL_OPTION @param icon theIcon
image to display
Creates an instance of JOptionPane to display a message with the specified message type icon and options. None of the options is initially selected.Class JOptionPane, constructor JOptionPane(Object, int, int, Icon, Object[], Object)The options objects should contain either instances of
ComponentsComponent
s (which are added directly) orStrings
(which are wrapped in aJButton
). If you provideComponentsComponent
s you must ensure that when theComponent
is clicked it messagessetValue
in the createdJOptionPane
. @param message theObject
to display @param messageType the type of message to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param optionType the options to display in the pane: DEFAULT_OPTION YES_NO_OPTION YES_NO_CANCEL_OPTION OK_CANCEL_OPTION. Only; only meaningful if theoptions
parameter isnull
@param icon the.Icon
image to display @param options the choices the user can select
Creates an instance ofClass JOptionPane, JDialog createDialog(Component, String)JOptionPane
to display a message with the specified message type icon and options with theinititiallyinitially-selected option specified. @param message theObject
to display @param messageType the type of message to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param optionType the options to display in the pane: DEFAULT_OPTION YES_NO_OPTION YES_NO_CANCEL_OPTION OK_CANCEL_OPTION. Only; only meaningful if theoptions
parameter isnull
@param icon the Icon image to display @param options the choices the user can select @param initialValue the choice that is initially selected.
Creates and returns a newClass JOptionPane, JInternalFrame createInternalFrame(Component, String)JDialog
wrappingthis
centered on theparentComponent
in theparentComponent
's frame.title
is the title of the returned dialog. The returnedJDialog
will be set up such that once it is closed or the user clicks on the OK button the dialog will be disposed and closed.Re@param parentComponent determines the frame in which the dialog is displayed; if theparentComponent
has noFrame
a defaultFrame
is used.@param title the title string for the dialog @return a newJDialog
containing this instance
Creates and returns an instance ofClass JOptionPane, AccessibleContext getAccessibleContext()JInternalFrame
. The internal frame is created with the specified title and wrapping theJOptionPane
. The returnedJInternalFrame
is added to theJDesktopPane
ancestor ofparentComponent
or components parent if one its ancestors isn't aJDesktopPane
or ifparentComponent
doesn't have a parent then aRuntimeException
is thrown. @param parentComponent the parentComponent
for the internal frame @param title theString
to display in the frame's title bar @return aJInternalFrame
containing aJOptionPane
@exception RuntimeException ifparentComponent
does not have a valid parent
Class JOptionPane, JDesktopPane getDesktopPaneForComponent(Component)GetGets the AccessibleContext associated with thisJComponentJOptionPane. For option panes the AccessibleContext takes the form of an AccessibleJOptionPane. A new AccessibleJOptionPane instance is created if necessary. @return an AccessibleJOptionPane that serves as the AccessibleContext of thisJComponentAccessibleJOptionPane @beaninfo expert: true description: The AccessibleContext associated with this option pane
Returns the specified component's desktop pane. @param parentComponent theClass JOptionPane, Frame getFrameForComponent(Component)Component
to check for a desktop @return theJDesktopPane
that contains the component ornull
if the component isnull
or does not have an ancestor that is aJInternalFrame
Returns the specified component'sClass JOptionPane, Icon getIcon()Frame
. @param parentComponent theComponent
to check for aFrame
@return theFrame
that contains the component or the default frame if the component isnull
or does not have a validFrame
parent
Returns the icon this pane displays. @return the Icon
that is displayed @see #setIcon
Class JOptionPane, Object getInitialSelectionValue()Returns the initial-selection value.Class JOptionPane, Object getInitialValue().@return the initially selected value @see #setInitialSelectionValue @see #setSelectionValues
Returns the initial value. @return the Object
that gets the initial keyboard focus @see #setInitialValue
Class JOptionPane, Object getInputValue()Returns the value the user has input ifClass JOptionPane, int getMaxCharactersPerLineCount()wantsInput
is true. @return theObject
the user specified if it was one of the objects or aString
if it was a value typed into a field.@see #setSelectionValues @see #setWantsInput @see #setInputValue
Returns the maximum number of characters to place on a line in a message. Default is to returnClass JOptionPane, Object getMessage()Integer.MAX_VALUE
. The value can be changed by overriding this method in asubclassesubclass. @return anintinteger giving the maximum number of characters on a line
Returns the message-object this pane displays. @see #setMessage @return the Object
that is displayed
Class JOptionPane, int getMessageType()Returns the message type. @return anClass JOptionPane, int getOptionType()intinteger specifying the message type @see #setMessageType
Returns the type of options that are displayed. @return anClass JOptionPane, Object[] getOptions()intinteger specifying the user-selectable options @see #setOptionType
Returns the choices the user can make. @Class JOptionPane, Frame getRootFrame()paramreturn the array ofObjects
that give the user's choices @see #setOptions
Returns theClass JOptionPane, Object[] getSelectionValues()Frame
to use for the class methods in which a frame is not provided. @return the defaultFrame
to use
Returns the selection values. @param return the array of Objects
the user can select @see #setSelectionValues
Class JOptionPane, OptionPaneUI getUI()Returns the UI object which implements the L&F for this component. @return the OptionPaneUI
object
Class JOptionPane, String getUIClassID()Returns the name of the UI class that implements the L&F for this component. @return the string "OptionPaneUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JOptionPane, Object getValue()
Returns the value the user has selected. UNINITIALIZED_VALUE implies the user has not yet made a choiceClass JOptionPane, boolean getWantsInput()null
means the user closed the window with outchosingchoosing anything. Otherwise the returned value will be one of the options defined in this object. @return theObject
chosen by the user UNINITIALIZED_VALUE if the user has not yet made a choice ornull
if the user closed the window without making a choice.@see #setValue
Returns true if aClass JOptionPane, String paramString()parentComponent
will be provided for the user to input. @return true if aparentComponent
will be provided @see #setWantsInput
Returns a string representation of thisClass JOptionPane, void setIcon(Icon)JOptionPane
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJOptionPane
.
Sets the icon to display. If non-Class JOptionPane, void setInitialValue(Object)null
thelookLook andfeelFeel does not provide an icon. @param icon theIcon
to display @see #getIcon @beaninfo preferred: true bound: true description: The option pane's type icon.
Sets the initial value that is to be enabled -- theClass JOptionPane, void setInputValue(Object)Component
that has the focus when the pane is initially displayed. @param newInitialValue theObject
that gets the initial keyboard focus @see #getInitialValue @beaninfo preferred: true bound: true description: The option pane's initial value object.
Sets the user's input-value. @param newValue the Object
used to initialized the value that the user specified (usually in a text field) @see #setSelectionValues @see #setWantsInput @see #getInputValue @beaninfo preferred: true bound: true description: The option pane's input value object.
Class JOptionPane, void setMessage(Object)Sets the option pane's message-object. @param newMessage the Object
to display @see #getMessage @beaninfo preferred: true bound: true description: The optionpane's message object.
Class JOptionPane, void setMessageType(int)Sets the option pane's message type. The message type is used by theClass JOptionPane, void setOptionType(int)lookLook andfeelFeel to determine the icon to display (if not supplied) as well as potentially how to lay out theparentComponent
. @param newType anintinteger specifying the kind of message to display: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@exceptionOtherwise aRuntimeException ifRuntimeEceptionnewType
isthrown.not one of the legal values listed above @see #getMessageType @beaninfo preferred: true bound: true description: The option pane's message type.
Sets the options to display. The option type is used by theClass JOptionPane, void setOptions(Object[])lookLook andfeelFeel to determine what buttons to show (unless options are supplied). @param newType anintinteger specifying the options the L&F is to display: DEFAULT_OPTION YES_NO_OPTION YES_NO_CANCEL_OPTION or OK_CANCEL_OPTION. Otherwisea@exception RuntimeException ifnewType
isthrown.not one of the legal values listed above @see #getOptionType @see #setOptions @beaninfo preferred: true bound: true description: The option pane's option type.
Sets the options this pane displays. If an element inClass JOptionPane, void setRootFrame(Frame)newOptions
is aComonentComponent
it is added directly to the paneOtherwiseotherwise a button is created for the element. @param newOptions an array ofObjects
that create the buttons the user can click on or arbitraryComponents
to add to the pane @see #getOptions @beaninfo bound: true description: The option pane's options objects.
Sets the frame to use for class methods in which a frame is not provided. @param newRootFrame the default Frame
to use
Class JOptionPane, void setSelectionValues(Object[])Sets the selection values for a pane that provides the user with a list of items to choose from. (The UI provides a widget for choosing one of the values.)Class JOptionPane, void setUI(OptionPaneUI)Sets
wantsInput
to true. UsesetInitialSelectionValue
to specify the initially-chosen value. After the pane as been enabledinputValue
is set to the value the user has selected. @param newValues an array ofObjects
the user to be displayed (usually in a list or combo-box) from which the user can make a selection @see #setWantsInput @see #setInitialSelectionValue @see #getSelectionValues @beaninfo bound: true description: The option pane's selection values.
Sets the UI object which implements the L&F for this component. @param ui the OptionPaneUI
L&F object @see UIDefaults#getUI @beaninfo bound: true hidden: true description: The UI object that implements the optionpane's LookAndFeel
Class JOptionPane, void setWantsInput(boolean)IfClass JOptionPane, int showConfirmDialog(Component, Object)newValue
is true aparentComponent
is provided to allow the user to input a value. IfgetSelectionValues
returns a non-null
the input value is one of the objects in that array. Otherwise the input value is whatever the user inputs.This is a bound property. @see #setSelectionValues @see #setInputValue @beaninfo preferred: true bound: true description: Flag which allows the user to input a value.
Brings up a modal dialog with the options Yes No and Cancel; with the title "Select an Option". @param parentComponentClass JOptionPane, int showConfirmDialog(Component, Object, String, int)Determinesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThetheObject
to display @return anintinteger indicating the option selected by the user
Brings up a modal dialog where the number of choices is determined by theClass JOptionPane, int showConfirmDialog(Component, Object, String, int, int)optionType
parameter. @param parentComponentDeterminesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThetheObject
to display @param title the title string for the dialog @param optionType an int designating the options available on the dialog: YES_NO_OPTION or YES_NO_CANCEL_OPTION @return an int indicating the option selected by the user
Brings up a modal dialog where the number of choices is determined by theClass JOptionPane, int showConfirmDialog(Component, Object, String, int, int, Icon)optionType
parameter where themessageType
parameter determines the icon to display. ThemessageType
parameter is primarily used to supply a default icon from thelookLook andfeelFeel. @param parentComponentDeterminesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used. @param messageThetheObject
to display @param title the title string for the dialog @param optionType anintinteger designating the options available on the dialog: YES_NO_OPTION or YES_NO_CANCEL_OPTION @param messageType anintinteger designating the kind of message this is primarily used to determine the icon from the pluggablelookLook andfeelFeel: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@return anintinteger indicating the option selected by the user
Brings up a modal dialog with a specified icon where the number of choices is determined by theClass JOptionPane, String showInputDialog(Component, Object)optionType
parameter. ThemessageType
parameter is primarily used to supply a default icon from thelookLook andfeelFeel. @param parentComponentDeterminesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param message The Object to display @param title the title string for the dialog @param optionType an int designating the options available on the dialog: YES_NO_OPTION or YES_NO_CANCEL_OPTION @param messageType an int designating the kind of message this is primarily used to determine the icon from the pluggablelookLook andfeelFeel: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param icon the icon to display in the dialog @return an int indicating the option selected by the user
Shows a question-message dialog requesting input from the user parented toClass JOptionPane, String showInputDialog(Component, Object, String, int)parentComponent
. The dialog is displayed in the Component's frame and is usually positioned below theComponent
. @param parentComponent the parentComponent
for the dialog @param message theObject
to display
Shows a dialog requesting input from the user parented toClass JOptionPane, Object showInputDialog(Component, Object, String, int, Icon, Object[], Object)parentComponent
with the dialog having the titletitle
and message typemessageType
. @param parentComponent the parentComponent
for the dialog @param message theObject
to display @param title theString
to display in the dialog title bar @param messageType the type of message that is to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.
Prompts the user for input in a blocking dialog where the initial selection possible selections and all other options can be specified. The user will able to choose fromClass JOptionPane, String showInputDialog(Object)selectionValues
wherenull
implies the user can input whatever they wish usually by means of aJTextField
.initialSelectionValue
is the initial value to prompt the user with. It is up to the UI to decide how best to represent theselectionValues
but usually aJComboBox
JList
orJTextField
will be used. @param parentComponent the parentComponent
for the dialog @param message theObject
to display @param title theString
to display in the dialog title bar @param messageType the type of message to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param icon the Icon image to display @param selectionValues an array ofObjectsObject
s that gives the possible selections @param initialSelectionValue the value used to initialize the input field @return users input ornull
meaning the usercanceledcancelled the input
Shows a question-message dialog requesting input from the user. The dialog uses the default frame which usually means it is centered on the screen. @param message the Object
to display
Class JOptionPane, int showInternalConfirmDialog(Component, Object)Brings up an internal dialog panel with the options Yes No and Cancel; with the title "Select an Option". @param parentComponentClass JOptionPane, int showInternalConfirmDialog(Component, Object, String, int)Determinesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThetheObject
to display @return anintinteger indicating the option selected by the user
Brings up a internal dialog panel where the number of choices is determined by theClass JOptionPane, int showInternalConfirmDialog(Component, Object, String, int, int)optionType
parameter. @param parentComponentDeterminesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThethe object to display in the dialog.;AaComponent
object is rendered as aComponent
;.AaString
object is rendered as a string. Other; other objects are converted to aString
using thetoString
method.@param title the title string for the dialog @param optionType anintinteger designating the options available on the dialog: YES_NO_OPTION or YES_NO_CANCEL_OPTION @return anintinteger indicating the option selected by the user
Brings up an internal dialog panel where the number of choices is determined by theClass JOptionPane, int showInternalConfirmDialog(Component, Object, String, int, int, Icon)optionType
parameter where themessageType
parameter determines the icon to display. ThemessageType
parameter is primarily used to supply a default icon from thelookLook andfeelFeel. @param parentComponentDeterminesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThethe object to display in the dialog.;AaComponent
object is rendered as aComponent
;.AaString
object is rendered as a string. Other; other objects are converted to aString
using thetoString
method.@param title the title string for the dialog @param optionType anintinteger designating the options available on the dialog: YES_NO_OPTION or YES_NO_CANCEL_OPTION @param messageType anintinteger designating the kind of message this is primarily used to determine the icon from the pluggablelookLook andfeelFeel: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@return anintinteger indicating the option selected by the user
Brings up an internal dialog panel with a specified icon where the number of choices is determined by theClass JOptionPane, String showInternalInputDialog(Component, Object)optionType
parameter. ThemessageType
parameter is primarily used to supply a default icon from thelookLook andfeelFeel. @param parentComponentDeterminesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if the parentComponent has no Frame a defaultFrame
is used.@param messageThethe object to display in the dialog.;AaComponent
object is rendered as aComponent
;.AaString
object is rendered as a string. Other; other objects are converted to aString
using thetoString
method.@param title the title string for the dialog @param optionType anintinteger designating the options available on the dialog: YES_NO_OPTION or YES_NO_CANCEL_OPTION @param messageType anintinteger designating the kind of message this is primarily used to determine the icon from the pluggablelookLook andfeelFeel: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param icon the icon to display in the dialog @return anintinteger indicating the option selected by the user
Shows an internal question-message dialog requesting input from the user parented toClass JOptionPane, String showInternalInputDialog(Component, Object, String, int)parentComponent
. The dialog is displayed in theComponent
's frame and is usually positioned below theComponent
. @param parentComponent the parentComponent
for the dialog @param message theObject
to display
Shows an internal dialog requesting input from the user parented toClass JOptionPane, Object showInternalInputDialog(Component, Object, String, int, Icon, Object[], Object)parentComponent
with the dialog having the titletitle
and message typemessageType
. @param parentComponent the parentComponent
for the dialog @param message theObject
to display @param title theString
to display in the dialog title bar @param messageType the type of message that is to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.
Prompts the user for input in a blocking internal dialog where the initial selection possible selections and all other options can be specified. The user will able to choose fromClass JOptionPane, void showInternalMessageDialog(Component, Object)selectionValues
wherenull
implies the user can input whatever they wish usually by means of aJTextField
.initialSelectionValue
is the initial value to prompt the user with. It is up to the UI to decide how best to represent theselectionValues
but usually aJComboBox
JList
orJTextField
will be used. @param parentComponent the parentComponent
for the dialog @param message theObject
to display @param title theString
to display in the dialog title bar @param messageType the type of message to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param icon theIcon
image to display @param selectionValues an array ofObjects
that gives the possible selections @param initialSelectionValue the value used to initialize the input field @return users input ornull
meaning the usercanceledcancelled the input
Brings up an internal confirmation dialog panel. The dialog is a modal information-message dialog titled "Message". @param parentComponentClass JOptionPane, void showInternalMessageDialog(Component, Object, String, int)Determinesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThethe object to display
Brings up an internal dialog panel that displays a message using a default icon determined by theClass JOptionPane, void showInternalMessageDialog(Component, Object, String, int, Icon)messageType
parameter. @param parentComponentDeterminesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThetheObject
to display @param title the title string for the dialog @param messageType the type of message to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.
Brings up an internal dialog panel displaying a message specifying all parameters. @param parentComponentClass JOptionPane, int showInternalOptionDialog(Component, Object, String, int, int, Icon, Object[], Object)Determinesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThetheObject
to display @param title the title string for the dialog @param messageType the type of message to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param icon an icon to display in the dialog that helps the user identify the kind of message that is being displayed.
Brings up an internal dialog panel with a specified icon where the initial choice is dermined by theClass JOptionPane, void showMessageDialog(Component, Object)initialValue
parameter and the number of choices is determined by theoptionType
parameter.If
optionType
is YES_NO_OPTION or YES_NO_CANCEL_OPTION and theoptions
parameter isnull
then the options are supplied by thelookLook andfeelFeel.The
messageType
parameter is primarily used to supply a default icon from thelookLook andfeelFeel. @param parentComponentDeterminesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThethe object to display in the dialog.;AaComponent
object is rendered as aComponent
;.AaString
object is rendered as a string. Other objects are converted to aString
using thetoString
method.@param title the title string for the dialog @param optionType anintinteger designating the options available on the dialog: YES_NO_OPTION or YES_NO_CANCEL_OPTION @param messageType anintinteger designating the kind of message this is primarily used to determine the icon from the pluggablelookLook andfeelFeel: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param icon the icon to display in the dialog @param options an array of objects indicating the possible choices the user can make. If; if the objects are components they are rendered properly.;Nonnon-String
objects are rendered using theirtoString
methods. If; if this parameter isnull
the options are determined by thelookLook andfeel.Feel @param initialValue the object that represents the default selection for the dialog @return anintinteger indicating the option chosen by the user or CLOSED_OPTION if the user closed the Dialog
Brings up aClass JOptionPane, void showMessageDialog(Component, Object, String, int)confirmation dialog -- amodal information-message dialog titled "ConfirmMessage". @param parentComponentDeterminesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThetheObject
to display
Brings up a dialog that displays a message using a default icon determined by theClass JOptionPane, void showMessageDialog(Component, Object, String, int, Icon)messageType
parameter. @param parentComponentDeterminesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThetheObject
to display @param title the title string for the dialog @param messageType the type of message to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.
Brings up a dialog displaying a message specifying all parameters. @param parentComponentClass JOptionPane, int showOptionDialog(Component, Object, String, int, int, Icon, Object[], Object)Determinesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThetheObject
to display @param title the title string for the dialog @param messageType the type of message to be displayed: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param icon an icon to display in the dialog that helps the user identify the kind of message that is being displayed.
Brings up a modal dialog with a specified icon where the initial choice is dermined by theClass JOptionPane, void updateUI()initialValue
parameter and the number of choices is determined by theoptionType
parameter.If
optionType
is YES_NO_OPTION or YES_NO_CANCEL_OPTION and theoptions
parameter isnull
then the options are supplied by thelookLook andfeelFeel.The
messageType
parameter is primarily used to supply a default icon from thelookLook andfeelFeel. @param parentComponentDeterminesdetermines theFrame
in which the dialog is displayed. If; ifnull
or if theparentComponent
has noFrame
a defaultFrame
is used.@param messageThetheObject
to display @param title the title string for the dialog @param optionType anintinteger designating the options available on the dialog: YES_NO_OPTION or YES_NO_CANCEL_OPTION @param messageType anintinteger designating the kind of message this is primarily used to determine the icon from the pluggablelookLook andfeelFeel: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE or PLAIN_MESSAGE.@param icon the icon to display in the dialog @param options an array of objects indicating the possible choices the user can make. If; if the objects are components they are rendered properly.;Nonnon-String
objects are rendered using theirtoString
methods. If; if this parameter isnull
the options are determined by thelookLook andfeelFeel. @param initialValue the object that represents the default selection for the dialog @return anintinteger indicating the option chosen by the user or CLOSED_OPTION if the user closed the Dialog
Notification from theClass JOptionPane, int DEFAULT_OPTIONUIManager
that the L&F has changed. Replaces the current UI object with the latest version from theUIManager
. @see JComponent#updateUI
Type meaningClass JOptionPane, Object valuelookLook andfeelFeel should not supply any options -- only use the options from the JOptionPane.
Currently selected value will be a valid option or UNINITIALIZED_VALUE or null
.
JPanel is a generic lightweight container. For examples and task-oriented documentation for JPanel see How to Use Panels a section in The Java Tutorial.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @
see Mixing Heavy and Light Components @beaninfo description: A generic lightweight container. @version 1.30 0936 03/0114/9800 @author Arnaud Weber @author Steve Wilson
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJPanel
class.role forIt providesthisan implementation of the Java Accessibility API appropriate to panel user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
GetGets the AccessibleContext associated with thisJComponentJPanel. For JPanels the AccessibleContext takes the form of an AccessibleJPanel. A new AccessibleJPanel instance is created if necessary. @return an AccessibleJPanel that serves as the AccessibleContext of thisJComponentJPanel
JPasswordField is a lightweight component that allows the editing of a single line of text where the view indicates something was typed but does not show the original characters.ItYou can find further information and examples in How to Use Text Fields a section in The Java Tutorial. JPasswordField is intended to be source-compatible with java.awt.TextField used with echoChar set. It is provided seperately to make it easier to safely change the ui for the JTextField without affecting password entries.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JPasswordField key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: Allows the editing of a line of text but doesn't show the characters. @author Timothy Prinzing @version 1.
31 0941 03/1114/9800
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJPasswordField
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to password field user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Gets the AccessibleContext associated with this JPasswordField. For password fields the AccessibleContext takes the form of an AccessibleJPasswordField. A newClass JPasswordField, String getText()contextAccessibleJPasswordField instance is createdasif necessary. @return an AccessibleJPasswordField that serves as the AccessibleContext of this JPasswordField
Returns the text contained in this TextComponent. If the underlying document is null will give a NullPointerException.Class JPasswordField, String getText(int, int)For security reasons this method is deprecated. Use the getPassword method instead. @deprecated As of
JDKJavaversion2 platform1v1.2 replaced bygetPassword()
. @return the text
Fetches a portion of the text represented by the component. Returns an empty string if length is 0.For security reasons this method is deprecated. Use the getPassword method instead. @deprecated As of
JDKJavaversion2 platform1v1.2 replaced bygetPassword()
. @param offs the offset >= 0 @param len the length >= 0 @return the text @exception BadLocationException if the offset or length are invalid
An implementation of aPopup Menupopup menu -- a small windowwhichthat pops up and displays a series of choices. AJPopupMenu
is used for the menu that appears when the user selects an item on the menu bar. It is also used for "pull-right" menu that appears when the selects a menu item that activates it. Finally aJPopupMenu
can also be used anywhere else you want a menu to appear--.forFor example when the user right-clicks in a specified area.For information and examples of using popup menus see How to Use Menus in The Java Tutorial. For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JPopupMenu key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A small window that pops up and displays a series of choices. @version 1.
131 05149 11/0327/9900 @author Georges Saab @author David Karlton @author Arnaud Weber
AClass JPopupMenu.Separator, String getUIClassID()popupmenupopup menu-specific separator.
Returns the name of the L&F class that renders this component. @return the string "PopupMenuSeparatorUI" @see JComponent#getUIClassID @see UIDefaults#getUI
Class JPopupMenu, constructor JPopupMenu(String)CreateConstructs aJPopupMenu
without an "invoker".
Class JPopupMenu, JMenuItem add(Action)CreateConstructs aJPopupMenu
with the specified title. @param labelThethe string that a UI may use to display as a title for the popup menu.
Class JPopupMenu, JMenuItem add(JMenuItem)AppendAppends a newmenuitemmenu item to the end of the menu which dispatches the specifiedAction
object. As of JDK 1.3 this is no longer the preferred method for addingActions
to a container. Instead it is recommended to configure a control with an action usingsetAction
and then add that control directly to theContainer
. @param a theAction
to add to the menu @return the new menu item @see Action
Appends the specified menu item to the end of this menu. @param c theClass JPopupMenu, JMenuItem add(String)JMenuItem
to add @return theJMenuItem
added.
Creates a newClass JPopupMenu, void addPopupMenuListener(PopupMenuListener)menuitemmenu item with the specified text and appends it to the end of this menu. @param s the string for themenuitemmenu item to be added
Class JPopupMenu, void firePopupMenuCanceled()AddAdds aPopupMenu
listener. @param l thePopupMenuListener
to add
NotifiesClass JPopupMenu, void firePopupMenuWillBecomeInvisible()PopupMenuListeners
that this popup menu iscanceledcancelled.
NotifiesClass JPopupMenu, void firePopupMenuWillBecomeVisible()PopupMenuListenersPopupMenuListener
s that this popup menu will become invisible.
NotifiesClass JPopupMenu, AccessibleContext getAccessibleContext()PopupMenuListenersPopupMenuListener
s that this popup menu will become visible.
Class JPopupMenu, Component getComponentAtIndex(int)GetGets the AccessibleContext associated with thisJComponentJPopupMenu. For JPopupMenus the AccessibleContext takes the form of an AccessibleJPopupMenu. A new AccessibleJPopupMenu instance is created if necessary. @return an AccessibleJPopupMenu that serves as the AccessibleContext of thisJComponentJPopupMenu
Returns the component at the specified index.Class JPopupMenu, int getComponentIndex(Component)This method is obsolete please use getComponent(int i) instead.@param i the index of the component where 0 is the first @return theComponent
at that index @deprecated replaced bygetComponent(int i)
Returns the index of the specified component. @param the Component
to find @return the index of the component where 0 is the first; or -1 if the component is not found
Class JPopupMenu, boolean getDefaultLightWeightPopupEnabled()Class JPopupMenu, Component getInvoker()ReturnReturnsthetrue if this is a light weightdefault value forpopup component false otherwise. @return thelightWeightPopupEnabled
property.@see #setDefaultLightWeightPopupEnabled
Returns the component which is the 'invoker' of this popup menu. @return the Component
in which the popup menu is displayed
Class JPopupMenu, String getLabel()Returns the popup menu's label @return aClass JPopupMenu, Insets getMargin()Stringstring containing the popup menu's label @see #setLabel
Returns the margin in pixels between theClass JPopupMenu, SingleSelectionModel getSelectionModel()popupmenupopup menu's border and its containees. @return anInsets
object containing the margin values.
Returns the model object that handles single selections. @return theClass JPopupMenu, PopupMenuUI getUI()SingleSelectionModel inselectionModel
useproperty @see SingleSelectionModel
Returns the look and feel (L&F) object that renders this component. @return the PopupMenuUI
object that renders this component
Class JPopupMenu, String getUIClassID()Returns the name of the L&F class that renders this component. @return the string "PopupMenuUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JPopupMenu, void insert(Action, int)
Inserts a menu item for the specifiedClass JPopupMenu, void insert(Component, int)Action
object at a given position. @paramcomponenta theAction
object to insert @param indexan int specifyingspecifies the position at which to insert theAction
where 0 is the first @see Action
Inserts the specified component into the menu at a given position. @param component theClass JPopupMenu, boolean isBorderPainted()Component
to insert @param indexanspecifiesint specifyingthe position at which to insert the component where 0 is the first @exception IllegalArgumentException ifindex
<0
Checks whether the border should be painted. @return true if the border is painted false otherwise @see #setBorderPaintedClass JPopupMenu, boolean isLightWeightPopupEnabled()
Returns true ifClass JPopupMenu, boolean isVisible()lightweightlight weight (all-Java) popups are in use or false ifheavyweightheavy weight (native peer) popups are being used. @return true iflightweightlight weight popups are in use false otherwise
Returns true if theClass JPopupMenu, void pack()popupmenupopup menu is visible (currently being displayed).
Class JPopupMenu, void paintBorder(Graphics)LayoutLays out the container so that it uses the minimum space needed to display its contents.
Class JPopupMenu, String paramString()PaintPaints the popup menu's border ifBorderPainted
property is true. @param g theGraphics
object @see JComponent#paint @see JComponent#setBorder
Returns a string representation of thisClass JPopupMenu, void remove(int)JPopupMenu
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJPopupMenu
.
Removes the component at the specified index from this popup menu. @paramClass JPopupMenu, void removePopupMenuListener(PopupMenuListener)indexpos the position of the item to be removed.@exception IllegalArgumentException if the value of<0 or if the value of
indexpospos
islessgreater than0.the number of items
Class JPopupMenu, void setDefaultLightWeightPopupEnabled(boolean)RemoveRemoves aPopupMenu
listener. @param l thePopupMenuListener
to remove
Class JPopupMenu, void setInvoker(Component)SetSets the default value for thelightWeightPopupEnabled
property. Lightweight popup windows are more efficient than heavy weight windows but light weight and heavy weight components do not mix well in a GUI and in that situation a heavy weight may be required. @param aFlag true if the popup is to be light weight otherwise false @see #getDefaultLightWeightPopupEnabled
Sets the invoker of thisClass JPopupMenu, void setLabel(String)popupmenupopup menu -- the component in which thepopupmenupopup menu menu is to be displayed. @param invoker theComponent
in which the popup menu is displayed @beaninfo description: The invoking component for the popup menu expert: true
Sets the popup menu's label. DifferentClass JPopupMenu, void setLightWeightPopupEnabled(boolean)Looklook andFeelsfeels may choose to display or not display this. @param label aStringstring specifying the label for the popup menu @see #setLabel @beaninfo description: The label for the popup menu. bound: true
When displaying the popupClass JPopupMenu, void setLocation(int, int)JPopupMenu
choosechooses to use a light weight popup if it fits. This method allows you to disable this feature. You have to do disable it if your application mixes light weight and heavy weights components. @param aFlag true if the popup is to be light weight otherwise false @beaninfo description: Determines whether lightweight popups are used when possible expert: true
Class JPopupMenu, void setPopupSize(Dimension)SetSets the location of the upper left corner of the popup menu using x y coordinates. @param x the x coordinate of the popup's new position @param y the y coordinate of the popup's new position @beaninfo description: The location of the popup menu.
Sets the size of the Popup window using aClass JPopupMenu, void setPopupSize(int, int)Dimension
object.@paramThis is equivalent tosetPreferredSize(d)
.The@param d thedimensionDimension
specifying the new size of this component. @beaninfo description: The size of the popup menu
Sets the size of the Popup window to the specified width and height. This is equivalent toClass JPopupMenu, void setSelected(Component)setPreferredSize(new Dimension(width height))
. @paramwidth
Thethe new width of the Popup in pixels.@paramheight
Thethe new height of the Popup in pixels.@beaninfo description: The size of the popup menu
Sets the currently selected component This will result in a change to the selection model. @param sel the Component
to select @beaninfo description: The selected component on the popup menu expert: true hidden: true
Class JPopupMenu, void setSelectionModel(SingleSelectionModel)Class JPopupMenu, void setUI(PopupMenuUI)SetSets the model object to handle single selections. @param model theSingleSelectionModel tonewuseSingleSelectionModel
@see SingleSelectionModel @beaninfo description: The selection model for the popup menu expert: true
Sets the L&F object that renders this component. @param ui the newClass JPopupMenu, void setVisible(boolean)PopupMenuUI
L&F object @see UIDefaults#getUI @beaninfodescriptionbound:The popup menu UI delegatetrueboundhidden: trueexpertattribute: visualUpdate truehiddendescription:trueThe UI object that implements the Component's LookAndFeel.
Class JPopupMenu, void show(Component, int, int)SetSets the visibility of the popup menu. @param b true to make the popup visible or false to hide it @beaninfo bound: true description: Makes the popup visible
Class JPopupMenu, void updateUI()DisplayDisplays thepopupmenupopup menu at the position x y in the coordinate space of the component invoker. @param invokerThethe component in whose space thepopupmenupopup menu is to appear @param x the x coordinate in invoker's coordinate space at which the popup menu is to be displayed @param y the y coordinate in invoker's coordinate space at which the popup menu is to be displayed
NotificationResetsfrom the UIFactory thattheL&F has changed.UICalledproperty toreplace theaUI withvalue from thelatest versioncurrentfrom the UIFactorylook and feel. @see JComponent#updateUI
A component that displays an integer value within a bounded interval. A progress bar typically communicates the progress of an event by displaying its percentage of completion and possibly a textual display of this percentage.For further documentation and examples see How to Monitor Progress a section in The Java Tutorial.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A component that displays an integer value. @version 1.
71 0976 03/0114/9800 @author Michael C. Albers
Class JProgressBar.AccessibleJProgressBar, AccessibleValue getAccessibleValue()TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJProgressBar
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to progress bar user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Get the AccessibleValue associated with this object.if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleValue interface on behalf of itself. @return this object
GetGets the AccessibleContext associated with thisJComponentJProgressBar. For progress bars the AccessibleContext takes the form of an AccessibleJProgressBar. A new AccessibleJProgressBar instance is created if necessary. @return an AccessibleJProgressBar that serves as the AccessibleContext of thisJComponentJProgressBar @beaninfo expert: true description: The AccessibleContext associated with this ProgressBar.
An implementation of a radio button -- an item that can be selected or deselected and which displays its state to the user. Used with a ButtonGroup object to create a group of buttons in which only one button at a time can be selected. (Create a ButtonGroup object and use itsadd
method to include the JRadioButton objects in the group.)Note: The ButtonGroup object is a logical grouping -- not a physical grouping. Tocreate a button panel you should still create a JPanel or similar container-object and add a javax.swing.border.Border to it to set it off from surrounding components.See How to Use Buttons Check Boxes and Radio Buttons in The Java Tutorial for further documentation.
For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JRadioButton key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A component which can display it's state as selected or deselected. @see ButtonGroup @see JCheckBox @version 1.
52 0963 03/0114/9800 @author Jeff Dinkins
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJRadioButton
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to radio button user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
GetGets the AccessibleContext associated with thisJComponentJRadioButton. For JRadioButtons the AccessibleContext takes the form of an AccessibleJRadioButton. A new AccessibleJRadioButton instance is created if necessary. @return an AccessibleJRadioButton that serves as the AccessibleContext of thisJComponentJRadioButton @beaninfo expert: true description: The AccessibleContext associated with this Button
An implementation of aRadioButtonMenuItemradio button menu item. ARadioButtonMenuItemJRadioButtonMenuItem
is a menu item that is part of a group of menu items in which only one item in the group can be selected. The selected item displays its selected state. Selecting it causes any other selected item to switch to the unselected state.Used withToacontrolButtonGrouptheobject to createselected state of a group ofmenu items in whichradioonly one item atbutton menu items use atime can beButtonGroup
selectedobject.(Create
a ButtonGroup objectFor further documentation anduse itsexamplesaddseemethodHow toincludeUsetheMenusJRadioButtonMenuItem objectsa section intheThegroup.)Java Tutorial. For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JRadioButtonMenuItem key assignments.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A component within a group of menu items which can be selected. @version 1.
33 1141 03/0214/9800 @author Georges Saab @author David Karlton @see ButtonGroup
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJRadioButtonMenuItem
class.role forIt providesthisan implementation of the Java Accessibility API appropriate toJRadioButtonMenuItem
user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Creates a JRadioButtonMenuItem
with no set text or icon.
Class JRadioButtonMenuItem, constructor JRadioButtonMenuItem(Icon)Creates aClass JRadioButtonMenuItem, constructor JRadioButtonMenuItem(String)JRadioButtonMenuItem
with an icon. @param icon theIcon
to display on theRadioButtonMenuItem.JRadioButtonMenuItem
Creates aClass JRadioButtonMenuItem, constructor JRadioButtonMenuItem(String, Icon)JRadioButtonMenuItem
with text. @param text the text of theRadioButtonMenuItem.JRadioButtonMenuItem
Creates aClass JRadioButtonMenuItem, constructor JRadioButtonMenuItem(String, Icon, boolean)JRadioButtonMenuItemradio button menu item with the specified text andIcon
. @param text the text of theRadioButtonMenuItemJRadioButtonMenuItem
@param icon the icon to display on theRadioButtonMenuItemJRadioButtonMenuItem
Creates a radio button menu item that has the specified text image and selection state. All other constructors defer to this one. @param text the string displayed on the radio button @param icon the image that the button should displayClass JRadioButtonMenuItem, constructor JRadioButtonMenuItem(String, boolean)
Creates aClass JRadioButtonMenuItem, AccessibleContext getAccessibleContext()radiobuttonradio button menu item with the specified text and selection state. @param text the text of theCheckBoxMenuItem
@param.bselected the selected state of thecheckboxmenuitemCheckBoxMenuItem
Class JRadioButtonMenuItem, String getUIClassID()GetGets the AccessibleContext associated with thisJComponentJRadioButtonMenuItem. For JRadioButtonMenuItems the AccessibleContext takes the form of an AccessibleJRadioButtonMenuItem. A new AccessibleJRadioButtonMenuItem instance is created if necessary. @return an AccessibleJRadioButtonMenuItem that serves as the AccessibleContext of thisJComponentJRadioButtonMenuItem
Returns the name of the L&F class that renders this component. @return the string "RadioButtonMenuItemUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JRadioButtonMenuItem, String paramString()
Returns a string representation of thisClass JRadioButtonMenuItem, void requestFocus()JRadioButtonMenuItem
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJRadioButtonMenuItem
.
OverrideOverridesComponent.requestFocus
to not grab focus.()
The fundamental component inAthelightweight containerhierarchy. In the same way that JComponent is fundamentalusedtobehind theJFC/Swing components JRootPane is fundamentalscenesto theby JFrameJFC/SwingJDialogwindow frameJWindow JApplet andpane containersJInternalFrame.However while other classes use inheritance toFortaketask-orientedadvantage ofinformation onJComponent'sfunctionalitycapabilities the container classes delegateprovided by root panes seeoperationsHow toa JRootPane instance.UseThose containersRootarePanesthe heavyweighta sectioncontainers:inJFrameTheJDialogJavaJWindowTutorial.and JApplet as well asThe following image shows the
lightweight container JInternalFrame.relationshipsThe following image shows thesebetween the classes that use rootrelationships:panes.The "heavyweight" components (those that delegate to a peer or native component on the host system) are shown with a darker heavier box. The four heavyweight JFC/Swing containers (JFrame JDialog JWindow and JApplet) are shown in relation to the AWT classes they extend. These four components are the only heavyweight containers in the Swing library. The lightweight container JInternalPane is also shown. All 5 of these JFC/Swing containers implement the RootPaneContainer interface and they all delegate their operations to a JRootPane (shown with a little "handle" on top).
Note: The JComponent methodgetRootPane
can be used to obtain the JRootPane that contains a given component.The diagram at right shows the structure of a JRootPane. A JRootpane is made up of a glassPane an optional menuBar and a contentPane. (The JLayeredPane manages the menuBar and the contentPane.) The glassPane sits over the top of everything where it is in a position to intercept mouse movements. Since the glassPane (like the contentPane) can be an arbitrary component it is also possible to set up the glassPane for drawing. Lines and images on the glassPane can then range over the frames underneath without being limited by their boundaries.
![]()
Although the menuBar component is optional the layeredPane contentPane and glassPane always exist. Attempting to set them to null generates an exception.
The
contentPane
must be the parent of any children of the JRootPane. Rather than adding directly to a JRootPane like this:rootPane.add(child);You instead add to the contentPane of the JRootPane like this:rootPane.getContentPane().add(child);The same priniciple holds true for setting layout managers removing components listing children etc. All these methods are invoked on thecontentPane
instead of on the JRootPane.Note: The default layout manager for theIf a JMenuBar component is set on the JRootPane it is positioned along the upper edge of the frame. ThecontentPane
is a BorderLayout manager. However the JRootPane uses a custom LayoutManager. So when you want to change the layout manager for the components you added to a JRootPane be sure to use code like this:rootPane.getContentPane().setLayout(new BoxLayout());contentPane
is adjusted in location and size to fill the remaining area. (The JMenuBar and thecontentPane
are added to thelayeredPane
component at the JLayeredPane.FRAME_CONTENT_LAYER layer.)The
layeredPane
is the parent of all children in the JRootPane. It is an instance of JLayeredPane which provides the ability to add components at several layers. This capability is very useful when working with menu popups dialog boxes and dragging -- situations in which you need to place a component on top of all other components in the pane.The
glassPane
sits on top of all other components in the JRootPane. That provides a convenient place to draw above all other components and makes it possible to intercept mouse events which is useful both for dragging and for drawing. Developers can usesetVisible
on the glassPane to control when theglassPane
displays over the other children. By default theglassPane
is not visible.The custom LayoutManager used by JRootPane ensures that:
Any other views in the JRootPane view hierarchy are ignored.
- The
glassPane
if present fills the entire viewable area of the JRootPane (bounds - insets).- The
layeredPane
fills the entire viewable area of the JRootPane. (bounds - insets)- The
menuBar
is positioned at the upper edge of the layeredPane().- The
contentPane
fills the entire viewable area minus the MenuBar if present.If you replace the LayoutManager of the JRootPane you are responsible for managing all of these views. So ordinarily you will want to be sure that you change the layout manager for the
contentPane
rather than for the JRootPane itselfWarning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JLayeredPane @see JMenuBar @see JWindow @see JFrame @see JDialog @see JApplet @see JInternalFrame @see JComponent @see BoxLayout @see Mixing Heavy and Light Components @version 1.
47 0465 03/2214/9900 @author David Kloba
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJRootPane
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to root pane user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Class JRootPane, String getUIClassID()GetGets the AccessibleContext associated with thisJComponentJRootPane. For root panes the AccessibleContext takes the form of an AccessibleJRootPane. A new AccessibleJRootPane instance is created if necessary. @return an AccessibleJRootPane that serves as the AccessibleContext of thisJComponentJRootPane
Class JRootPane, boolean isOptimizedDrawingEnabled()ReturnReturnsthe UIDefaults key usedato look upstring that specifies the name of theswing.plaf.ComponentUIl&f class thatdefines the look and feelrendersforthis component.Most applications will never need to call this method. Subclasses of JComponent that support pluggable look and feel should override this method to return a UIDefaults key that maps to the ComponentUI subclass that defines their look and feel.@returnThe UIDefaults key forStringa"RootPaneUI"ComponentUI@seesubclass.JComponent#getUIClassID @see UIDefaults#getUI@beaninfo expert: true description: UIClassID
Class JRootPane, void removeNotify()Returns true if this component tiles its childrenThe GlassPane and ContentPane have the same boundsi.e.whichif it can guarantee that themeans JRootPane does not tiles its childrenwillandnotthisoverlapshould return false.TheOn therepainting systemother hand the GlassPane issubstantiallynormally notmore efficient invisible and so thiscommoncancase.return trueJComponent subclasses that canif the GlassPane isn'tmakevisible. Thereforethis guaranteethe returne.g.valueJLayeredPane should override this method to return falsehere depends upon the visiblity of the GlassPane. @return true if thiscomponentscomponent's children don't overlap
Unregister ourselves from SystemEventQueueUtils. @see #addNotifyClass JRootPane, void setDefaultButton(JButton)
Sets the current default button for thisClass JRootPane, void updateUI()JRootPane
. The default button is the button which will be activated when a UI-defined activation event (typically the Enter key) occurs in the RootPane regardless of whether or not the button has keyboard focus (unless there is another component within the RootPane which consumes the activation event such as a JTextPane). For default activation to work the button must be an enabled descendent of the RootPane when activation occurs. To remove a default button from this RootPane set this property tonull
. @see JButton#isDefaultButton @param default the JButton which is to be the default button
Class JRootPane, DefaultAction defaultPressActionResetsNotificationthe UI property to a valuefrom thecurrent look and feel. JComponent subclasses must override this method likeUIFactorythis:thatpublic voidtheupdateUI()L&F{hassetUI((SliderUI)UIManagerchanged.getUI(this); } @see#setUI @see UIManager#getLookAndFeel@seeUIManagerJComponent#getUIupdateUI
Class JRootPane, DefaultAction defaultReleaseActionThe action to take whenAs of Java 2 platformthev1.3defaultButtonthis unusable field ispressedno longer used. To override the default button you should replace the Action in the JRootPane's ActionMap. Please refer to the key bindings specification for further details. @deprecated As of Java 2 platform v1.3. @see #defaultButton
The action to take whenAs of Java 2 platformthev1.3defaultButtonthis unusable field isreleasedno longer used. To override the default button you should replace the Action in the JRootPane's ActionMap. Please refer to the key bindings specification for further details. @deprecated As of Java 2 platform v1.3. @see #defaultButton
An implementation of a scrollbar. The user positions the knob in the scrollbar to determine the contents of the viewing area. The program typically adjusts the display so that the end of the scrollbar represents the end of the displayable contents or 100% of the contents. The start of the scrollbar is the beginning of the displayable contents or 0%. The postion of the knob within those bounds then translates to the corresponding percentage of the displayable contents.Typically as the position of the knob in the scrollbar changes a corresponding change is made to the position of the JViewport on the underlying view changing the contents of the JViewport.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JScrollPane @beaninfo attribute: isContainer false description: A component that helps determine the visible content range of an area. @version 1.
60 0464 03/2214/9900 @author David Kloba
Class JScrollBar.AccessibleJScrollBar, AccessibleValue getAccessibleValue()TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJScrollBar
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to scroll bar user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Get the AccessibleValue associated with this object.if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleValue interface on behalf of itself. @return this object
Class JScrollBar, boolean isFocusTraversable()GetGets the AccessibleContext associated with thisJComponentJScrollBar. For JScrollBar the AccessibleContext takes the form of an AccessibleJScrollBar. A new AccessibleJScrollBar instance is created if necessary. @return an AccessibleJScrollBar that serves as the AccessibleContext of thisJComponentJScrollBar
Identifies whether or not this component can receive the focus.A disabled button forThis returns false asexampleJScrollBar'swould returndo notfalsewant to participate in focus traversal. @return true if this component can receive the focus
A specialized containerProvides a scrollablethatview of a component. AJScrollPane
manages a viewport optional vertical and horizontalscrollbarsscroll bars and optional row and column heading viewports. You can find task-oriented documentation ofJScrollPane
in How to Use Scroll Panes a section in The Java Tutorial.
The
![]()
JViewport
provides a window or "viewport" onto a data source -- for example a text file. That data source is the "scrollable client" (aka data model) displayed by theJViewport
view. AJScrollPane
basically consists ofJScrollBarsJScrollBar
s aJViewport
and the wiring between them as shown in the diagram at right.In addition to the scroll bars and viewport a
JScrollPane
can have a column header and a row header. Each of these is aJViewport
object that you specify withsetRowHeaderView
andsetColumnHeaderView
. The column header viewport automatically scrolls left and right tracking the left-right scrolling of the main viewport. (It never scrolls vertically however.) The row header acts in a similar fashion.By default the corners are empty. You can put a component into a corner using
setCorner
in case you there is some function or decoration you would like to add to the scroll pane. The size of corner components is entirely determined by the size of the headers and scroll bars that surround them.To add a border around the main viewport you can use
setViewportBorder
. (Of course you can also add a border around the whole scroll pane usingsetBorder
.)For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JScrollPane key assignments.
A common operation to want to do is to set the background color that will be used if the main viewport view is smaller than the viewport or is not opaque. This can be accomplished by setting the background color of the viewport via
scrollPane.getViewport().setBackground()
. The reason for setting the color of the viewport and not the scrollpane is that by defaultJViewport
is opaque which among other things means it will completely fill in its background using its background color. Therefore whenJScrollPane
draws its background the viewport will usually draw over it.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JScrollBar @see JViewport @see #setViewportView @see #setRowHeaderView @see #setColumnHeaderView @see #setCorner @see #setViewportBorder @beaninfo attribute: isContainer true attribute: containerDelegate getViewport description: A specialized container that manages a viewport optional scrollbars and headers @version 1.
61 0474 03/2214/9900 @author Hans Muller
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJScrollPane
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to scroll pane user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
By defaultClass JScrollPane.ScrollBar, constructor JScrollPane.ScrollBar(JScrollPane, int)JScrollPane
creates scrollbars that are instances of this class.Scrollbar
overrides thegetUnitIncrement
andgetBlockIncrement
methods so that if theviewportsviewport's view is aScrollable
the view is asked to compute these values. Unless the unit/block increment have been explicitly set.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see Scrollable @see JScrollPane#createVerticalScrollBar @see JScrollPane#createHorizontalScrollBar
Class JScrollPane.ScrollBar, int getBlockIncrement(int)CreateCreates a scrollbar with the specified orientation where the options are:@param orientation an
- JScrollPane.VERTICAL
_SCROLLBAR- JScrollPane.HORIZONTAL
_SCROLLBARintinteger specifying one of the legal orientation values shown above
Class JScrollPane.ScrollBar, int getUnitIncrement(int)IfComputes theviewports view isblocka Scrollable then askincrement for scrolling if theviewviewport'sto compute theview is ablockScrollable
incrementobject. Otherwise theblockIncrement
equals theviewportsviewport's width or height. If there's no viewportreuurnreturnsuper.getBlockIncrement
. @param direction less than zero to scroll up/left greater than zero for down/right @return an integer in pixels containing the block increment @see Scrollable#getScrollableBlockIncrement()
Class JScrollPane.ScrollBar, void setBlockIncrement(int)IfComputes theviewports view isunita Scrollable then askincrement for scrolling if theviewviewport'sto compute theview is aunitScrollable
incrementobject. Otherwise returnsuper.getUnitIncrement
. @param direction less than zero to scroll up/left greater than zero for down/right @return an integer in pixels containing the unit increment @see Scrollable#getScrollableUnitIncrement()
Messages super to set the value and resets the blockIncrementSet
instance variable to true. @param blockIncrement the new block increment value in pixels
Class JScrollPane.ScrollBar, void setUnitIncrement(int)Messages super to set the value and resets the unitIncrementSet
instance variable to true. @param unitIncrement the new unit increment value in pixels
Class JScrollPane, constructor JScrollPane(Component)CreateCreates an empty (no viewport view)JScrollPane
where both horizontal and vertical scrollbars appear when needed.
Class JScrollPane, constructor JScrollPane(Component, int, int)CreateCreates aJScrollPane
that displays the contents of the specified component where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view. @see #setViewportView @param view theComponentcomponent to display in thescrollpanesscrollpane's viewport
Class JScrollPane, constructor JScrollPane(int, int)CreateCreates aJScrollPane
that displays the view component in a viewport whose view position can be controlled with a pair of scrollbars. The scrollbar policies specify when the scrollbars are displayede.g.For example ifvsbPolicy
isVERTICAL_SCROLLBAR_AS_NEEDED
then the vertical scrollbar only appears if the view doesn't fit vertically. The availablepoliciespolicy settings are listed at #setVerticalScrollBarPolicy and #setHorizontalScrollBarPolicy @see #setViewportView @param view theComponentcomponent to display in the scrollpanes viewport @param vsbPolicy anintinteger that specifies the vertical scrollbar policy @param hsbPolicy anintinteger that specifies the horizontal scrollbar policy
Class JScrollPane, JScrollBar createHorizontalScrollBar()CreateCreates an empty (no viewport view)JScrollPane
with specified scrollbar policies. The availablepoliciespolicy settings are listed at #setVerticalScrollBarPolicy and #setHorizontalScrollBarPolicy @see #setViewportView @param vsbPolicy anintinteger that specifies the vertical scrollbar policy @param hsbPolicy anintinteger that specifies the horizontal scrollbar policy
Class JScrollPane, JScrollBar createVerticalScrollBar()Used by ScrollPaneUI implementations to create the horizontal scrollbar.Returns aJScrollPane.ScrollBar
by default. Subclasses may override this method to forceScrollPaneUI
implementations to use aJScrollBar
subclass. Used byScrollPaneUI
implementations to create the horizontal scrollbar. @return aJScrollBar
with a horizontal orientation @see JScrollBar
Class JScrollPane, JViewport createViewport()Used by ScrollPaneUI implementations to create the vertical scrollbar.Returns aJScrollPane.ScrollBar
by default. Subclasses may override this method to forceScrollPaneUI
implementations to use aJScrollBar
subclass. Used byScrollPaneUI
implementations to create the vertical scrollbar. @return aJScrollBar
with a vertical orientation @see JScrollBar
Returns a newClass JScrollPane, AccessibleContext getAccessibleContext()JViewport
by default. Used to create the viewport (as needed) insetViewportView
setRowHeaderView
andsetColumnHeaderView
. Subclasses may override this method to return a subclass ofJViewport
. @return a newJViewport
Class JScrollPane, JViewport getColumnHeader()GetGets the AccessibleContext associated with thisJComponentJScrollPane. For scroll panes the AccessibleContext takes the form of an AccessibleJScrollPane. A new AccessibleJScrollPane instance is created if necessary. @return an AccessibleJScrollPane that serves as the AccessibleContext of thisJComponentJScrollPane
Returns the column header. @returnClass JScrollPane, Component getCorner(String)a JViewport object forthecolumncolumnHeader
headerproperty @see #setColumnHeader
Returns the component at the specified corner. TheClass JScrollPane, JScrollBar getHorizontalScrollBar()key
value specifying the corner is one of:@
- JScrollPane.LOWER_LEFT_CORNER
- JScrollPane.LOWER_RIGHT_CORNER
- JScrollPane.UPPER_LEFT_CORNER
- JScrollPane.UPPER_RIGHT_CORNER
- JScrollPane.LOWER_LEADING_CORNER
- JScrollPane.LOWER_TRAILING_CORNER
- JScrollPane.UPPER_LEADING_CORNER
- JScrollPane.UPPER_TRAILING_CORNER
seeparam#setCornerkey one of the values as shown above @return one of theComponent at the specifiedcomponents listed below orcornernull
ifkey
is invalid:@see #setCorner
- lowerLeft
- lowerRight
- upperLeft
- upperRight
Returns the horizontal scroll barClass JScrollPane, int getHorizontalScrollBarPolicy(). @returnthe scrollbarthat controls theviewportsviewport's horizontal view position. @return thehorizontalScrollBar
property @see #setHorizontalScrollBar
Returns the horizontal scroll bar policy value. @return theClass JScrollPane, JViewport getRowHeader()horizontal scrollbarhorizontalScrollBarPolicy
policy.property @see #setHorizontalScrollBarPolicy
Returns the row header. @return theClass JScrollPane, ScrollPaneUI getUI()JViewportrowHeader
forpropertythe row header@see #setRowHeader
Returns the look and feel (L&F) object that renders this component. @return the ScrollPaneUI
object that renders this component @see #setUI
Class JScrollPane, String getUIClassID()Returns theClass JScrollPane, JScrollBar getVerticalScrollBar()keysuffix used tolookconstructuptheScrollPaneUI class thatname of theprovidesL&Fthe look and feel for JScrollPaneclass used to render this component. @return the string "ScrollPaneUI" @see JComponent#getUIClassID @see UIDefaults#getUI @beaninfo hidden: true
Returns the vertical scroll barClass JScrollPane, int getVerticalScrollBarPolicy(). @returnthe scrollbarthat controls the viewports vertical view position. @return theverticalScrollBar
property @see #setVerticalScrollBar
Returns the vertical scroll bar policy value. @return theClass JScrollPane, JViewport getViewport()vertical scrollbarverticalScrollBarPolicy
policyproperty @see #setVerticalScrollBarPolicy
Returns the currentClass JScrollPane, Border getViewportBorder()JViewport
. @see #setViewport @return theJViewport currently inviewport
useproperty
Returns theClass JScrollPane, Rectangle getViewportBorderBounds()valueBorder
of the viewportBorderobject that surroundspropertythe viewport. @return theBorder object that surrounds theviewportBorder
viewportproperty @see #setViewportBorder
Returns the bounds of the viewport's border. @return a Rectangle
object specifying the viewport border
Class JScrollPane, boolean isOpaque()Returns true if this component is completely opaque.Class JScrollPane, boolean isValidateRoot()An opaque component
paints every pixelinwithin itsrangerectangular bounds.(InA non-opaque component paints only a subset of its pixels or none atother wordsall allowing the pixels underneath it to "show through". Therefore a component that does nothavefully paint its pixels provides atransparentdegree ofbackgroundtransparency.orSubclasses that guarantee to always completely paint
foregroundtheir contents should override this method and return true.)@returnThe value of the opaquetrue if this component ispropertycompletely opaque @seeJComponent#isOpaquesetOpaque
CallsClass JScrollPane, String paramString()torevalidate
on any descendant of this()JScrollPane
.eg.For example theviewportsviewport's view will cause a request to be queued that will validate theJScrollPane
and all its descendants. @return true @see JComponent#revalidate @beaninfo hidden: true
Returns a string representation of thisClass JScrollPane, void setColumnHeader(JViewport)JScrollPane
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJScrollPane
.
Class JScrollPane, void setColumnHeaderView(Component)If anRemoves the old columnHeaderexists removeif it exists. If the new columnHeader isn'tnull
sync the x coordinate of the its viewPosition with the viewport (if there is one) and then add it to theScrollPanescrollpane.Most applications will find it more convenient to use
setRowHeaderView
to add a row header component and its viewport to the scrollpane. @see #getColumnHeader @see #setColumnHeaderView @beaninfo bound: true description: The column header child for this scrollpane attribute: visualUpdate true
Creates a column-header viewport ifClass JScrollPane, void setComponentOrientation(ComponentOrientation)neccessarynecessary sets its view and then adds the column-header viewport to the scrollpane. For example:JScrollPane scrollpane = new JScrollPane(); scrollpane.setViewportView(myBigComponentToScroll); scrollpane.setColumnHeaderView(myBigComponentsColumnHeader);@see #setColumnHeader @see JViewport#setView @param view theComponentcomponent to display as the column header
Class JScrollPane, void setCorner(String, Component)SetSets thelanguage-sensitiveorientationthat is to be used to orderfor theelements or text within this component. Language-sensitiveverticalLayoutManagerandComponent subclasses will use this property tohorizontaldeterminescrollbarshow toaslay out anddetermined by thedrawComponentOrientation
componentsargument.At construction@paramtime aco onecomponent'soforientation isthe followingsetvalues:to@see java.awt.
ComponentOrientation- java.
UNKNOWN indicating that it has not been specified explicitlyawt.The UNKNOWN orientation behaves the same asComponentOrientation.LEFT_TO_RIGHT. To set the orientation of a single component use this method. To apply a ResourceBundle's orientation to anentire component hierarchy use- java.awt.
Window.applyResourceBundleComponentOrientation.@seeRIGHT_TO_LEFT- java.awt.ComponentOrientation.UNKNOWN
Window#ApplyResourceBundle(java.util.ResourceBundle) @author Laura Werner IBMComponentOrientation
Adds a child that will appear in one of the scroll panes corners if there's room. For example with both scrollbars showing (on the right and bottom edges of the scrollpane) the lower left corner component will be shown in the space between ends of the two scrollbars. Legal values for the key are:Class JScrollPane, void setHorizontalScrollBar(JScrollBar)
- JScrollPane.LOWER_LEFT_CORNER
- JScrollPane.LOWER_RIGHT_CORNER
- JScrollPane.UPPER_LEFT_CORNER
- JScrollPane.UPPER_RIGHT_CORNER
- JScrollPane.LOWER_LEADING_CORNER
- JScrollPane.LOWER_TRAILING_CORNER
- JScrollPane.UPPER_LEADING_CORNER
- JScrollPane.UPPER_TRAILING_CORNER
Although "corner"
isn'tdoesn't match any beans property signaturePropertyChange
events are generated with the property name set to the corner key. @param key identifies which corner the component will appear in @param corneranyonecomponentof the following components:@exception IllegalArgumentException if corner key is invalid
- lowerLeft
- lowerRight
- upperLeft
- upperRight
Class JScrollPane, void setHorizontalScrollBarPolicy(int)AddAdds the scrollbar that controls theviewportsviewport's horizontal view position to the scrollpane. This is usuallyunneccessaryunnecessary asJScrollPane creates horizontal and vertical scrollbars by default. @param horizontalScrollBar the horizontal scrollbar to be added @see #createHorizontalScrollBar @see #getHorizontalScrollBar @beaninfo expert: true bound: true description: The horizontal scrollbar.
Determines when the horizontal scrollbar appears in the scrollpane. The options are:Class JScrollPane, void setLayout(LayoutManager)@param policy one of the three values listed above @exception IllegalArgumentException if
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
- JScrollPane.HORIZONTAL_SCROLLBAR_NEVER
- JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS
policy
is not one of the legal values shown above @see #getHorizontalScrollBarPolicy @beaninfo preferred: true bound: true description: The scrollpane scrollbar policy enum: HORIZONTAL_SCROLLBAR_AS_NEEDED JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED HORIZONTAL_SCROLLBAR_NEVER JScrollPane.HORIZONTAL_SCROLLBAR_NEVER HORIZONTAL_SCROLLBAR_ALWAYS JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS
Sets the layout manager for thisClass JScrollPane, void setRowHeader(JViewport)JScrollPane
. This method overridessetLayout
injava.awt.Container
to ensure that onlyLayoutManagersLayoutManager
s which are subclasses ofScrollPaneLayout
can be used in aJScrollPane
. @param layout the specified layout manager @exception ClassCastException if layout is not aScrollPaneLayout
@see java.awt.Container#getLayout @see java.awt.Container#setLayout @beaninfo hidden: true
Class JScrollPane, void setRowHeaderView(Component)If anRemoves the old rowHeaderexists removeif it exists. If the new rowHeader isn'tnull
syncsyncs the y coordinate oftheits viewPosition with the viewport (if there is one) and thenaddadds it to theScrollPanescrollpane.Most applications will find it more convenient to use
setRowHeaderView
to add a row header component and its viewport to the scrollpane. @param rowHeader the new row header to be used; ifnull
the old row header is still removed and the new rowHeader is set tonull
@see #getRowHeader @see #setRowHeaderView @beaninfo bound: true expert: true description: The row header child for this scrollpane
Creates a row-header viewport ifClass JScrollPane, void setUI(ScrollPaneUI)neccessarynecessary sets its view and then adds the row-header viewport to the scrollpane. For example:JScrollPane scrollpane = new JScrollPane(); scrollpane.setViewportView(myBigComponentToScroll); scrollpane.setRowHeaderView(myBigComponentsRowHeader);@see #setRowHeader @see JViewport#setView @param view theComponentcomponent to display as the row header
Sets theClass JScrollPane, void setVerticalScrollBar(JScrollBar)ScrollPaneUI
object that provides the look and feel (L&F) for this component. @param ui theScrollPaneUI
L&F object @see #getUI
Class JScrollPane, void setVerticalScrollBarPolicy(int)AddAdds the scrollbar that controls the viewports vertical view position to the scrollpane. This is usuallyunneccessaryunnecessary asJScrollPane creates vertical and
verticalhorizontal scrollbars by default. @param verticalScrollBar the new vertical scrollbar to be added @see #createVerticalScrollBar @see #getVerticalScrollBar @beaninfo expert: true bound: true description: The vertical scrollbar.
Determines when the vertical scrollbar appears in the scrollpane. Legal values are:Class JScrollPane, void setViewport(JViewport)@param policy one of the three values listed above @exception IllegalArgumentException if
- JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
- JScrollPane.VERTICAL_SCROLLBAR_NEVER
- JScrollPane.VERTICAL_SCROLLBAR_ALWAYS
policy
is not one of the legal values shown above @see #getVerticalScrollBarPolicy @beaninfo preferred: true bound: true description: The scrollpane vertical scrollbar policy enum: VERTICAL_SCROLLBAR_AS_NEEDED JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED VERTICAL_SCROLLBAR_NEVER JScrollPane.VERTICAL_SCROLLBAR_NEVER VERTICAL_SCROLLBAR_ALWAYS JScrollPane.VERTICAL_SCROLLBAR_ALWAYS
Class JScrollPane, void setViewportBorder(Border)RemoveRemoves the old viewport (if there is one);forceforces the viewPosition of the new viewport to be in the +x +y quadrant;syncsyncs up the row and column headers (if there are any) with the new viewport; and finallysyncsyncs the scrollbars and headers with the new viewport.Most applications will find it more convenient to use
setViewportView
to add a viewport and a view to the scrollpane. @param viewport the new viewport to be used; if viewport isnull
the old viewport is still removed and the new viewport is set tonull
@see #createViewport @see #getViewport @see #setViewportView @beaninfo expert: true bound: true attribute: visualUpdate true description: The viewport child for this scrollpane
Class JScrollPane, void setViewportView(Component)AddAdds a border around the viewport. Note that the border isn't set on the viewport directlyJViewport
doesn't support theJComponent
border property. Similarly setting theJScrollPanesJScrollPane
s viewport doesn'teffectaffect theviewportBorder
property.The default value of this property is computed by the look and feel implementation. @param viewportBorder the border to be added @see #getViewportBorder @see #setViewport @beaninfo preferred: true bound: true description: The border around the viewport.
Creates a viewport ifClass JScrollPane, void updateUI()neccessarynecessary and then sets its view. Applications that don't provide the view directly to theJScrollPane
constructor should use this method to specify the scrollable child that's going to be displayed in the scrollpanee.g. For example:JScrollPane scrollpane = new JScrollPane(); scrollpane.setViewportView(myBigComponentToScroll);Applications should not add children directly to the scrollpane. @param view theComponentcomponent to add to the viewport @see #setViewport @see JViewport#setView
Class JScrollPane, JViewport columnHeaderTo be called when the default look and feel changes.Replaces the currentScrollPaneUI
object with a version from the current defaultLookAndFeellook and feel. To be called when the default look and feel changes. @see JComponent#updateUI @see UIManager#getUI
The column header child. Default is null
. @see #setColumnHeader
Class JScrollPane, JScrollBar horizontalScrollBarThe scrollpane's horizontal scrollbar child. Default is a JScrollBar
. @see #setHorizontalScrollBar
Class JScrollPane, int horizontalScrollBarPolicyThe display policy for the horizontal scrollbar. The default is JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
. @see #setHorizontalScrollBarPolicy
Class JScrollPane, Component lowerLeftThe component to display in the lower left corner. Default is null
. @see #setCorner
Class JScrollPane, Component lowerRightThe component to display in the lower right corner. Default is null
. @see #setCorner
Class JScrollPane, JViewport rowHeaderThe row header child. Default is null
. @see #setRowHeader
Class JScrollPane, Component upperLeftThe component to display in the upper left corner. Default is null
. @see #setCorner
Class JScrollPane, Component upperRightThe component to display in the upper right corner. Default is null
. @see #setCorner
Class JScrollPane, JScrollBar verticalScrollBarThe scrollpane's vertical scrollbar child. Default is a JScrollBar
. @see #setVerticalScrollBar
Class JScrollPane, int verticalScrollBarPolicyThe display policy for the vertical scrollbar. The default is JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
. @see #setVerticalScrollBarPolicy
Class JScrollPane, JViewport viewportThescrollpanesscrollpane's viewport child. Default is an emptyJViewport
. @see #setViewport
An implementation of aMenu Separatormenu separator -- a divider between menu items that breaks them up into logical groupings. Instead of usingJSeparator
directly you can use theJMenu
orJPopupMenu
addSeparator
method to create and add a separator.For more information and examples see How to Use Menus a section in The Java Tutorial.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A divider between menu items. @version 1.
34 1141 03/1914/9800 @author Georges Saab @author Jeff Shapiro
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJSeparator
class.role forIt providesthisan implementation of the Java Accessibility API appropriate to separator user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Class JSeparator, constructor JSeparator(int)CreateCreates a new horizontal separator.
Class JSeparator, AccessibleContext getAccessibleContext()CreateCreates a new separator with the specified horizontal or vertical orientation. @param orientation anintinteger specifyingSwingConstants.HORIZONTAL
orSwingConstants.VERTICAL
@exception IllegalArgumentException iforientation
is neitherSwingConstants.HORIZONTAL
norSwingConstants.VERTICAL
Class JSeparator, String getUIClassID()GetGets the AccessibleContext associated with thisJComponentJSeparator. For separators the AccessibleContext takes the form of an AccessibleJSeparator. A new AccessibleJSeparator instance is created if necessary. @return an AccessibleJSeparator that serves as the AccessibleContext of thisJComponentJSeparator
Returns the name of the L&F class that renders this component. @return the string "SeparatorUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JSeparator, boolean isFocusTraversable()
Identifies whether or not this component can receive the focus.Class JSeparator, String paramString()JSeparatorsJSeparator
s cannot recieve focus. @return false
Returns a string representation of thisClass JSeparator, void setOrientation(int)JSeparator
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJSeparator
.
Sets the orientation of the separator. The default value of this property is HORIZONTAL. @param orientation eitherClass JSeparator, void updateUI()SwingConstants.HORIZONTAL
orSwingConstants.VERTICAL
@exception IllegalArgumentException iforientation
is neitherSwingConstants.HORIZONTAL
norSwingConstants.VERTICAL
@see SwingConstants @see #getOrientation @beaninfo bound: true preferred: true enum: HORIZONTAL SwingConstants.HORIZONTAL VERTICAL SwingConstants.VERTICAL attribute: visualUpdate true description: The orientation of the separator.
Notification from theUIFactory
that the L&F has changed. Called to replace the UI with the latest version from theUIFactoryUIFactorys
. @see JComponent#updateUI
A component that lets the user graphically select a value by slding a knob within a bounded interval. The slider can show both major tick marks and minor tick marks between them. The number of values between the tick marks is controlled withsetMajorTickSpacing
andsetMinorTickSpacing
.For further information and examples see How to Use Sliders a section in The Java Tutorial. For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JSlider key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A component that supports selecting a integer value from a range. @version 1.
78 0989 03/0114/9800 @author David Kloba
Class JSlider.AccessibleJSlider, AccessibleValue getAccessibleValue()TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJSlider
class.role forIt providesthisan implementation of the Java Accessibility API appropriate to slider user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Get the AccessibleValue associated with this object.if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleValue interface on behalf of itself. @return this object
Creates a hashtable that will draw text labels starting at the slider minimum using the increment specified. If you call createStandardLabels( 10 )
and the slider minimum is zero then it will make labels for the values 0 10 20 30 and so on. @see #setLabelTable
Class JSlider, Hashtable createStandardLabels(int, int)Creates a hashtable that will draw text labels starting at the start point specified using the increment specified. If you call createStandardLabels( 10 2 )
then it will make labels for the values 2 12 22 32 and so on. @see #setLabelTable @exception IllegalArgumentException if slider label start point out of range or if label increment is less than or equal to zero
Class JSlider, AccessibleContext getAccessibleContext()Class JSlider, boolean getInverted()GetGets the AccessibleContext associated with thisJComponentJSlider. For sliders the AccessibleContext takes the form of an AccessibleJSlider. A new AccessibleJSlider instance is created if necessary. @return an AccessibleJSlider that serves as the AccessibleContext of thisJComponentJSlider
Returns true if the value-range shown for the slider is reversedClass JSlider, void setInverted(boolean)with the maximum value at the left end of a horizontal slider or at the bottom of a vertical one.@return true if the slider values are reversed from their normal order @see #setInverted
Specify true to reverse the value-range shown for the sliderClass JSlider, void setLabelTable(Dictionary)so that theand false tomaximumput the valueis atrange in theleftnormalendorder.of aThe orderhorizontaldepends on the slider'sComponentOrientation
orproperty.atNormalthe(non-inverted) horizontal slidersbottomwith aComponentOrientation
value ofLEFT_TO_RIGHT
have their maximum on the right. Normal horizontal sliders with averticalComponentOrientation
value ofoneRIGHT_TO_LEFT
have their maximum on the left.Specify false toNormal vertical slidersputhave their maximum on thevaluetop.rangeTheseinlabels are reversed when thenormalsliderorderis inverted. @param b true to reverse the slider values from their normal order @beaninfo bound: true attribute: visualUpdate true description: If true reverses the slider values from their normal order
Used to specify what label will be drawn at any given value. The key-value pairs are of this format: { Integer value java.awtswing.ComponentJComponent label }
. @see #createStandardLabels @see #getLabelTable @beaninfo hidden: true bound: true attribute: visualUpdate true description: Specifies what labels will be drawn for any given value.
Class JSlider, void setMaximum(int)Sets the models maximum property. @see #getMaximum @see BoundedRangeModel#setMaximum @beaninfo bound: true preferred: true description: The sliders maximum value.Class JSlider, void setMinimum(int)
Sets the models minimum property. @see #getMinimum @see BoundedRangeModel#setMinimum @beaninfo bound: true preferred: true description: The sliders minimum value.Class JSlider, ChangeEvent changeEvent
Only one ChangeEvent
is needed per slider instance since the event's only (read-only) state is the source property. The source of events generated here is always "this". The event is lazily created the first time that an event notification is fired. @exception IllegalArgumentException if orientation is not either HORIZONTAL or VERTICAL @see #fireStateChanged
Class JSlider, boolean snapToTicksIf true the knob (and the data value it represents) resolve to the closest tick mark next to where the user positioned the knob. The default is false. @see #setSnapToTicks
JSplitPane
is used to divide two (and only two)ComponentsComponent
s. The twoComponentsComponent
s are graphically divided based on the look and feel implementation and the twoComponentsComponent
s can then be interactively resized by the user. Information on usingJSplitPane
is in How to Use Split Panes in The Java Tutorial.The two
ComponentsComponent
s in a split pane can be aligned left to right usingJSplitPane.HORIZONTAL_SPLIT
or top to bottom usingJSplitPane.VERTICAL_SPLIT
. The preferred way to change the size of theComponentsComponent
s is to invokesetDividerLocation
wherelocation
is either the new x or y position depending on the orientation of theJSplitPane. If one component changesJSplitPane
.also attempts to reposition the other componentTo resize the
ComponentsComponent
s to their preferred sizes invokeresetToPreferredSizes
.When the user is resizing the
ComponentsComponent
s the minimum size of theComponents
is used to determine the maximum/minimum position theComponentsComponent
s can be set to.So that ifIf the minimum size of the two components is greater than the size of thesplitpanesplit pane the divider will not allow you to resize it. To alter the minimum size of aJComponent
see JComponent#setMinimumSizeWhen the user resizes the split pane the new space is distributed between the two components based on the
resizeWeight
property. A value of 0 the default indicates the right/bottom component gets all the space where as a value of 1 indicates the left/top component gets all the space.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JSplitPane key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see #setDividerLocation @see #resetToPreferredSizes @version 1.
51 0461 03/2214/9900 @author Scott Violet
Class JSplitPane.AccessibleJSplitPane, AccessibleRole getAccessibleRole()TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJSplitPane
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to split pane user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Class JSplitPane.AccessibleJSplitPane, AccessibleStateSet getAccessibleStateSet()GetGets the role of this object. @return an instance of AccessibleRole describing the role of the object @see AccessibleRole
Class JSplitPane.AccessibleJSplitPane, AccessibleValue getAccessibleValue()GetGets the state set of this object. @return an instance of AccessibleState containing the current state of the object @see AccessibleState
Get the AccessibleValue associated with this object.Class JSplitPane.AccessibleJSplitPane, Number getCurrentAccessibleValue()if oneIn theexists.implementation of the Java Accessibility APIOtherwisefor this class returnnullthis object which is responsible for implementing the AccessibleValue interface on behalf of itself. @return this object
Class JSplitPane.AccessibleJSplitPane, Number getMaximumAccessibleValue()GetGets the accessible value of this object. @return a localized String describing the value of this object
Class JSplitPane.AccessibleJSplitPane, Number getMinimumAccessibleValue()GetGets the maximum accessible value of this object. @return The maximum value of this object.
Class JSplitPane.AccessibleJSplitPane, boolean setCurrentAccessibleValue(Number)GetGets the minimum accessible value of this object. @return The minimum value of this object.
SetSets the value of this object as a Number. @return True if the value was set.
Class JSplitPane, constructor JSplitPane(int)ReturnsCreates a newJSplitPane
configured to arrange the child components side-by-side horizontally with no continuous layout using two buttons for thecompoentscomponents.
Class JSplitPane, constructor JSplitPane(int, Component, Component)ReturnsCreates a newJSplitPane
configured with the specified orientation and no continuous layout. @param newOrientationan intJSplitPane.HORIZONTAL_SPLIT
specifyingortheJSplitPane.VERTICAL_SPLIT
horizontal@exceptionor verticalIllegalArgumentException iforientation
is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT.
Class JSplitPane, constructor JSplitPane(int, boolean)ReturnsCreates a newJSplitPane
with the specified orientation and with thespecifiiedspecified components thatdoesdo not do continuous redrawing. @param newOrientationan int specifying the horizontalJSplitPane.HORIZONTAL_SPLIT
orvertical orientationJSplitPane.VERTICAL_SPLIT
@paramnewContinuousLayout a boolean true fornewLeftComponent thecomponentsComponent
to redraw continuously asthat will appear on thedividerleftchanges positionof afalsehorizontally-splitto wait untilpane or at thedivider positiontopstops changingof atovertically-splitredrawpane @paramnewLeftComponentnewRightComponent theComponent
that will appear on theleftright of a horizontally-split pane or at thetopbottom of a vertically-split pane.@exception IllegalArgumentException iforientation
is not one of: HORIZONTAL_SPLIT or VERTICAL_SPLIT
Class JSplitPane, constructor JSplitPane(int, boolean, Component, Component)ReturnsCreates a newJSplitPane
with the specified orientation and redrawing style. @param newOrientationan int specifying the horizontalJSplitPane.HORIZONTAL_SPLIT
orvertical orientationJSplitPane.VERTICAL_SPLIT
@param newContinuousLayout a boolean true for the components to redraw continuously as the divider changes position false to wait until the divider position stops changing to redraw @exception IllegalArgumentException iforientation
is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT
Class JSplitPane, void addImpl(Component, Object, int)ReturnsCreates a newJSplitPane
with the specified orientation and redrawing style and with the specified components. @param newOrientationan int specifying the horizontalJSplitPane.HORIZONTAL_SPLIT
orvertical orientationJSplitPane.VERTICAL_SPLIT
@param newContinuousLayout a boolean true for the components to redraw continuously as the divider changes position false to wait until the divider position stops changing to redraw @param newLeftComponent theComponent
that will appear on the left of a horizontally-split pane or at the top of a vertically-split pane.@param newRightComponent theComponent
that will appear on the right of a horizontally-split pane or at the bottom of a vertically-split pane @exception IllegalArgumentException iforientation
is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT
Adds the specified component to this split pane. IfClass JSplitPane, AccessibleContext getAccessibleContext()constraints
identifies the left/top or right/bottom child component and a component with that identifier was previously added it will be removed and thencomp
will be added in its place. Ifconstraints
is not one of the known identifers the layout manager may throw an IllegalArgumentException.The possible constraints objects (Strings) are:
If the
- JSplitPane.TOP
- JSplitPane.LEFT
- JSplitPane.BOTTOM
- JSplitPane.RIGHT
constraints
object isnull
the component is added in the first available position (left/top if open else right/bottom). @param comp the component to add @param constraints anObject
specifying the layout constraints (position) for this component @param index anintinteger specifying the index in the container's list. @exception IllegalArgumentExceptionthrownif theconstraints
object does not match an existing component @see java.awt.Container#addImpl(Component Object int)
Class JSplitPane, Component getBottomComponent()GetGets the AccessibleContext associated with thisJComponentJSplitPane. For split panes the AccessibleContext takes the form of an AccessibleJSplitPane. A new AccessibleJSplitPane instance is created if necessary. @return an AccessibleJSplitPane that serves as the AccessibleContext of thisJComponentJSplitPane @beaninfo expert: true description: The AccessibleContext associated with thisLabelSplitPane.
Returns the component below or to the right of the divider. @return the Component
displayed in that position
Class JSplitPane, int getDividerLocation()Returns theClass JSplitPane, int getDividerSize()location of thelast value passeddividertosetDividerLocation
. The value returned from this method may differ from thelookactual divider location (ifsetDividerLocation
was passed a value bigger thanand feelthe curentimplementationsize). @return anintinteger specifyinga UI-specific valuethe(typicallylocationa pixelof thecount)divider
Returns the size of the divider. @return anClass JSplitPane, int getLastDividerLocation()intinteger giving the size of the divider in pixels
Returns the last location the divider was at. @return anClass JSplitPane, Component getLeftComponent()intinteger specifying the last divider location as a count of pixels from the left (or upper) edge of the pane to the left (or upper) edge of the divider
Returns the component to the left (or above) the divider. @return the Component
displayed in that position @beaninfo preferred: true description: The component to the left (or above) the divider.
Class JSplitPane, int getMaximumDividerLocation()Returns the maximum location of the divider from the look and feel implementation. @return anClass JSplitPane, int getMinimumDividerLocation()intinteger specifying a UI-specific value for the maximum location (typically a pixel count); or -1 if the UI isnull
Returns the minimum location of the divider from the look and feel implementation. @return anClass JSplitPane, int getOrientation()intinteger specifying a UI-specific value for the minimum location (typically a pixel count); or -1 if the UI isnull
@beaninfo description: The minimum location of the divider from the L&F.
Returns the orientation. @return anClass JSplitPane, Component getRightComponent()intinteger giving the orientation @see #setOrientation
Returns the component to the right (or below) the divider. @return the Component
displayed in that position
Class JSplitPane, Component getTopComponent()Returns the component above or to the left of the divider. @return the Component
displayed in that position
Class JSplitPane, SplitPaneUI getUI()Returns theClass JSplitPane, String getUIClassID()SplitPaneUI
that is providing the current look and feel. @return theSplitPaneUI
object that renders this component @beaninfo expert: true description: The L&F object that renders this component.
Returns the name of the L&F class that renders this component. @return the string "SplitPaneUI" @see JComponent#getUIClassID @see UIDefaults#getUI @beaninfo expert: true description: A string that specifies the name of the L&F class.Class JSplitPane, boolean isValidateRoot()
Class JSplitPane, void paintChildren(Graphics)CallsReturns true so that calls torevalidate
on any descendant of this()JSplitPane
will cause a request to be queued that will validate theJSplitPane
and all its descendants. @return true @see JComponent#revalidate @beaninfo hidden: true
Subclassed to message the UI withClass JSplitPane, String paramString()finishedPaintingChildren
after super has been messaged as well as painting the border. @param g theGraphics
context within which to paint
Returns a string representation of thisClass JSplitPane, void remove(Component)JSplitPane
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJSplitPane
.
Removes the child componentClass JSplitPane, void remove(int)component
from the pane. Resets theleftComponent
orrightComponent
instance variable as necessary. @param component theComponent
to remove
Removes theClass JSplitPane, void removeAll()Component
at the specified index. Updates theleftComponent
andrightComponent
instance variables as necessary and then messages super. @param index anintinteger specifying the component to remove where 1 specifies the left/top component and 2 specifies the bottom/right component
Removes all the child components from theClass JSplitPane, void resetToPreferredSizes()receiversplit pane. Resets theleftComonent
andrightComponent
instance variables.
Class JSplitPane, void setBottomComponent(Component)Messaged toLays outrelayouttheJSplitPane
layout based on the preferred size of the children components. This will likely result in changing the divider location.
Sets the component below or to the right of the divider. @param comp the Component
to display in that position @beaninfo description: The component below or to the right of the divider.
Class JSplitPane, void setDividerLocation(double)Sets the divider location as a percentage of theClass JSplitPane, void setDividerLocation(int)JSplitPane
's size.This method is implemented in terms of
setDividerLocation(int)
. This method immediately changes the size of the split pane based on its current size. If the split pane is not correctly realized and on screen this method will have no effect (new divider location will become (current size * proportionalLocation) which is 0). @param proportionalLocation a double-precision floating point value that specifies a percentage from zero (top/left) to 1.0 (bottom/right) @exception IllegalArgumentException if the specified location is <0 or > 1.0 @beaninfo description: The location of the divider.
Sets the location of the divider. This is passed off to the look and feel implementation and then listeners are notified. A value less than 0 implies the divider should be reset to a value that attempts to honor the preferred size of the left/top component. After notifying the listeners the last divider location is updated via setLastDividerLocation
. @param location an int specifying a UI-specific value (typically a pixel count) @beaninfo bound: true description: The location of the divider.
Class JSplitPane, void setDividerSize(int)Sets the size of the divider. @param newSize anClass JSplitPane, void setLastDividerLocation(int)intinteger giving the size of the divider in pixels @beaninfo bound: true description: The size of the divider.
Sets the last location the divider was at toClass JSplitPane, void setLeftComponent(Component)newLastLocation
. @param newLastLocation anintinteger specifying the last divider location in pixels from the left (or upper) edge of the pane to the left (or upper) edge of the divider @beaninfo bound: true description: The last location the divider was at.
Sets the component to the left (or above) the divider. @param comp the Component
to display in that position
Class JSplitPane, void setOneTouchExpandable(boolean)Determines whether the JSplitPane
provides a UI widget on the divider to quickly expand/collapse the divider. @param newValue a boolean where true means to provide a collapse/expand widget @beaninfo bound: true description: UI widget on the divider to quickly expand/collapse the divider.
Class JSplitPane, void setOrientation(int)Sets the orientation or how the splitter is divided. The options are:Class JSplitPane, void setRightComponent(Component)@param orientation an
- JSplitPane.VERTICAL_SPLIT (above/below orientation of components)
- JSplitPane.HORIZONTAL_SPLIT (left/right orientation of components)
intinteger specifying the orientation @exception IllegalArgumentException if orientation is not one of: HORIZONTAL_SPLIT or VERTICAL_SPLIT. @beaninfo bound: true description: The orientation or how the splitter is divided. enum: HORIZONTAL_SPLIT JSplitPane.HORIZONTAL_SPLIT VERTICAL_SPLIT JSplitPane.VERTICAL_SPLIT
Sets the component to the right (or below) the divider. @param comp the Component
to display in that position @beaninfo preferred: true description: The component to the right (or below) the divider.
Class JSplitPane, void setTopComponent(Component)Sets the component above or to the left of the divider. @param comp the Component
to display in that position @beaninfo description: The component above or to the left of the divider.
Class JSplitPane, void setUI(SplitPaneUI)Sets the L&F object that renders this component. @param ui the SplitPaneUI
L&F object @see UIDefaults#getUI
Class JSplitPane, void updateUI()Notification from theClass JSplitPane, String BOTTOMUIManager
that the L&F has changed. Replaces the current UI object with the latest version from theUIManager
. @see JComponent#updateUI
Used to add aClass JSplitPane, String DIVIDERComponent
below the otherComponent
.
Used to add a Component
that will represent the divider.
Class JSplitPane, int HORIZONTAL_SPLITHorizontal split indicates theClass JSplitPane, String LEFTComponentsComponent
s are split along the x axis. Foregexample the twoComponentsComponent
s will be split one to the left of the other.
Used to add aClass JSplitPane, String RIGHTComponent
to the left of the otherComponent
.
Used to add aClass JSplitPane, String TOPComponent
to the right of the otherComponent
.
Used to add aClass JSplitPane, int VERTICAL_SPLITComponent
above the otherComponent
.
Vertical split indicates theComponentsComponent
s are split along the y axis. Foregexample the twoComponentsComponent
s will be split one on top of the other.
A componentwhichthat lets the user switch between a group of components by clicking on a tab with a given title and/or icon. For examples and information on using tabbed panes see How to Use Tabbed Panes a section in The Java Tutorial.Tabs/components are added to a
TabbedPane
object by using the addTab and insertTab methods. A tab is represented by an index corresponding to the position it was added in where the first tab has an index equal to 0 and the last tab has an index equal to the tab count minus 1.The
TabbedPane
uses aSingleSelectionModel
to represent the set of tabindecesindices and the currently selected index. If the tab count is greater than 0 then there will always be a selected index which by default will be initialized to the first tab. If the tab count is 0 then the selected index will be -1.
See How to Use Tabbed Panes in The Java Tutorial for further documentation.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JTabbedPane key assignments.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer true description: A component which provides a tab folder metaphor for displaying one component from a set of components. @version %I% %G% @author Dave Moore @author Philip Milne @author Amy Fowler @see SingleSelectionModel
Class JTabbedPane.AccessibleJTabbedPane, Accessible getAccessibleChild(int)TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJTabbedPane
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to tabbed pane user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Return the specified Accessible child of the object. @param i zero-based index of child @return the Accessible child of the object @exception IllegalArgumentException if index is out of boundsClass JTabbedPane.AccessibleJTabbedPane, AccessibleSelection getAccessibleSelection()
Get the AccessibleSelection associated with this object.if oneIn theexists.implementationOtherwise returnof thenull.Java@Accessibility API for this class return this object which is responsible for implementing the AccessibleSelectionorinterface on behalf ofnullitself. @return this object
We pass ModelChanged
events along to the listeners with the tabbedpane (instead of the model itself) as the event source.
Creates an empty TabbedPane
. The default tab placement is TOP. @see #addTab
Class JTabbedPane, constructor JTabbedPane(int)Creates an empty TabbedPane
with the specified tab placement of either: TOP BOTTOM LEFT or RIGHT. @param tabPlacement the placement for the tabs relative to the content @see #addTab
Class JTabbedPane, Component add(Component)Adds aClass JTabbedPane, void add(Component, Object)component
with a tab title defaulting to the name of the component. Cover method forinsertTab
. @param component()Thethe component to be displayed when this tab is clicked.@return the component @see #insertTab @see #removeTabAt
Adds aClass JTabbedPane, void add(Component, Object, int)component
to the tabbed pane. Ifconstraints
is aString
or anIcon
it will be used for the tab title otherwise the component's name will be used as the tab title. Cover method forinsertTab
. @param component()Thethe component to be displayed when this tab is clicked.@param constraints the object to be displayed in the tab @see #insertTab @see #removeTabAt
Adds aClass JTabbedPane, Component add(Component, int)component
at the specified tab index. Ifconstraints
is aString
or anIcon
it will be used for the tab title otherwise the component's name will be used as the tab title. Cover method forinsertTab
. @param component()Thethe component to be displayed when this tab is clicked.@constraints the object to be displayed in the tab @param index the position to insert this new tab @see #insertTab @see #removeTabAt
Adds aClass JTabbedPane, Component add(String, Component)component
at the specified tab index with a tab title defaulting to the name of the component. Cover method forinsertTab
. @param component()Thethe component to be displayed when this tab is clicked.@param index the position to insert this new tab @return the component @see #insertTab @see #removeTabAt
Adds aClass JTabbedPane, void addChangeListener(ChangeListener)component
with the specified tab title. Cover method forinsertTab
. @param title the title to be displayed in this tab @param component()Thethe component to be displayed when this tab is clicked.@return the component @see #insertTab @see #removeTabAt
Adds aClass JTabbedPane, void addTab(String, Component)ChangeListener
to this tabbedpane. @param l theChangeListener
to add @see #fireStateChanged @see #removeChangeListener
Adds aClass JTabbedPane, void addTab(String, Icon, Component)component
represented by atitle
and no icon. Cover method forinsertTab
. @param title the title to be displayed in this tab @param component The component to be displayed when this tab is clicked. @see #insertTab @see #removeTabAt()
Adds aClass JTabbedPane, void addTab(String, Icon, Component, String)component
represented by atitle
and/oricon
either of which can benull
. Cover method forinsertTab
. @param title the title to be displayed in this tab @param icon the icon to be displayed in this tab @param component()Thethe component to be displayed when this tab is clicked.@see #insertTab @see #removeTabAt
Adds aClass JTabbedPane, ChangeListener createChangeListener()component
andtip
represented by atitle
and/oricon
either of which can benull
. Cover method forinsertTab
. @param title the title to be displayed in this tab @param icon the icon to be displayed in this tab @param component The component to be displayed when this tab is clicked. @param tip the tooltip to be displayed for this tab @see #insertTab @see #removeTabAt()
Subclasses that want to handleClass JTabbedPane, void fireStateChanged()ChangeEvents
differently can override this to return a subclass ofModelListener
or anotherChangeListener
implementation. @see #fireStateChanged
Send aClass JTabbedPane, AccessibleContext getAccessibleContext()ChangeEvent
whose source is this tabbedpane to each listener. This method method is called each time aChangeEvent
is received from the model. @see #addChangeListener @see EventListenerList
Class JTabbedPane, Color getBackgroundAt(int)GetGets the AccessibleContext associated with thisJComponentJTabbedPane. For tabbed panes the AccessibleContext takes the form of an AccessibleJTabbedPane. A new AccessibleJTabbedPane instance is created if necessary. @return an AccessibleJTabbedPane that serves as the AccessibleContext of thisJComponentJTabbedPane
Returns the tab background color atClass JTabbedPane, Rectangle getBoundsAt(int)index
. @param index the index of the item being queried @return theColor
of the tab background atindex
@exception IllegalArgumentException if index is out of bounds @see #setBackgroundAt
Returns the tab bounds atClass JTabbedPane, Component getComponentAt(int)index
. If the tab at this index is not currently visible in the UI then returnsnull
. If there is no UI set on thistabbedpane
then returnsnull
. @param index the index to be queried @return aRectangle
containing the tab bounds atindex
ornull
if tab atindex
is not currently visible in the UI or if there is no UI set on thistabbedpane
Returns the component atClass JTabbedPane, Icon getDisabledIconAt(int)index
. @param index the index of the item being queried @return theComponent
atindex
@exception IllegalArgumentException if index is out of bounds @see #setComponentAt
Returns the tab disabled icon atClass JTabbedPane, Color getForegroundAt(int)index
. @param index the index of the item being queried @return the icon atindex
@exception IllegalArgumentException if index is out of bounds @see #setDisabledIconAt
Returns the tab foreground color atClass JTabbedPane, Icon getIconAt(int)index
. @param index the index of the item being queried @return theColor
of the tab foreground atindex
@exception IllegalArgumentException if index is out of bounds @see #setForegroundAt
Returns the tab icon atClass JTabbedPane, Component getSelectedComponent()index
. @param index the index of the item being queried @return the icon atindex
@exception IllegalArgumentException if index is out of bounds @see #setIconAt
Returns the currently selected component for this tabbedpane. Returns null
if there is no currently selected tab. @return the component corresponding to the selected tab @see #setSelectedComponent
Class JTabbedPane, int getTabCount()Returns the number of tabs in thisClass JTabbedPane, int getTabRunCount()tabbedpane
. @return anintinteger specifying the number of tabbed pages
Returns the number of tab runs currently used to display the tabs. @return anClass JTabbedPane, String getTitleAt(int)intinteger giving the number of rows if thetabPlacement
is TOP or BOTTOM and the number of columns iftabPlacement
is LEFT or RIGHT or 0 if there is no UI set on thistabbedpane
Returns the tab title atClass JTabbedPane, String getToolTipText(MouseEvent)index
. @param index the index of the item being queried @return the title atindex
@exception IllegalArgumentException if index is out of bounds @see #setTitleAt
Returns the tooltip text for the component determined by the mouse event location. @param event theClass JTabbedPane, String getUIClassID()MouseEvent
that tells where the cursor is lingering @return theString
withcontaining the tooltip text @exception IllegalArgumentException if index is out of bounds
Returns the name of the UI class that implements the L&F for this component. @return the string "TabbedPaneUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JTabbedPane, int indexOfComponent(Component)
Returns the index of the tab for the specified component. Returns -1 if there is no tab for this component. @param component the component for the tab @return the first tab which matches this component or -1 if there is no tab for this componentClass JTabbedPane, int indexOfTab(Icon)
Returns the first tab index with a givenClass JTabbedPane, int indexOfTab(String)icon
.Returnsor -1 if no tab has this icon. @param icon the icon for the tab @return the first tab index which matchesicon
or -1 if no tab has this icon
Returns the first tab index with a givenClass JTabbedPane, void insertTab(String, Icon, Component, String, int)title
Returnsor -1 if no tab has this title. @param title the title for the tab @return the first tab index which matchestitle
or -1 if no tab has this title
Inserts aClass JTabbedPane, boolean isEnabledAt(int)component
atindex
represented by atitle
and/oricon
either of which may benull
. Uses java.util.Vector internally seeinsertElementAt
for details of insertion conventions. @param title the title to be displayed in this tab @param icon the icon to be displayed in this tab @param component The component to be displayed when this tab is clicked. @param tip the tooltip to be displayed for this tab @param index the position to insert this new tab @see #addTab @see #removeTabAt()
Returns whether or not the tab atClass JTabbedPane, String paramString()index
is currently enabled. @param index the index of the item being queried @return true if the tab atindex
is enabled; false otherwise @exception IllegalArgumentException if index is out of bounds @see #setEnabledAt
Returns a string representation of thisClass JTabbedPane, void removeAll()JTabbedPane
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of this JTabbedPane.
Removes all the tabs and their corresponding components from the tabbedpane
. @see #addTab @see #removeTabAt
Class JTabbedPane, void removeChangeListener(ChangeListener)Removes a ChangeListener
from this tabbedpane. @param l the ChangeListener to remove @see #fireStateChanged @see #addChangeListener
Class JTabbedPane, void removeTabAt(int)Removes the tab atClass JTabbedPane, void setBackgroundAt(int, Color)index
. After the component associated withindex
is removed its visibility is reset to true to ensure it will be visible if added to other containers. @param index the index of the tab to be removed @see #addTab @see #insertTab
Sets the background color atClass JTabbedPane, void setComponentAt(int, Component)index
tobackground
which can benull
in which case the tab's background color will default to the background color of thetabbedpane
. An internal exception is raised if there is no tab at that index. @param index the tab index where the background should be set @param background the color to be displayed in the tab's background @exception IllegalArgumentException if index is out of bounds @see #getBackgroundAt @beaninfo preferred: true attribute: visualUpdate true description: The background color at the specified tab index.
Sets the component atClass JTabbedPane, void setDisabledIconAt(int, Icon)index
tocomponent
. An internal exception is raised if there is no tab at that index. @param index the tab index where this component is being placed @param component the component for the tab @exception IllegalArgumentException if index is out of bounds @see #getComponentAt @beaninfo attribute: visualUpdate true description: The component at the specified tab index.
Sets the disabled icon atClass JTabbedPane, void setEnabledAt(int, boolean)index
toicon
which can benull
. An internal exception is raised if there is no tab at that index. @param index the tab index where the disabled icon should be set @param icon the icon to be displayed in the tab when disabled @exception IllegalArgumentException if index is out of bounds @see #getDisabledIconAt @beaninfo preferred: true attribute: visualUpdate true description: The disabled icon at the specified tab index.
Sets whether or not the tab at index
is enabled. An internal exception is raised if there is no tab at that index. @param index the tab index which should be enabled/disabled @param enabled whether or not the tab should be enabled @exception IllegalArgumentException if index is out of bounds @see #isEnabledAt
Class JTabbedPane, void setForegroundAt(int, Color)Sets the foreground color atClass JTabbedPane, void setIconAt(int, Icon)index
toforeground
which can benull
in which case the tab's foreground color will default to the foreground color of thistabbedpane
. An internal exception is raised if there is no tab at that index. @param index the tab index where the foreground should be set @param foreground the color to be displayed as the tab's foreground @exception IllegalArgumentException if index is out of bounds @see #getForegroundAt @beaninfo preferred: true attribute: visualUpdate true description: The foreground color at the specified tab index.
Sets the icon atClass JTabbedPane, void setSelectedComponent(Component)index
toicon
which can benull
. An internal exception is raised if there is no tab at that index. @param index the tab index where the icon should be set @param icon the icon to be displayed in the tab @exception IllegalArgumentException if index is out of bounds @see #getIconAt @beaninfo preferred: true attribute: visualUpdate true description: The icon at the specified tab index.
Sets the selected component for this tabbedpane. This will automatically set the selectedIndex
to the index corresponding to the specified component. @exception IllegalArgumentException if component not found in tabbed pane @see #getSelectedComponent @beaninfo preferred: true description: The tabbedpane's selected component.
Class JTabbedPane, void setSelectedIndex(int)Sets the selected index for this tabbedpane. @param index the index to be selected @exception IllegalArgumentException if index is out of bounds @see #getSelectedIndex @see SingleSelectionModel#setSelectedIndex @beaninfo preferred: true description: The tabbedpane's selected tab index.Class JTabbedPane, void setTabPlacement(int)
Sets the tab placement for this tabbedpane. Possible values are:Class JTabbedPane, void setTitleAt(int, String)The default value if not set is
- SwingConstants.TOP
- SwingConstants.BOTTOM
- SwingConstants.LEFT
- SwingConstants.RIGHT
SwingConstants.TOP
. @param tabPlacement the placement for the tabs relative to the content @exception IllegalArgumentException if tab placement value isn't one of the above valid values @beaninfo preferred: true bound: true attribute: visualUpdate true enum: TOP JTabbedPane.TOP LEFT JTabbedPane.LEFT BOTTOM JTabbedPane.BOTTOM RIGHT JTabbedPane.RIGHT description: The tabbedpane's tab placement.
Sets the title atClass JTabbedPane, void updateUI()index
totitle
which can benull
. An internal exception is raised if there is no tab at that index. @param index the tab index where the title should be set @param title the title to be displayed in the tab @exception IllegalArgumentException if index is out of bounds @see #getTitleAt @beaninfo preferred: true attribute: visualUpdate true description: The title at the specified tab index.
Notification from theClass JTabbedPane, ChangeEvent changeEventUIManager
that the L&F has changed. Called to replace the UI with the latest version from the defaultUIFactory
. @see JComponent#updateUI
Only oneChangeEvent
is needed perTabPane
instance since the event's only (read-only) state is the source property. The source of events generated here is always "this".
JTable
is a user-interface component that presents data in a two-dimensional table format. See How to Use Tables in The Java Tutorial for task-oriented documentation and examples of usingJTable
.The
JTable
has many facilities that make it possible to customize its rendering and editing but provides defaults for these features so that simple tables can be set up easily. For example to set up a table with 10 rows and 10 columns of numbers:
TableModel dataModel = new AbstractTableModel() { public int getColumnCount() { return 10; } public int getRowCount() { return 10;} public Object getValueAt(int row int col) { return new Integer(row*col); } }; JTable table = new JTable(dataModel); JScrollPane scrollpane = new JScrollPane(table);Because the
JTable
is now much easier to set up with custom models theDefaultTableModel
is less useful than it was in previous releases. Instead of copying the data in an application into theDefaultTableModel
we recommend wrapping it in the methods of theTableModel
interface and passing the real data to theJTable
as above. This technique is nearly as concise as using aDefaultTableModel
and starting this way has a number of advantages over the longer term. In particular: it is a scalable techniqueis easier tocan more easily handle dynamic or editable tables and often results in much more efficient applications because the model is free to choose the internal representation that best suits the data.The "Table" directory in the examples/demo area gives a number of complete examples of
JTable
usage covering how theJTable
can be used to provide an editable view of data taken from a database and how to modify the columns in the display to use specialized renderers and editors. For example overridingAbstractTableModel
'sgetColumnClass
method to return a value of()ImageIcon.class
for a given column allows icons to be displayed while returning a value ofNumber.class
allows digits to be right-justified in the column.The
JTable
uses integers exclusively to refer to both the rows and the columns of the model that it displays. TheJTable
simply takes a tabular range of cells and usesgetValueAt(int int)
to retrieve and display the appropriate values from the model.If
getTableHeader().setReorderingAllowed(boolean)
is used to enable column reordering columns may be rearranged in theJTable
so that the view's columns appear in a different order to the columns in the model. This does not affect the implementation of the model at all: when the columns are reordered theJTable
maintains the new order of the columns internally and converts its column indices before querying the model.So when writing a
TableModel
it is not necessary to listen for column reordering events as thethemodel will be queried in its ownco-ordinatecoordinate system regardless of what is happening in the view. In the examples area there is a demonstration of a sorting algorithm making use of exactly this technique to interpose yet anotherco-ordinatecoordinate system where the order of the rows is changed rather than the order of the columns.The general rule for the
JTable
API and the APIs of all its associated classes including thethecolumn model and both the row and column selection models is: methods using integer indices for rows and columns always use theco-ordinatecoordinate system of the view. There are three exceptions to this rule:The
- All references to rows and columns in the
TableModel
interface are in theco-ordinatecoordinate system of the model.- The index
modelIndex
in theTableColumn
constructors refers to the index of the column in the model not the view.- All constructors for the
TableModelEvent
which describes changes that have taken place in a table model use theco-ordinatecoordinate system of the model.TableColumn
provides a slot for holding an identifier or "tag" for each column and theJTable
andTableColumModelTableColumnModel
both supportgetColumn(Object id)
conveniences for locating columns by their identifier. If no identifier is explicitly set theTableColumn
returns its header value (the name of the column) as a default. A different identifier which can be of any type can be set using theTableColumn
'ssetIdentifier
method. All of the()JTable
's functions operate correctly regardless of the type and uniqueness of these identifiers.The
convertColumnIndexToView
and()convertColumnIndexToModel
methods have been provided to convert between the two()co-ordinatecoordinate systems but they are rarely needed during normal use.
LikeAs for allJComponent
classes you can useJComponent#registerKeyboardActionInputMap and ActionMap to associate an Action object with a KeyStroke and execute the action under specified conditions.
See How to Use Tables in The Java Tutorial for further documentation.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see theJTable
key assignments.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A component which displays data in a two dimensional grid. @version 1.
120 04165 03/2214/9900 @author Philip Milne@author Alan Chung
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJTable
class.role forIt providesthisan implementation of the Java Accessibility API appropriate to table user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
The classClass JTable.AccessibleJTable.AccessibleJTableCell, constructor JTable.AccessibleJTable.AccessibleJTableCell(AccessibleJTable, JTable, int, int, int)usedprovidestoan implementationobtainof theAccessibleRoleJava AccessibilityforAPI appropriate toa celltable cells.
Constructs anClass JTable.AccessibleJTable.AccessibleJTableCell, AccessibleAction getAccessibleAction()AccessiblJTableHeaaderEntryAccessibleJTableHeaderEntry
Class JTable.AccessibleJTable.AccessibleJTableCell, AccessibleComponent getAccessibleComponent()GetGets the AccessibleAction associated with this object if one exists. Otherwisereturnreturns null. @return the AccessibleAction or null
Class JTable.AccessibleJTable.AccessibleJTableCell, AccessibleContext getAccessibleContext()GetGets the AccessibleComponent associated with this object if one exists. Otherwisereturnreturns null. @return the AccessibleComponent or null
Class JTable.AccessibleJTable.AccessibleJTableCell, String getAccessibleDescription()GetGets theAccessibleContext
associated with this@returncomponent. In theAccessibleContextimplementation of the Java Accessibility API for this class return this object which is its own AccessibleContext. @return thisJComponentobject
Class JTable.AccessibleJTable.AccessibleJTableCell, int getAccessibleIndexInParent()GetGets the accessible description of this object. @return the localized description of the object; null if this object does not have a description
Class JTable.AccessibleJTable.AccessibleJTableCell, String getAccessibleName()GetGets the index of this object in its accessible parent. @return the index of this object in its parent; -1 if this object does not have an accessible parent. @see #getAccessibleParent
Class JTable.AccessibleJTable.AccessibleJTableCell, Accessible getAccessibleParent()GetGets the accessible name of this object. @return the localized name of the object; null if this object does not have a name
Class JTable.AccessibleJTable.AccessibleJTableCell, AccessibleRole getAccessibleRole()GetGets the Accessible parent of this object. @return the Accessible parent of this object; null if this object does not have an Accessible parent
Class JTable.AccessibleJTable.AccessibleJTableCell, AccessibleSelection getAccessibleSelection()GetGets the role of this object. @return an instance of AccessibleRole describing the role of the object @see AccessibleRole
Class JTable.AccessibleJTable.AccessibleJTableCell, AccessibleStateSet getAccessibleStateSet()GetGets the AccessibleSelection associated with this object if one exists. Otherwisereturnreturns null. @return the AccessibleSelection or null
Class JTable.AccessibleJTable.AccessibleJTableCell, AccessibleText getAccessibleText()GetGets the state set of this object. @return an instance of AccessibleStateSet containing the current state set of the object @see AccessibleState
Class JTable.AccessibleJTable.AccessibleJTableCell, AccessibleValue getAccessibleValue()GetGets the AccessibleText associated with this object if one exists. Otherwisereturnreturns null. @return the AccessibleText or null
Class JTable.AccessibleJTable.AccessibleJTableCell, Color getBackground()GetGets the AccessibleValue associated with this object if one exists. Otherwisereturnreturns null. @return the AccessibleValue or null
Class JTable.AccessibleJTable.AccessibleJTableCell, Cursor getCursor()GetGets the background color of this object. @return the background color if supported of the object; otherwise null.
Class JTable.AccessibleJTable.AccessibleJTableCell, Font getFont()GetGets the Cursor of this object. @return the Cursor if supported of the object; otherwise null
Class JTable.AccessibleJTable.AccessibleJTableCell, FontMetrics getFontMetrics(Font)GetGets the Font of this object. @return the Font if supported for the object; otherwise null
Class JTable.AccessibleJTable.AccessibleJTableCell, Color getForeground()GetGets the FontMetrics of this object. @param f the Font @return the FontMetrics if supported the object; otherwise null @see #getFont
Class JTable.AccessibleJTable.AccessibleJTableCell, Locale getLocale()GetGets the foreground color of this object. @return the foreground color if supported of the object; otherwise null
Gets the locale of the component. If the component does not have a locale then the locale of its parent is returned. @returnClass JTable.AccessibleJTable.AccessibleJTableCell, Point getLocation()Thisthis component's locale.;Ifif this component does not have a locale the locale of its parent is returned.@exception IllegalComponentStateExceptionIfif the Component does not have its own locale and has not yet been added to a containment hierarchy such that the locale can be determined from the containing parent.@see #setLocale
Gets the location of the object relative to the parent in the form of a point specifying the object's top-left corner in the screen's coordinate space. @returnClass JTable.AccessibleJTable.AccessibleJTableCell, boolean isEnabled()Anan instance of Point representing the top-left corner of theobjectsobject's bounds in the coordinate space of the screen; null if this object or its parent are not on the screen
Class JTable.AccessibleJTable.AccessibleJTableCell, boolean isShowing()DetermineDetermines if the object is enabled. @return true if object is enabled; otherwise false
Class JTable.AccessibleJTable.AccessibleJTableCell, boolean isVisible()DetermineDetermines if the object is showing. This is determined by checking the visibility of the object and ancestors of the object. Note: this will return true even if the object is obscured by another (for example it happens to be underneath a menu that was pulled down). @return true if the object is showing; otherwise false
Class JTable.AccessibleJTable.AccessibleJTableCell, void setAccessibleDescription(String)DetermineDetermines ifthethis object is visible. Note: this means that the object intends to be visible; however it may not in fact be showing on the screen because one of the objects that this object is contained by is not visible. To determine if an object is showing on the screen use isShowing(). @return true if object is visible; otherwise false
Class JTable.AccessibleJTable.AccessibleJTableCell, void setAccessibleName(String)SetSets the accessible description of this object. @param s the new localized description of the object
Class JTable.AccessibleJTable.AccessibleJTableCell, void setBackground(Color)SetSets the localized accessible name of this object. @param s the new localized name of the object.
Class JTable.AccessibleJTable.AccessibleJTableCell, void setCursor(Cursor)SetSets the background color of this object. @param c the new Color for the background
Class JTable.AccessibleJTable.AccessibleJTableCell, void setEnabled(boolean)SetSets the Cursor of this object. @param c the new Cursor for the object
Class JTable.AccessibleJTable.AccessibleJTableCell, void setFont(Font)SetSets the enabled state of the object. @param b if true enables this object; otherwise disables it
Class JTable.AccessibleJTable.AccessibleJTableCell, void setForeground(Color)SetSets the Font of this object. @param f the new Font for the object
Class JTable.AccessibleJTable.AccessibleJTableCell, void setVisible(boolean)SetSets the foreground color of this object. @param c the new Color for the foreground
SetSets the visible state of the object. @param b if true shows this object; otherwise hides it
Class JTable.AccessibleJTable, AccessibleSelection getAccessibleSelection()GetGets the role of this object. @return an instance of AccessibleRole describing the role of the object @see AccessibleRole
Get the AccessibleSelection associated with this object.if oneIn theexists.implementationOtherwise returnof thenull.Java@Accessibility API for this class return this object which is responsible for implementing the AccessibleSelectionorinterface on behalf ofnullitself. @return this object
Constructs a defaultClass JTable, constructor JTable(Object[][], Object[])JTable
whichthat is initialized with a default data model a default column model and a default selection model. @see #createDefaultDataModel @see #createDefaultColumnModel @see #createDefaultSelectionModel
Constructs aClass JTable, constructor JTable(TableModel)JTable
to display the values in the two dimensional arrayrowData
with column namescolumnNames
.rowData
is anArrayarray of rows so the value of the cell at row 1 column 5 can be obtained with the following code:
rowData[1][5];All rows must be of the same length as
columnNames
.@param rowData
Thethe data for the new table @param columnNamesNamesnames of each column
Constructs aClass JTable, constructor JTable(TableModel, TableColumnModel)JTable
whichthat is initialized withdm
as the data model a default column model and a default selection model. @param dmThethe data model for the table @see #createDefaultColumnModel @see #createDefaultSelectionModel
Constructs aClass JTable, constructor JTable(TableModel, TableColumnModel, ListSelectionModel)JTable
whichthat is initialized withdm
as the data modelcm
as the column model and a default selection model. @param dmThethe data model for the table @param cmThethe column model for the table @see #createDefaultSelectionModel
Constructs aClass JTable, constructor JTable(Vector, Vector)JTable
whichthat is initialized withdm
as the data modelcm
as the column model andsm
as the selection model. If any of the parameters arenull
this method will initialize the table with the corresponding default model. TheautoCreateColumnsFromModel
flag is set to false ifcm
is non-null otherwise it is set to true and the column model is populated with suitableTableColumns
for the columns indm
. @param dmThethe data model for the table @param cmThethe column model for the table @param smThethe row selection model for the table @see #createDefaultDataModel @see #createDefaultColumnModel @see #createDefaultSelectionModel
Constructs aClass JTable, constructor JTable(int, int)JTable
to display the values in theVector
ofVectors
rowData
with column namescolumnNames
. TheVectors
contained inrowData
should contain the values for that row. In other words the value of the cell at row 1 column 5 can be obtained with the following code:
((Vector)rowData.elementAt(1)).elementAt(5);
All rowsEach row mustbecontainofathevalue for eachsame length ascolumn or ancolumnNamesexception will be raised.@param rowData
Thethe data for the new table @param columnNamesNamesnames of each column
Constructs aClass JTable, void addColumn(TableColumn)JTable
withnumRows
andnumColumns
of empty cells usingtheDefaultTableModel
. The columns will have names of the form "A" "B" "C" etc. @param numRowsThethe number of rows the table holds @param numColumnsThethe number of columns the table holds @see javax.swing.table.DefaultTableModel
AppendsClass JTable, void addColumnSelectionInterval(int, int)aColumn
to the end of the array of columns held bythethisJTable
's column model. If theheader valuecolumn name ofaColumn
isnull
sets theheadercolumnvaluename ofaColumn
to the name returned bygetModel().getColumnName()
.To add a column to
thethisJTable
to display themodelColumn
'th column of data in the model with a givenwidth
cellRenderer
andcellEditor
you can use:addColumn(new TableColumn(modelColumn width cellRenderer cellEditor));[AllAny of theotherTableColumn
constructorsin the TableColumncan be usedin placeinstead of this one.] The model column number is stored inside theTableColumn
and is used during rendering and editing to locate theappropriateappropriates data values in the model. The model column number does not change when columns are reordered in the view. @param aColumnThetheTableColumn to be added @see #removeColumn
Adds the columns fromClass JTable, void addNotify()index0
toindex0index1
inclusive to the current selection. @exception IllegalArgumentException ifindex0
orindex1
lie outside [0getColumnCount()
-1] @param index0 one end of the interval.@param index1 the other end of the interval
Calls the configureEnclosingScrollPane
method. @see #configureEnclosingScrollPane
Class JTable, void addRowSelectionInterval(int, int)Adds the rows fromClass JTable, void columnAdded(TableColumnModelEvent)index0
toindex0index1
inclusive to the current selection. @exception IllegalArgumentException ifindex0
orindex1
lie outside [0getRowCount()
-1] @param index0 one end of the interval.@param index1 the other end of the interval
Class JTable, int columnAtPoint(Point)Tells listenersInvoked whenthata columnwasis added to the table column model.Application code will not use these methods explicitly they are used internally by JTable. @see TableColumnModelListener
Returns the index of the column thatClass JTable, void columnMarginChanged(ChangeEvent)point
lies in or -1 ifittheliesresult is notoutsidein thereceiver'srange [0boundsgetColumnCount()
-1]. @param point the location of interest @return the index of the column thatpoint
lies in or -1 ifit lies outsidethe result is not in thereceiver'srangebounds[0getColumnCount()
-1] @see #rowAtPoint
Class JTable, void columnMoved(TableColumnModelEvent)Tells listenersInvoked whenthata columnwasis moved due to a margin change. If a cell is being edited then editing is stopped and the cell is redrawn.Application code will not use these methods explicitly they are used internally by JTable. @param e the event received
@see TableColumnModelListener
Class JTable, void columnRemoved(TableColumnModelEvent)Tells listenersInvoked whenthata columnwasis repositioned. If a cell is being edited then editing is stopped and the cell is redrawn.Application code will not use these methods explicitly they are used internally by JTable. @param e the event received
@see TableColumnModelListener
Class JTable, void columnSelectionChanged(ListSelectionEvent)Tells listenersInvoked whenthata columnwasis removed from the table column model.Application code will not use these methods explicitly they are used internally by JTable. @see TableColumnModelListener
Class JTable, void configureEnclosingScrollPane()Tells listenersInvoked whenthatthe selection model of theTableColumnModel
is changed.Application code will not use these methods explicitly they are used internally by JTable. @param e the event received @see TableColumnModelListener
IfClass JTable, int convertColumnIndexToModel(int)thethisJTable
is theviewportView
of an enclosingJScrollPane
(the usual situation) configure thisScrollPane
by amongst other things installing the table'stableHeader
as thecolumnHeaderView
of thescrollpanescroll pane. When aJTable
is added to aJScrollPane
in the usual way usingnew JScrollPane(myTable)
addNotify
is called in theJTable
(when the table is added to the viewport).JTable
'saddNotify
method in turn calls this method which is protected so that this default installation procedure can be overridden by a subclass. @see #addNotify
Class JTable, int convertColumnIndexToView(int)ReturnMaps the index of the column in themodelviewwhoseatdataviewColumnIndex
is being displayed into the index of the columnviewColumnIndexin thedisplaytable model. ReturnsviewColumnIndexthe index of the corresponding column in theunchangedmodel.whenIfviewColumnIndex is less than zero returns
viewColumnIndex
. @param viewColumnIndex the index of the column in the view @return the index of the corresponding column in the model @see #convertColumnIndexToView
Class JTable, TableColumnModel createDefaultColumnModel()ReturnMaps the index of the column in theviewtablewhichmodelisatmodelColumnIndex
displayingto thedataindexfromof the columnmodelColumnIndexin themodelview. Returns the index of the corresponding column in the view; returns -1 if this column is not being displayed.Returns modelColumnIndex unchanged whenIfmodelColumnIndex
is less than zero returnsmodelColumnIndex
. @param modelColumnIndex the index of the column in the model @return the index of the corresponding column in the view @see #convertColumnIndexToModel
Returns the default column model object which is aClass JTable, void createDefaultColumnsFromModel()DefaultTableColumnModel
.SubclassA subclass can override this method to return a different column model object. @return the default column model object @see javax.swing.table.DefaultTableColumnModel
Class JTable, TableModel createDefaultDataModel()ThisCreatesmethod will createdefault columns for the table from the data model using thegetColumnCount
() and getColumnClass()methodsmethod defined in theTableModel
interface.
This method will clearClears anyexsitingexisting columns before creating the new columns based on information from the model. @see #getAutoCreateColumnsFromModel
Returns the default table model object which is aClass JTable, void createDefaultEditors()DefaultTableModel
.SubclassA subclass can override this method to return a different table model object. @return the default table model object @see javax.swing.table.DefaultTableModel
Creates default cell editors forClass JTable, ListSelectionModel createDefaultSelectionModel()Objectsobjects numbers and boolean values. @see DefaultCellEditor
Returns the default selection model object which is aClass JTable, JTableHeader createDefaultTableHeader()DefaultListSelectionModel
.SubclassA subclass can override this method to return a different selection model object. @return the default selection model object @see javax.swing.DefaultListSelectionModel
Returns the default table header object which is aClass JTable, void doLayout()JTableHeader
.SubclassA subclass can override this method to return a different table header object. @return the default table header object @see javax.swing.table.JTableHeader
Causes thisClass JTable, boolean editCellAt(int, int)containertable to lay out itscomponents. Most programsrowsshouldandnot callcolumns.this method directly but should invoke theOverridden so that columns can be resizedvalidatetomethodaccomodateinstead.a@seechangejava.awt.LayoutManager#layoutContainerin@seethe#setLayoutsize@seeof#validatea@sincecontainingJDK1parent.1
Programmatically starts editing the cell atClass JTable, boolean editCellAt(int, int, EventObject)row
andcolumn
if the cell is editable. @param row the row to be edited @param column the column to be edited @exception IllegalArgumentException Ifrow
orcolumn
areis not in the valid range @return false if for any reason the cell cannot be edited.
Programmatically starts editing the cell atClass JTable, void editingCanceled(ChangeEvent)row
andcolumn
if the cell is editable. To prevent theJTable
from editing a particular table column or cell value return false from theisCellEditable
method in the()TableModel
interface. @param row the row to be edited @param column the column to be edited @param e event to pass into shouldSelectCell @exception IllegalArgumentException Ifrow
orcolumn
areis not in the valid range @return false if for any reason the cell cannot be edited.
Invoked when editing is canceled. The editor object is discarded and the cell is rendered once again.Class JTable, void editingStopped(ChangeEvent)Application code will not use these methods explicitly they are used internally by JTable. @param e the event received @see CellEditorListener
Invoked when editing is finished. The changes are saved and the editor is discarded.Class JTable, AccessibleContext getAccessibleContext()Application code will not use these methods explicitly they are used internally by JTable. @param e the event received @see CellEditorListener
Class JTable, boolean getAutoCreateColumnsFromModel()GetGets the AccessibleContext associated with thisJComponentJTable. For tables the AccessibleContext takes the form of an AccessibleJTable. A new AccessibleJTable instance is created if necessary. @return an AccessibleJTable that serves as the AccessibleContext of thisJComponentJTable
Class JTable, int getAutoResizeMode()ReturnsDetermines whether the table will create default columns from the model. Ifthis istruesetModel
will clear any existing columns and create new columns from the new model. Also if the event in the()thetableChanged
notification()specifiedspecifies that theentiredentire table changed then the columns will be rebuilt. The default is true. @return the autoCreateColumnsFromModel of the table @see #setAutoCreateColumnsFromModel @see #createDefaultColumnsFromModel
Returns the auto resize mode of the table. The default mode is AUTO_RESIZE_SUBSEQUENT_COLUMNS. @return the autoResizeMode of the table @see #setAutoResizeMode @see #sizeColumnsToFit(int)Class JTable, TableCellEditor getCellEditor()
Class JTable, TableCellEditor getCellEditor(int, int)ReturnReturns thecellEditorcell editor. @return theTableCellEditor
that does the editing @see #cellEditor
Class JTable, Rectangle getCellRect(int, int, boolean)ReturnReturns an appropriate editor for the cell specified bythis thisrow
andcolumn
. If theTableColumn
for this column has a non-null editorreturnreturns that. If notfindfinds the class of the data in this column (usinggetColumnClass
)()andreturnreturns the default editor for this type of data.Note: Throughout the table package the internal implementations always use this method to provide editors so that this default behavior can be safely overridden by a subclass. @param row the row of the cell to edit where 0 is the first row @param column the column of the cell to edit where 0 is the first column @return the editor for this cell; if
null
return the default editor for this type of cell @see DefaultCellEditor
Returns a rectangleClass JTable, TableCellRenderer getCellRenderer(int, int)locatingfor the cell that lies at the intersection ofrow
andcolumn
. IfincludeSpacing
is true then the value returnedincludeshas the full height and width of theintercellSpacingrow and columnmarginspecified. If it is falsethenthe returnedrectrectangle is inset byhalftheofintercellintercellSpacing.spacing(Thistoisreturn the trueframebounds of thecell)rendering@paramorrowediting component as it will be set during rendering.If the column index is valid but
the rowto computeindex is@paramlesscolumnthan zero thecolumn to computemethod returns a@paramrectangleincludeSpacing ifwith thetruethey
andheight
values set appropriately and therectx
returnedandwillwidth
valuesincludeboth set to zero. In general when either thecorrect intercellSpacingrow or@returncolumn indices indicate a cell outside the appropriate range the method returns a rectanglecontainingdepicting the closest edge of the closest cellat indexthat isrowwithincolumnthe@exceptiontable'sIllegalArgumentExceptionrange.IfWhen both roworand column indices are out of range the returned rectangle covers the closest point of the closest cell.In all cases calulations that use this method to calculate results along one axix will
not fail because of anomalies in calculations along other axis. When the cell is not validrangethe includeSpacing parameter is ignored. @param includeSpacing if false return the true cell bounds - computed by subtracting the intercell spacing from the height and widths of the column and row models. @return the rectangle containing the cell at locationrow
column
Class JTable, boolean getCellSelectionEnabled()ReturnReturns an appropriate renderer for the cell specified by thisthisrow and column. If theTableColumn
for this column has a non-null rendererreturnreturns that. If notfindfinds the class of the data in this column (usinggetColumnClass
) and()returnreturns the default renderer for this type of data.Note: Throughout the table package the internal implementations always use this method to provide renderers so that this default behavior can be safely overridden by a subclass. @param row the row of the cell to render where 0 is the first row @param column the column of the cell to render where 0 is the first column @return the assigned renderer; if
null
returns the default renderer for this type of object @see javax.swing.table.DefaultTableCellRenderer @see javax.swing.table.TableColumn#setCellRenderer @see #setDefaultRenderer
Returns true ifClass JTable, TableColumn getColumn(Object)simultaneousboth row and columnselectionsselection models areallowedenabled. Equivalent togetRowSelectionAllowed() && getColumnSelectionAllowed()
. @return true ifsimultaneousboth row and columnselectionsselection models areallowedenabled @see #setCellSelectionEnabled
Returns theClass JTable, Class getColumnClass(int)TableColumn
object for the column in the table whose identifier is equal toidentifier
when compared usingequals
. @return the()TableColumn
objectwith matchingthat matches the identifier @exception IllegalArgumentException ifidentifier
isnull
or noTableColumn
has this identifier @param identifier the identifier object
Returns the type of the columnClass JTable, int getColumnCount()at the specifiedappearing in the view at column positioncolumn
. @param column the column in the view being queried @return the type of the column at positioncolumn
in the view where the first column is column 0.
Returns the number of columns in the column model. NoteClass JTable, TableColumnModel getColumnModel()notethat this may be differenttofrom the number of columns in the table model. @return the number of columns in the table @see #getRowCount @see #removeColumn
Returns theClass JTable, String getColumnName(int)TableColumnModel
that contains all columninforamtioninformation of this table. @return the object that provides the column state of the table @see #setColumnModel
Returns the name of the columnClass JTable, boolean getColumnSelectionAllowed()at the specifiedappearing in the view at column positioncolumn
. @param column the column in the view being queried @return the name of the column at positioncolumn
in the view where the first column is column 0.
Returns true if columns can be selected. @return true if columns can be selectedClass JTable, TableCellEditor getDefaultEditor(Class).otherwise false @see #setColumnSelectionAllowed
Returns the editor to be used when no editor has been set in aClass JTable, TableCellRenderer getDefaultRenderer(Class)TableColumn
. During the editing of cells the editor is fetched from aHashtable
of entries according to the class of the cells in the column. If there is no entry for thiscolumnClass
the method returns the entry for the most specific superclass. TheJTable
installs entries forObject
Number
andBoolean
all of which can be modified or replaced. @param columnClass return the default cell editor for this columnClass @return the default cell editor to be used for this columnClass @see #setDefaultEditor @see #getColumnClass
Returns the cell renderer to be used when no renderer has been set in aClass JTable, int getEditingColumn()TableColumn
. During the rendering of cells the renderer is fetched from aHashtable
of entries according to the class of the cells in the column. If there is no entry for thiscolumnClass
the method returns the entry for the most specific superclass. TheJTable
installs entries forObject
Number
andBoolean
all of which can be modified or replaced. @param columnClass return the default cell renderer for this columnClass @return the renderer for this columnClass @see #setDefaultRenderer @see #getColumnClass
Class JTable, int getEditingRow()ThisReturnsreturnsthe index of theeditingcolumn that contains the cell currently being edited. If nothing is being edited returns -1. @return the index of the column that contains the cell currently being edited; returns -1 if nothing being edited @see #editingRow
Returns the index of theClass JTable, Component getEditorComponent()editingrow that contains the cell currently being edited. If nothing is being edited returns -1. @return the index of the row that contains the cell currently being edited; returns -1 if nothing being edited @see #editingColumn
Class JTable, Color getGridColor()IfReturns thereceiver iscomponentcurrently editing this will returnthat is handling the editingthesession.Component that was returned from the CellEditorIf nothing is being edited returns null. @return Component handling editing session
Returns the color used to draw grid lines. The default color is Color.gray
. @return the color used to draw grid lines @see #setGridColor
Class JTable, Dimension getIntercellSpacing()Returns the horizontal and verticalClass JTable, TableModel getModel()spacingspace between cells. The default spacing is (3121) which provides room to draw the grid. @return the horizontal and vertical spacing between cells @see #setIntercellSpacing
Returns theClass JTable, Dimension getPreferredScrollableViewportSize()TableModel
that provides the data displayed bythethisreceiverJTable
. @return theobjectTableModel
that provides the data displayed bythethisreceiverJTable
@see #setModel
Returns the preferred size of the viewport for this table. @return aClass JTable, int getRowCount()Dimension
object containing thepreferredSize
of theJViewport
which displays this table @see Scrollable#getPreferredScrollableViewportSize
Returns the number of rows inClass JTable, int getRowHeight()thethis table's model. @return the number of rows in this table's model @see #getColumnCount
Returns the height of a table row inClass JTable, int getRowMargin()the receiverpixels. The default row height is 16.0. @return the heightof each row in the receiverin pixels of a table row @see #setRowHeight
Gets the amount ofClass JTable, boolean getRowSelectionAllowed()emtpyempty space in pixels betweenrowscells. Equivalent to:getIntercellSpacing().height
. @return the number of pixels between cells in a row @see #setRowMargin
Returns true if rows can be selected. @return true if rows can be selected otherwise false @see #setRowSelectionAllowedClass JTable, int getScrollableBlockIncrement(Rectangle, int, int)
ReturnsClass JTable, int getScrollableUnitIncrement(Rectangle, int, int)ThevisibleRect.height
orvisibleRect.width
depending onthethis table's orientation. Note that as of Swing 1.1.1 (Java 2 v 1.2.2) the value returned will ensure that the viewport is cleanly aligned on a row boundary. @returnThevisibleRect.height
orvisibleRect.width
per the orientation.@see Scrollable#getScrollableBlockIncrement
Returns the scroll increment (in pixels) that completely exposes one new row or column (depending on the orientation).Class JTable, int getSelectedColumn()This method is called each time the user requests a unit scroll. @param visibleRect
Thethe view area visible within the viewport @param orientationEithereitherSwingConstants.VERTICAL
orSwingConstants.HORIZONTAL
@param direction.Lessless than zero to scroll up/left greater than zero for down/right.@returnThethe "unit" increment for scrolling in the specified direction @see Scrollable#getScrollableUnitIncrement
Returns the index of the first selected column -1 if no column is selected. @return the index of the first selected columnClass JTable, int[] getSelectedColumns()
Returns the indices of all selected columns. @return an array ofClass JTable, int getSelectedRow()intsintegers containing the indices of all selected columns or an empty array if no column is selected.@see #getSelectedColumn
Returns the index of the first selected row -1 if no row is selected. @return the index of the first selected rowClass JTable, int getSelectedRowCount()
Returns the number of selected rows. @return the number of selected rows 0 if noClass JTable, int[] getSelectedRows()columnsrows are selected
Returns the indices of all selected rows. @return an array ofClass JTable, Color getSelectionBackground()intsintegers containing the indices of all selected rows or an empty array if no row is selected.@see #getSelectedRow
Returns the background color for selected cells. @return the Color
used for the background of selected list items @see #setSelectionBackground @see #setSelectionForeground
Class JTable, Color getSelectionForeground()Returns the foreground color for selected cells. @return the Color
object for the foreground property @see #setSelectionForeground @see #setSelectionBackground
Class JTable, ListSelectionModel getSelectionModel()Returns theClass JTable, boolean getShowHorizontalLines()ListSelectionModel
that is used to maintain row selection state. @return the object that provides row selection state. Ornull
if row selection is not allowed.@see #setSelectionModel
Returns true if theClass JTable, boolean getShowVerticalLines()receivertable draws horizontal lines between cells false if it doesn't. The default is true. @return true if thereceivertable draws horizontal lines between cells false if it doesn't @see #setShowHorizontalLines
Returns true if theClass JTable, JTableHeader getTableHeader()receivertable draws vertical lines between cells false if it doesn't. The default is true. @return true if thereceivertable draws vertical lines between cells false if it doesn't @see #setShowVerticalLines
Returns theClass JTable, String getToolTipText(MouseEvent)tableHeader
working withused by thisJTable
. @return thetableHeader
working with the receiverused by this table @see #setTableHeader
OverridesClass JTable, TableUI getUI()JComponent
'ssetToolTipTextgetToolTipText
methodto allow use ofin order to allow the renderer's tips(iftotheberendererused if it has text set).
NOTENote: ForJTable
to properly display tooltips of its renderersJTable
must be a registered component with theToolTipManager
. This is done automatically ininitializeLocalVars
but if at a later point()JTable
is toldsetToolTipText(null)
it will unregister the table component and no tips from renderers will display anymore. @see JComponent#getToolTipText
Returns the L&F object that renders this component. @return the TableUI
object that renders this component
Class JTable, String getUIClassID()Returns the suffix used to construct the name of the L&F classClass JTable, Object getValueAt(int, int)thatused torendersrender this component. @return the string "TableUI" @see JComponent#getUIClassID @see UIDefaults#getUI
Returns the cell value atClass JTable, boolean isCellEditable(int, int)row
andcolumn
.
NOTENote: The column is specified in the table view's display order and not in theTableModel
's column order. This is an important distinction because as the user rearranges the columns in the tablewhat isthe column atcolumna given index in the view2 changeswill change. Meanwhile the user's actions never affect the model's column ordering. @param row the row whose value is to belooked upqueried @param column the column whose value is to belooked upqueried @return the Object at the specified cell
Returns true if the cell atClass JTable, boolean isCellSelected(int, int)row
andcolumn
is editable. Otherwise invokingsetValueAt
()on the cell will have no effect.Note: The column is specified in the table view's display order and
not in theTableModel
's column order. This is an important distinction because as the user rearranges the columns in the table the column at a given index in the view will change. Meanwhile thevalueuser'sof thatactions nevercellaffect the model's column ordering. @param row the row whose value is to belooked upqueried @param column the column whose value is to belookedqueriedup@return true if the cell is editable.@see #setValueAt
Returns true if the cell at the specified position is selected. @param row the row being queried @param column the column being queried @return true if the cell at indexClass JTable, boolean isColumnSelected(int)(row column)
is selected where the first row and first column are at index 0 @exception IllegalArgumentException ifrow
orcolumn
are not in the valid range
Returns true if the column at the specified index is selected. @param column the column in the column model @return true if the column at indexClass JTable, boolean isEditing()column
is selected where 0 is the first column @exception IllegalArgumentException ifcolumn
is not in the valid range
Returns trueClass JTable, boolean isFocusTraversable()is the tableif a cell isediting abeingcelledited. @return trueisif the table is editing a cell @see #editingColumn @see #editingRow
Class JTable, boolean isManagingFocus()Identifies whetherWe overrideor notthiscomponent can receive themethod whose implementation infocus.JComponent
A disabled button forreturns false to returnexampletrue.would returnThis indicatesfalse.that@returnthetrueJTable
if thisis a componentcanthatreceiveshouldthebe part of a (tabbing) focus cycle by default. @return true
We override this method whose implementation inClass JTable, boolean isRowSelected(int)JComponent
returns false to return true. This allows us to give a special meaning to TAB and SHIFT-TAB in theJTable
. @return true
Returns true if the row at the specified index is selected. @return true if the row at indexClass JTable, void moveColumn(int, int)row
is selected where 0 is the first row @exception IllegalArgumentException ifrow
is not in the valid range
Moves the columnClass JTable, String paramString()column
to the position currently occupied by the columntargetColumn
in the view. The old column attargetColumn
is shifted left or right to make room. @param column the index of column to be moved @param targetColumn the new index of the column
Returns a string representation of thisClass JTable, Component prepareEditor(TableCellEditor, int, int)JTabletable. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJTable.table
Prepares theClass JTable, Component prepareRenderer(TableCellRenderer, int, int)specifiededitorusingby querying the data model for the value and selection state of the cell atrow
column
.Note: Throughout the
specifiedtablecellpackage the internal implementations always use this method to prepare editors so that this default behavior can be safely overridden by a subclass. @param editor theTableCellEditor
to set up @param row the row of the cell to edit where 0 is the first row @param column the column of the cell to edit where 0 is the first column @return theComponent
being edited
Prepares theClass JTable, void removeColumn(TableColumn)specifiedrendererwithby queryingan appropriate value fromthe data model for thedataModelvalue andan appropriate selectionselection state ofvaluethe cell atfromrow
column
.Note: Throughout the
selectiontable package the internalmodelsimplementations always use this method to prepare renderers so that this default behavior can be safely overridden by a subclass. @param renderer theTableCellRenderer
to prepare @param row the row of the cell to render where 0 is the first row @param column the column of the cell to render where 0 is the first column
RemovesClass JTable, void removeColumnSelectionInterval(int, int)aColumn
fromthethisJTable
's array of columns. Note: this method does not remove the column of data from the model; it just removes theTableColumn
that was responsible for displaying it. @param aColumnThetheTableColumn to be removed @see #addColumn
Deselects the columns fromClass JTable, void removeEditor()index0
toindex0index1
inclusive. @exception IllegalArgumentException ifindex0
orindex1
lie outside [0getColumnCount()
-1] @param index0 one end of the interval.@param index1 the other end of the interval
Class JTable, void removeNotify()DiscardDiscards the editor object andreturnfrees the real estate it usedtofor cell rendering.
Class JTable, void removeRowSelectionInterval(int, int)NotificationCallsto this component that it no longer has a parent component. When this method is invoked any KeyboardActions set up inthethe chain of parentunconfigureEnclosingScrollPane
components are removedmethod. @see #registerKeyboardActionunconfigureEnclosingScrollPane
Deselects the rows fromClass JTable, void reshape(int, int, int, int)index0
toindex0index1
inclusive. @exception IllegalArgumentException ifindex0
orindex1
lie outside [0getRowCount()
-1] @param index0 one end of the interval.@param index1 the other end of the interval
Class JTable, void resizeAndRepaint()CallsMovessuper.reshape()andis overridden simply to detect changes in our bounds. After reshaping we resize theresizescolumnsthis(similar to triggering a layout) to fit the new bounds for thecomponentusing sizeColumnsToFit(). @see java.awt.Component#sizeColumnsToFit(int)setBounds
Equivalent toClass JTable, int rowAtPoint(Point)revalidate
followed by()repaint
.()
Returns the index of the row thatClass JTable, void selectAll()point
lies in or -1 if the result is not in the range [0getRowCount()
-1]. @param point the location of interest @return the index of the row thatpoint
lies in or -1 ifitthe result is not in the range [0getRowCount()
-1] @see #columnAtPoint
Class JTable, void setAutoCreateColumnsFromModel(boolean)SelectSelects all rows columns and cells in the table.
SetsClass JTable, void setAutoResizeMode(int)thethis table'sautoCreateColumnsFromModel
flag. This methodwill callcallscreateDefaultColumnsFromModel
if()createColumnsautoCreateColumnsFromModel
changesisfrom false to true. @paramcreateColumnsautoCreateColumnsFromModel true ifJTable
shouldautoautomatically create columns @see #getAutoCreateColumnsFromModel @see #createDefaultColumnsFromModel @beaninfo bound: true description: Automaticallypopulatepopulates the columnModel when a new TableModel is submitted.
Sets the table's auto resize mode when the table is resized. @param mode One of 5 legal values: AUTO_RESIZE_OFF AUTO_RESIZE_NEXT_COLUMN AUTO_RESIZE_SUBSEQUENT_COLUMNS AUTO_RESIZE_LAST_COLUMN AUTO_RESIZE_ALL_COLUMNS @see #getAutoResizeMode @see #sizeColumnsToFit(int) @beaninfo bound: true description: Whether the columns should adjust themselves automatically. enum: AUTO_RESIZE_OFF JTable.AUTO_RESIZE_OFF AUTO_RESIZE_NEXT_COLUMN JTable.AUTO_RESIZE_NEXT_COLUMN AUTO_RESIZE_SUBSEQUENT_COLUMNS JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS AUTO_RESIZE_LAST_COLUMN JTable.AUTO_RESIZE_LAST_COLUMN AUTO_RESIZE_ALL_COLUMNS JTable.AUTO_RESIZE_ALL_COLUMNSClass JTable, void setCellEditor(TableCellEditor)
Class JTable, void setCellSelectionEnabled(boolean)SetSets thecellEditor
variable. @param anEditor the TableCellEditor that does the editing @see #cellEditor @beaninfo bound: true description: The table's active cell editor if one exists.
Sets whether this table allows both a column selection and a row selection to existClass JTable, void setColumnModel(TableColumnModel)at the same timesimultaneously. When setthis results in a facility to select a rectangular region of cells inthe table treats the intersection of the row and column selection models as thedisplayselected cells. OverrideisCellSelected
to change this default behavior. Thisflagmethod is equivalent to settingover-ridesboth therowrowSelectionAllowed
property andcolumncolumnSelectionAllowed
selectionproperty ofmodestheensuringcolumnModel
that cell selectionto the suppliedisvalue. @parampossible whenever this flagcellSelectionEnabled true if simultaneous row and column selection isset.allowed @see #getCellSelectionEnabled @see #isCellSelected @beaninfo bound: true description: Select a rectangular region of cells rather than rows or columns.
Sets the column model for this table toClass JTable, void setColumnSelectionAllowed(boolean)newModel
and registerswithforlistnerlistener notifications from the new column model. Also sets the column model of theJTableHeader
tonewModelcolumnModel
. @paramnewModelcolumnModel the new data source for this table @exception IllegalArgumentException ifnewModelcolumnModel
isnull
@see #getColumnModel @beaninfo bound: true description: The object governing the way columns appear in the view.
Sets whether the columns in this model can be selected. @param columnSelectionAllowed true if this model will allow column selection @see #getColumnSelectionAllowed @beaninfo bound: true description: If true an entire column is selected for each selected cell.Class JTable, void setColumnSelectionInterval(int, int)
Selects the columns fromClass JTable, void setDefaultEditor(Class, TableCellEditor)index0
toindex1
inclusive. @exception IllegalArgumentException ifindex0
orindex1
lie outside [0getColumnCount()
-1] @param index0 one end of the interval.@param index1 the other end of the interval
Class JTable, void setDefaultRenderer(Class, TableCellRenderer)SetSets a default cell editor to be used if no editor has been set in aTableColumn
. If no editing is required in a table or a particular column in a tableuseuses theisCellEditable
method in the()TableModel
interface to ensure thatthethisJTable
will not start an editor in these columns. If editor isnull
removeremoves the default editor for this column class. @param columnClass set the default cell editor for this columnClass @param editor default cell editor to be used for this columnClass @see TableModel#isCellEditable @see #getDefaultEditor @see #setDefaultRenderer
Class JTable, void setEditingColumn(int)SetSets a default cell renderer to be used if no renderer has been set in aTableColumn
. If renderer isnull
removeremoves the default renderer for this column class. @param columnClass set the default cell renderer for this columnClass @param renderer default cell renderer to be used for this columnClass @see #getDefaultRenderer @see #setDefaultEditor
Class JTable, void setEditingRow(int)SetSets theeditingColumn
variable. @param aColumn the column of the cell to be edited @see #editingColumn
Class JTable, void setGridColor(Color)SetSets theeditingRow
variable. @param aRow the row of the cell to be edited @see #editingRow
Sets the color used to draw grid lines toClass JTable, void setIntercellSpacing(Dimension)colorgridColor
and redisplaysthe receiver. The default color isColor.gray
. @paramcolorgridColor the new color of the grid lines @exception IllegalArgumentException ifcolorgridColor
isnull
@see #getGridColor @beaninfo bound: true description: The grid color.
Sets theClass JTable, void setModel(TableModel)widthrowMargin
andheightthebetweencolumnMargin
cells--tothenewSpacingheight andredisplayswidth of thereceiverspace between cells -- tointercellSpacing
. @paramnewSpacingintercellSpacing aTheDimension
specifying the new width and heightintercellSpacingbetween cells @see #getIntercellSpacing @beaninfo description: The spacing between the cells drawn in the background color of the JTable.
Sets the data model for this table toClass JTable, void setPreferredScrollableViewportSize(Dimension)newModel
and registers with it forlistnerlistener notifications from the new data model. @param newModel the new data source for this table @exception IllegalArgumentException ifnewModel
isnull
@see #getModel @beaninfo bound: true description: The model that is the source of the data for this view.
Sets the preferred size of the viewport for this table. @param size aClass JTable, void setRowHeight(int)Dimension
object specifying thepreferredSize
of aJViewport
whose view is this table @see Scrollable#getPreferredScrollableViewportSize @beaninfo description: The preferred size of the viewport.
Sets the heightClass JTable, void setRowMargin(int)for rowsin pixels of all cells tonewRowHeightrowHeight
revalidates andinvokesrepaints. The height of the cells in this row will be equaltileto the row height minus the row margin. @paramnewRowHeightrowHeight new row height @exception IllegalArgumentExceptionIfifnewRowHeightrowHeight
is less than 1.@see #getRowHeight @beaninfo bound: true description: The height of thecells including the inter-cellspecifiedspacingrow.
Sets the amount ofClass JTable, void setRowSelectionAllowed(boolean)emtpyempty space between cells in adjacent rows. @param rowMargin the number of pixels between cells in a row @see #getRowMargin @beaninfo bound: true description: The amount of space between cells.
Sets whether the rows in this model can be selected. @param rowSelectionAllowed true if this model will allow row selection @see #getRowSelectionAllowed @beaninfo bound: true description: If true an entire row is selected for each selected cell.Class JTable, void setRowSelectionInterval(int, int)
Selects the rows fromClass JTable, void setSelectionBackground(Color)index0
toindex1
inclusive. @exception IllegalArgumentException ifindex0
orindex1
lie outside [0getRowCount()
-1] @param index0 one end of the interval.@param index1 the other end of the interval
Class JTable, void setSelectionForeground(Color)SetSets the background color for selected cells. Cell renderers can use this color to the fill selected cells.The default value of this property is defined by the look and feel implementation.
This is a JavaBeans bound property. @param selectionBackground the
Color
to use for the background of selected cells @see #getSelectionBackground @see #setSelectionForeground @see #setForeground @see #setBackground @see #setFont @beaninfo bound: true description: A default background color for selected cells.
Class JTable, void setSelectionMode(int)SetSets the foreground color for selected cells. Cell renderers can use this color to render text and graphics for selected cells.The default value of this property is defined by the look and feel implementation.
This is a JavaBeans bound property. @param selectionForeground the
Color
to use in the foreground for selected list items @see #getSelectionForeground @see #setSelectionBackground @see #setForeground @see #setBackground @see #setFont @beaninfo bound: true description: A default foreground color for selected cells.
Sets the table's selection mode to allow only single selections a single contiguous interval or multiple intervals.Class JTable, void setSelectionModel(ListSelectionModel)NOTE
Note :JTable
provides all the methods for handling column and row selection. When setting states such assetSelectionMode
it not only updates the mode for the row selection model but also sets similar values in the selection model of thecolumnModel
. If you want to have the row and column selection models operating in different modes set them both directly.Both the row and column selection models for
theJTable
default to using aDefaultListSelectionModel
so thatJTable
works the same way as theJList
. See thesetSelectionMode
()method inJList
for details about the modes. @see JList#setSelectionMode @beaninfo description: The selection mode used by the row and column selection models. enum: SINGLE_SELECTION ListSelectionModel.SINGLE_SELECTION SINGLE_INTERVAL_SELECTION ListSelectionModel.SINGLE_INTERVAL_SELECTION MULTIPLE_INTERVAL_SELECTION ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
Sets the row selection model for this table toClass JTable, void setShowGrid(boolean)newModel
and registerswithforlistnerlistener notifications from the new selection model. @param newModel the new selection model @exception IllegalArgumentException ifnewModel
isnull
@see #getSelectionModel @beaninfo bound: true description: The selection model for rows.
Sets whether theClass JTable, void setShowHorizontalLines(boolean)receivertable draws grid lines around cells. IfflagshowGrid
is true it does; if it is false it doesn't. There is nogetShowGrid
method as()thethis state is held in two variables:--showHorizontalLines
andshowVerticalLines
-- each of whichmaycan be queried independently. @paramflagshowGrid true if table view should draw grid lines @see #setShowVerticalLines @see #setShowHorizontalLines @beaninfo description: The color used to draw the grid lines.
Sets whether theClass JTable, void setShowVerticalLines(boolean)receivertable draws horizontal lines between cells. IfflagshowHorizontalLines
is true it does; if it is false it doesn't. @paramflagshowHorizontalLines true if table view should draw horizontal lines @see #getShowHorizontalLines @see #setShowGrid @see #setShowVerticalLines @beaninfo bound: true description: Whether horizontal lines should be drawn in between the cells.
Sets whether theClass JTable, void setTableHeader(JTableHeader)receivertable draws vertical lines between cells. IfflagshowVerticalLines
is true it does; if it is false it doesn't. @paramflagshowVerticalLines true if table view should draw vertical lines @see #getShowVerticalLines @see #setShowGrid @see #setShowHorizontalLines @beaninfo bound: true description: Whether vertical lines should be drawn in between the cells.
Sets theClass JTable, void setUI(TableUI)tableHeader
working with thisJTable
tonewHeader
. It is legal to have anull
tableHeader
. @param newHeader new tableHeader @see #getTableHeader @beaninfo bound: true description: The JTableHeader instance which renders the column headers.
Sets the L&F object that renders this component and repaints. @param ui the TableUI L&F object @see UIDefaults#getUIClass JTable, void setValueAt(Object, int, int)
Sets the value for the cell in the table model atClass JTable, void sizeColumnsToFit(int)row
andcolumn
.Note: The column is specified in the table
view's display order and not in theTableModel
's column order. This is an important distinction because as the user rearranges the columns in the table the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.aValue
is the new value. @param aValue the new value @param row the rowwhose value isof the cell to be changed @param column the columnwhoseofvalue isthe cell to be changed @see #getValueAt
Class JTable, void tableChanged(TableModelEvent)This method will resizeResizes one or moreotof the columns in the table so that the total width of all ofthethisJTable
's columnswill beis equal to the width of the table.When
setBounds()doLayout
is called onthethisJTable
often as a result of the resizing of an enclosing window-this method is called withresizingColumn
set to -1. This means that resizing has taken place'"outside'" theJTable
and the change - or'"delta'" - should be distributed to all of the columns regardless ofthethisJTable
'sautoResizeModeautomatic resize mode.If the
resizingColumn
is not -1 it is one of the columns in the table that has changed size rather than the table itself. In this case the auto-resize modes govern the way the extra (ordefecitdeficit) space is distributed amongst theavailibleavailable columns.The modes are:
- AUTO_RESIZE_OFF: Don't automatically adjust the column's widths at all. Use a horizontal scrollbar to accomodate the columns when their sum exceeds the width of the
Viewport
. If theJTable
is not enclosed in aJScrollPane
this may leave parts of the table invisible.- AUTO_RESIZE_NEXT_COLUMN: Use just the column after the resizing column. This results in the
'boundry'"boundary" or divider between adjacent cells being independently adjustable.- AUTO_RESIZE_SUBSEQUENT_COLUMNS: Use all columns after the one being adjusted to absorb the changes. This is the default behavior.
- AUTO_RESIZE_LAST_COLUMN
Only ever:automaticallyAutomatically adjust the size of the last column only. If the bounds of the last column prevent the desired size from being allocated set the width of the last column to the appropriate limit and make no further adjustments.- AUTO_RESIZE_ALL_COLUMNS: Spread the delta amongst all the columns in the
JTable
including the one that is being adjusted.
Note: WhentheaJTable
makes adjustments to the widths of the columns it respects their minimum and maximum values absolutely. It is therefore possible that even after this method is called the total width of the columns is still not equal to the width of the table. When this happens theJTable
does not put itself in AUTO_RESIZE_OFF mode to bring up aScrollBarscroll bar or break other commitments of its current auto-resize mode -- instead it allows its bounds to be set larger (or smaller) than the total of the columnminimaminimum ormaximamaximum meaning either that there will not be enough room to display all of the columns or that the columns will not fill theJTable
's bounds. These respectively result in the clipping of some columns or an area being painted in theJTable
's background color during painting.The mechanism for distributing the delta amongst the
availibleavailable columns is provided in a private method in theJTable
class:adjustSizes(long targetSize final Resizable3 r boolean inverse)an explanation of which is providedbelowin the following section.Resizable3
is a private interface that allows any data structure containing a collection of elements with a sizepreferredSizepreferred size maximummaximumSizesize andminimumSizeminimum size to have its elements manipulated by the algorithm.
Distributing the delta
Overview
Call
'"DELTA'" the difference between thetargetSizetarget size and the sum of the preferred sizes of the elements in r. The individual sizes are calculated by taking the original preferred sizes and adding a share of the DELTA - that share being based on how far each preferred size is from its limiting bound (minimum or maximum).
Definition
Call the individual constraints min[i] max[i] and pref[i].
#Call their respective sums: MIN MAX and PREF.
#Each new size will be calculated using:
size[i] = pref[i] + delta[i]where each individual delta[i] is calculated according to:If (DELTA <0) we are in shrink mode where:
#
If (DELTA > 0) we are in expand mode where:#########################DELTA#######delta[i] =####------------ * (pref[i] - min[i])######################(PREF - MIN)#
#########################DELTA#######delta[i] =####------------ * (max[i] - pref[i])######################(MAX - PREF)The overall effect is that the total size moves that same percentage k towards the total minimum or maximum and that percentage
guarenteesguarantees accomodation of the required space DELTA.Details
Naive evaluation of the formulae presented here would be subject to the aggregated rounding errors caused by doing this operation in finite precision (using ints). To deal with this the
muliplyingmultiplying factor above is constantly recalculated and this takes account of the rounding errors in the previous iterations. The result is an algorithmwhichthat produces a set of integers whose values exactly sum to the suppliedtargetSize
and does so by spreading the rounding errors evenly over the given elements.When the MAX and MIN bounds are hit
When
targetSize
is outside the [MIN MAX] range the algorithm sets all sizes toeithertheir appropriate limiting value (maximum or minimum). @param resizingColumnThethe column whose resizing made this adjustment necessary or -1 if there is no such column.@see TableColumn#setWidth
Invoked when this table'sClass JTable, void updateUI()TableModel
generates aTableModelEvent
. TheTableModelEvent
should be constructed in theco-ordinatecoordinate system of the model; the appropriate mapping to the viewco-ordinatecoordinate system is performed bythethisJTable
when itrecievesreceives the event.Application code will not use these methods explicitly they are used internally by JTable.
Notification from theClass JTable, void valueChanged(ListSelectionEvent)UIManager
that the L&F has changed. Replaces the current UI object with the latest version from theUIManager
. @see JComponent#updateUI
Invoked when the row selection changes -- repaints to show the new selection.Class JTable, int AUTO_RESIZE_ALL_COLUMNSApplication code will not use these methods explicitly they are used internally by JTable. @param e the event received @see ListSelectionListener
During all resize operations proportionately resize all columns.Class JTable, int AUTO_RESIZE_LAST_COLUMN
During all resize operations apply adjustments to the last column only.Class JTable, int AUTO_RESIZE_NEXT_COLUMN
When a column is adjusted in the UI adjust the next column the opposite way.Class JTable, int AUTO_RESIZE_OFF
Do not adjust column widths automatically; use a scrollbar.Class JTable, int AUTO_RESIZE_SUBSEQUENT_COLUMNS
During UI adjustment change subsequent columns to preserve the total width; this is the default behavior.Class JTable, boolean autoCreateColumnsFromModel
The table will query the TableModel
to build the default set of columns if this is true.
Class JTable, int autoResizeModeClass JTable, TableCellEditor cellEditorThisDeterminesmode value determinesif the table automatically resizes the width of the table's columns to take up the entire width of the table and how it does the resizing.
The object that overwrites the screen real estate occupied by the current cell and allows the user to changeClass JTable, boolean cellSelectionEnabledthoseits contents.
Class JTable, TableColumnModel columnModelIf this is true then bothObsolete as of Java 2 platforma row selection and a column selection can bev1.3.non-emptyPleaseatuse thesamerowSelectionAllowed
time the selectedproperty and thecellscolumnSelectionAllowed
are theproperty of thecellscolumnModel
whose rowinstead.and column are bothOr use the methodselectedgetCellSelectionEnabled
.
The TableColumnModel
of the table.
Class JTable, TableModel dataModelThe TableModel
of the table.
Class JTable, Hashtable defaultEditorsByColumnClassA table of objects that display and edit the contents of a cell indexed by class as declared inClass JTable, Hashtable defaultRenderersByColumnClassgetColumnClass
in theTableModel
interface.
A table of objects that display the contents of a cell indexed by class as declared inClass JTable, Component editorCompgetColumnClass
in theTableModel
interface.
If editing the
Component that is handling the editing.
Class JTable, Color gridColorThe color of the grid.Class JTable, Dimension preferredViewportSize
Used by the Scrollable
interface to determine the initial visible area.
Class JTable, int rowHeightThe height in pixels ofClass JTable, int rowMarginall rowseach row in the table.
The height in pixels of the margin betweenClass JTable, boolean rowSelectionAllowedrowsthe cells in each row.
Class JTable, Color selectionBackgroundRowTrue if row selection is allowed in this table.
The background color of selected cells.Class JTable, Color selectionForeground
The foreground color of selected cells.Class JTable, ListSelectionModel selectionModel
The ListSelectionModel
of the table used to keep track of row selections.
Class JTable, boolean showHorizontalLinesThe table draws horizontal lines between cells if showHorizontalLines
is true.
Class JTable, boolean showVerticalLinesThe table draws vertical lines between cells if showVerticalLines
is true.
Class JTable, JTableHeader tableHeaderThe TableHeader
working with the table.
A TextArea is a multi-line area that displays plain text. It is intended to be a lightweight component that provides source compatibility with the java.awt.TextArea class where it can reasonably do so. You can find information and examples of using all the text components in Using Text Components a section in The Java Tutorial.This component has capabilities not found in the java.awt.TextArea class. The superclass should be consulted for additional capabilities. Alternative multi-line text classes with more capabilitites are JTextPane and JEditorPane.
The
java.awt.TextArea
internally handles scrolling.JTextArea
is different in that it doesn't manage scrolling but implements the swingScrollable
interface. This allows it to be placed inside aJScrollPane
if scrolling behavior is desired and used directly if scrolling is not desired.The
java.awt.TextArea
has the ability to do line wrapping. This was controlled by the horizontal scrolling policy. Since scrolling is not done byJTextArea
directly backward compatibility must be provided another way.JTextArea
has a bound property for line wrapping that controls whether or not it will wrap lines. By default the line wrapping property is set to false (not wrapped).
java.awt.TextArea
has two properties rows and columns that are used to determine the preferred size.JTextArea
uses these properties to indicate the preferred size of the viewport when placed inside a JScrollPane to match the functionality provided byjava.awt.TextArea
.JTextArea
has a preferred size of what is needed to display all of the text so that it functions properly inside of aJScrollPane
. If the value for the rows or columns is equal to zero the preferred size along that axis is used for the viewport preferred size along the same axis.The java.awt.TextArea could be monitored for changes by adding a TextListener for TextEvent's. In the JTextComponent based components changes are broadcasted from the model via a DocumentEvent to DocumentListeners. The DocumentEvent gives the location of the change and the kind of change if desired. The code fragment might look something like:
DocumentListener myListener = ; JTextArea myArea = ; myArea.getDocument().addDocumentListener(myListener);
For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JTextArea key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A multi-line area that displays plain text. @author Timothy Prinzing @version 1.
58 1068 03/1314/9800 @see JTextPane @see JEditorPane
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJTextArea
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to text area user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Constructs a new JTextArea with the specified number of rows and columns and the given model. All of the constructors feed through this constructor. @param doc the model to use or create a default one if null @param text the text to be displayed null if none @param rows the number of rows >= 0 @param columns the number of columns >= 0 @exception IllegalArgumentException if the rows or columns arguments are negative.Class JTextArea, constructor JTextArea(String, int, int)
Constructs a new TextArea with the specified text and number of rows and columns. A default model is created. @param text the text to be displayed or null @param rows the number of rows >= 0 @param columns the number of columns >= 0 @exception IllegalArgumentException if the rows or columns arguments are negative.Class JTextArea, constructor JTextArea(int, int)
Constructs a new empty TextArea with the specified number of rows and columns. A default model is created and the initial string is null. @param rows the number of rows >= 0 @param columns the number of columns >= 0 @exception IllegalArgumentException if the rows or columns arguments are negative.Class JTextArea, AccessibleContext getAccessibleContext()
Class JTextArea, boolean getWrapStyleWord()GetGets the AccessibleContext associated with this JTextArea.CreatesForaJTextAreas the AccessibleContext takes the form of an AccessibleJTextArea. A newcontextAccessibleJTextArea instance is created if necessary. @return an AccessibleJTextArea that serves as the AccessibleContext of this JTextArea
Get the style of wrapping used if the text area is wrapping lines. If set to true the lines will be wrapped at wordClass JTextArea, void processComponentKeyEvent(KeyEvent)boundriesboundaries (ie whitespace) if they are too long to fit within the allocated width. If set to false the lines will be wrapped at characterboundriesboundaries. @returns if the wrap style should be wordboundriesboundaries instead of characterboundriesboundaries. @see #setWrapStyleWord
Class JTextArea, void processKeyEvent(KeyEvent)Make sureProcesses any key events thatTABthe component itself recognizes. This is called after the focus manager andShift-TABanyeventsinterested listeners have been givengeta chance to steal away the event. This method is called only if the event has not yet been consumed.so that awtThis method isdoesn'tcalledattemptpriorfocusto the keyboard UI logic.This method is implemented to do nothing. Subclasses would normally override
traversalthis method if they process some key events themselves. If the event is processed it should be consumed.
Class JTextArea, void setLineWrap(boolean)Override processKeyEvent to processMake sure that TAB and Shift-TAB events get consumed so that awt doesn't attempt focus traversal.
Sets the line-wrapping policy of the text area. If set to true the lines will be wrapped if they are too long to fit within the allocated width. If set to false the lines will always be unwrapped. A PropertyChange event ("lineWrap") is fired when the policy is changed. By default this property is false. @param wrap indicates if lines should be wrapped. @see #getLineWrap @beaninfo preferred: true bound: true description: should lines be wrappedClass JTextArea, void setWrapStyleWord(boolean)
Set the style of wrapping used if the text area is wrapping lines. If set to true the lines will be wrapped at wordboundriesboundaries (iewhitespace) if they are too long to fit within the allocated width. If set to false the lines will be wrapped at characterboundriesboundaries. By default this property is false. @param word indicates if wordboundriesboundaries should be used for line wrapping. @see #getWrapStyleWord @beaninfo preferred: false bound: true description: should wrapping occur at wordboundriesboundaries
JTextField is a lightweight component that allows the editing of a single line of text.ItFor information on and examples of using text fields see How to Use Text Fields in The Java Tutorial.JTextField
is intended to be source-compatible with java.awt.TextField where it is reasonable to do so. This component has capabilities not found in the java.awt.TextField class. The superclass should be consulted for additional capabilities.JTextField has a method to establish the string used as the command string for the action event that gets fired. The java.awt.TextField used the text of the field as the command string for the ActionEvent. JTextField will use the command string set with the
setActionCommand
method if not null otherwise it will use the text of the field as a compatibility with java.awt.TextField.The method
setEchoChar
andgetEchoChar
are not provided directly to avoid a new implementation of a pluggable look-and-feelinadvertantlyinadvertently exposing password characters. To provide password-like services aseperateseparate class JPasswordField extends JTextField to provide this service with anindependantlyindependently pluggable look-and-feel.The java.awt.TextField could be monitored for changes by adding a TextListener for TextEvent's. In the JTextComponent based components changes are broadcasted from the model via a DocumentEvent to DocumentListeners. The DocumentEvent gives the location of the change and the kind of change if desired. The code fragment might look something like:
DocumentListener myListener = ; JTextField myArea = ; myArea.getDocument().addDocumentListener(myListener);
The horizontal alignment of JTextField can be set to be left justified leading justified centered right justified or
righttrailing justified. Right/trailing justification is useful if the required size of the field text is smaller than the size allocated to it. This is determined by thesetHorizontalAlignment
andgetHorizontalAlignment
methods. The default is to beleftleading justified.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JTextField key assignments.
ForHowcompatibility withthe textjava.awt.TextFieldfieldtheconsumes VK_ENTERkey fireseventsthe ActionEvent todepends on whether theregisteredtextActionListeners.fieldHowever awthas anydidn'tactionhavelisteners.default buttons likeIf so thenswingVK_ENTERdoes.resultsIf a text field has focusin the listeners getting an ActionEvent and the VK_ENTERkeyevent ispressed itconsumed.will fire the fields ActionEvent rather than activate theThis is compatible with how AWT text fields handledefaultVK_ENTERbuttonevents.To disableIf thecompatibility withtextawt for text fields the following code fragment willfield has no action listeners then as of vremove1.3 thebinding ofVK_ENTERfrom the default keymap used by all JTextFields if thatevent isdesirednot consumed. Insteadstatic { JTextField f = newthe bindings of ancestor components areJTextField();processedKeyStroke enter =which enables theKeyStroke.getKeyStroke(KeyEvent.VK_ENTERdefault0);buttonKeymap mapfeature of=JFC/Swingf.getKeymap();tomapwork.removeKeyStrokeBinding(enter); }Customized fields can easily be created by extending the model and changing the default model provided. For example the following piece of code will create a field that holds only upper case characters. It will work even if text is pasted into from the clipboard or it is altered via programmatic changes.
public class UpperCaseField extends JTextField { public UpperCaseField(int cols) { super(cols); } protected Document createDefaultModel() { return new UpperCaseDocument(); } static class UpperCaseDocument extends PlainDocument { public void insertString(int offs String str AttributeSet a) throws BadLocationException { if (str == null) { return; } char[] upper = str.toCharArray(); for (int i = 0; i
upper[i] = Character.toUpperCase(upper[i]); } super.insertString(offs new String(upper) a); } } } Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A component which allows for the editing of a single line of text. @author Timothy Prinzing @version 1.
58 0971 03/0114/9800 @see #setActionCommand @see JPasswordField @see #addActionListener
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJTextField
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to text field user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Class JTextField, int getHorizontalAlignment()GetGets the AccessibleContext associated with this JTextField.CreatesForaJTextFields the AccessibleContext takes the form of an AccessibleJTextField. A newcontextAccessibleJTextField instance is created if necessary. @return an AccessibleJTextField that serves as the AccessibleContext of this JTextField
Returns the horizontal alignment of the text. Valid keys: JTextField.LEFTClass JTextField, boolean isValidateRoot()(the default)JTextField.CENTER JTextField.RIGHT JTextField.LEADING and JTextField.TRAILING @return the alignment
Calls to revalidate that come from within the textfield itself will be handled by validating the textfield unless the receiver is contained within a JViewport in which case this returns false. @see JComponent#revalidate @see JComponent#isValidateRootClass JTextField, void setHorizontalAlignment(int)
Sets the horizontal alignment of the text. Valid keys: JTextField.LEFT JTextField.CENTER JTextField.RIGHT JTextField.LEADING (the default)JTextField.CENTERand JTextField.RIGHTTRAILING. invalidate() and repaint() are called when the alignment is set and a PropertyChange event ("horizontalAlignment") is fired. @param alignment the alignment @exception IllegalArgumentException if the alignment specified is not a valid key. @beaninfo preferred: true bound: true description: Set the field alignment to LEFT CENTER RIGHT LEADING (the default)CENTER RIGHTor TRAILING enum: LEFT JTextField.LEFT CENTER JTextField.CENTER RIGHT JTextField.RIGHT LEADING JTextField.LEADING TRAILING JTextField.TRAILING
A text component that can be marked up with attributes that are represented graphically. You can find how-to information and examples of using text panes in Using Text Components a section in The Java Tutorial.Class JTextPane, constructor JTextPane(StyledDocument)This component models paragraphs that are composed of runs of character level attributes. Each paragraph may have a logical style attached to it which contains the default attributes to use if no overriden by attributes set on the paragraph or character run. Components and images may be embedded in the flow of text.
For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JTextPane key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer true description: A text component that can be marked up with attributes that are graphically represented. @author Timothy Prinzing @version 1.
66 0972 02/0102/9800 @see javax.swing.text.StyledEditorKit
Constructs a new JTextPane with a specified document model. A new instance of javax.swing.text.StyledEditorKit is created and set. @param doc the document modelClass JTextPane, EditorKit createDefaultEditorKit()
Creates the EditorKit to use by default. This is implemented to return javax.swing.text.StyledEditorKit. @return the editor kitClass JTextPane, boolean getScrollableTracksViewportWidth()
Returns true if a viewport should always force the width of thisClass JTextPane, void setEditorKit(EditorKit)Scrollable
to match the width of the viewport. @return true if a viewport should force the Scrollables width to match its own.false otherwise
Sets the currently installed kit for handling content. This is the bound property that establishes the content type of the editor. @param kit the desired editor behavior. @exception IllegalArgumentException if kit is not atext.StyledEditorKit
An implementation of a two-state button. TheJRadioButton
andJCheckBox
classes are subclasses of this class. For information on using them see How to Use Buttons Check Boxes and Radio Buttons a section in The Java Tutorial.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JToggleButton key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: An implementation of a two-state button. @see JRadioButton @see JCheckBox @version 1.
38 1049 03/0814/9800 @author Jeff Dinkins
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJToggleButton
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to toggle button user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Creates a toggle button with the specified text image and selection state. @param text the text of the toggle buttonClass JToggleButton, AccessibleContext getAccessibleContext().@param icon the image that the button should display @param selected if true the button is initially selected; otherwise the button is initially unselected
GetGets the AccessibleContext associated with thisJComponentJToggleButton. For toggle buttons the AccessibleContext takes the form of an AccessibleJToggleButton. A new AccessibleJToggleButton instance is created if necessary. @return an AccessibleJToggleButton that serves as the AccessibleContext of thisJComponentJToggleButton @beaninfo expert: true description: The AccessibleContext associated with this ToggleButton.
JToolBar
provides a componentwhichthat is useful for displaying commonly usedActionsAction
s or controls.ItFor examples and information on using tool bars see How to Use Tool Bars a section in The Java Tutorial.A tool bar
can be dragged out into a separate window by the user (unless the floatable property is set to false). In order for drag-out to work correctly it is recommended that you addJToolBar
instances to one of the four 'sides' of a container whose layout manager is aBorderLayout
and do not add children to any of the other four 'sides'.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JToolBar key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer true description: A component which displays commonly used controls or Actions. @version 1.
70 0487 03/2214/9900 @author Georges Saab @author Jeff Shapiro @see Action
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJToolBar
class. Itroleprovidesforan implementation of the Java Accessibility API appropriate to tool barthisuser-interfaceobjectelements.
Class JToolBar.Separator, constructor JToolBar.Separator(Dimension)CreateCreates a new toolbar separator with the default size as defined by the current look and feel.
Class JToolBar.Separator, Dimension getMaximumSize()CreateCreates a new toolbar separator with the specified size. @param size thenew sizeDimension
of the separator
Class JToolBar.Separator, Dimension getMinimumSize()ReturnReturns the maximum size for the separator. @return theDimension
object containing the separator's maximum size
Class JToolBar.Separator, Dimension getPreferredSize()ReturnReturns the minimum size for the separator. @return theDimension
object containing the separator's minimum size
Class JToolBar.Separator, Dimension getSeparatorSize()ReturnReturns the preferred size for the separator. @return theDimension
object containing the separator's preferred size
Class JToolBar.Separator, String getUIClassID()ReturnReturns the size of the separator @return theDimension
object containing the separator's size (This is a reference NOT a copy )
Returns the name of the L&F class that renders this component. @return the string "ToolBarSeparatorUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JToolBar.Separator, void setSeparatorSize(Dimension)
SetSets the size of the separator. @param size the newsizeDimension
of the separator
Class JToolBar, constructor JToolBar(int)CreateCreates a new toolbar.;Orientrationorientation defaults tohorizontalHORIZONTAL
.
Class JToolBar, JButton add(Action)CreateCreates a new toolbar.@paramwith the specifiedorientation. The
initialorientation
must be(eitherHORIZONTAL
/orVERTICAL
). @param orientation the orientation desired
Class JToolBar, void addSeparator()AddAdds a newJButton
which dispatches the action.As of 1.3 this is no longer the preferred method for adding
Action
s to a container. Instead it is recommended to configure a control with an action using usingsetAction
and then add that control directly to theContainer
. @param a theAction
object to add as a new menu item @return the new button which dispatches the action
Appends a toolbar separator of default size to the end of the toolbar. The default size is determined by the current look and feel.Class JToolBar, void addSeparator(Dimension)
Appends a toolbar separator of a specified size to the end of the toolbar. @param size theClass JToolBar, AccessibleContext getAccessibleContext()sizeDimension
of the separator
Class JToolBar, Component getComponentAtIndex(int)GetGets the AccessibleContext associated with thisJComponentJToolBar. For tool bars the AccessibleContext takes the form of an AccessibleJToolBar. A new AccessibleJToolBar instance is created if necessary. @return an AccessibleJToolBar that serves as the AccessibleContext of thisJComponentJToolBar
Returns the component at the specified index. @param i the component's position where 0Class JToolBar, int getComponentIndex(Component)=is first @return theComponent
at that position ornull
for an invalid index
Returns the index of the specified component. (Note: Separators occupy index positions.) @param c theClass JToolBar, Insets getMargin()Component
to find @return anintinteger indicating the component's position where 0=is first
Returns the margin between the toolbar's border and its buttons. @return an Insets
object containing the margin values @see Insets
Class JToolBar, int getOrientation()Returns the current orientation of the toolbar. The value is eitherClass JToolBar, String getUIClassID()HORIZONTAL
orVERTICAL
. @return anintinteger representing the current orientation(-- eitherHORIZONTAL
/orVERTICAL
)@see #setOrientation
Returns the name of the L&F class that renders this component. @return the string "ToolBarUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JToolBar, boolean isFloatable()
Class JToolBar, void paintBorder(Graphics)ReturnReturns true if theToolbarJToolbar
can be dragged out by the user. @return true if theToolbarJToolbar
can be dragged out by the user false otherwise
Paint the toolbar's border ifClass JToolBar, String paramString()BorderPainted
property is true. @param g theGraphics
context in which the painting is done @see JComponent#paint @see JComponent#setBorder
Returns a string representation of thisClass JToolBar, void setBorderPainted(boolean)JToolBar
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJToolBar
.
Sets whether the border should be painted. @param b if true the border is paintedClass JToolBar, void setFloatable(boolean).@see #isBorderPainted @beaninfo description: Does the toolbar paint its borders bound: true expert: true
Sets whether the toolbar can be made to float. @param b if true the toolbar can be dragged out; false otherwise @see #isFloatable @beaninfo description: Can the toolbar be made to float by the user bound: true preferred: trueClass JToolBar, void setMargin(Insets)
Sets the margin between the toolbar's border and its buttons. Setting toClass JToolBar, void setOrientation(int)null
causes the toolbar to use the default margins. The toolbar's defaultBorder
object uses this value to create the proper margin. However if a non-default border is set on the toolbar it is thatBorder
object's responsibility to create the appropriate margin space (otherwise this property will effectively be ignored). @param m anInsets
object that defines the space between the border and the buttons @see Insets @beaninfo description: The margin between the toolbar's border and contents bound: true expert: true
Class JToolBar, void setUI(ToolBarUI)SetSets the orientation of the toolbar. The orientation must have either the valueHORIZONTAL
orVERTICAL
. Iforientation
is an invalid value an exception will be thrown. @param oThethe new orientation(-- eitherHORIZONTAL
or VERTICAL @exception IllegalArgumentException if orientation is neitherHORIZONTAL
/norVERTICAL
)@see #getOrientation @beaninfo description: The current orientation of the toolbar bound: true preferred: true
Sets the L&F object that renders this component. @param ui the ToolBarUI
L&F object @see UIDefaults#getUI @beaninfo description: The menu item's UI delegate bound: true expert: true hidden: true
Class JToolBar, void updateUI()Notification from theUIFactory
that the L&F has changed. Called to replace the UI with the latest version from theUIFactory
. @see JComponent#updateUI
Used to display a "Tip" for a Component. Typically components provide api to automate the process of usingToolTipsToolTip
s. For example any Swing component can use theJComponent
setToolTipText
method to specify the text for a standard tooltip. A component that wants to create a customToolTip
display can overrideJComponent
'screateToolTip
method and use a subclass of this class.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JToolTip key assignments.
See How to Use Tool Tips in The Java Tutorial for further documentation.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JComponent#setToolTipText @see JComponent#createToolTip @version %I% %G% @author Dave Moore @author Rich Shiavi
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJToolTip
class. Itrole forprovides anthisimplementation of the Java Accessibility API appropriate to tool tip user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Class JToolTip, JComponent getComponent()GetGets the AccessibleContext associated with thisJComponentJToolTip. For tool tips the AccessibleContext takes the form of an AccessibleJToolTip. A new AccessibleJToolTip instance is created if necessary. @return an AccessibleJToolTip that serves as the AccessibleContext of thisJComponentJToolTip
Returns the component the tooltip applies to. The returned value may be null
. @return the component that the tooltip describes @see JComponent#createToolTip
Class JToolTip, String getTipText()Returns the text that is shown when the tool tip is displayed. The returned value may beClass JToolTip, ToolTipUI getUI()null
. @return theString
that is displayed
Returns the L&F object that renders this component. @return the ToolTipUI
object that renders this component
Class JToolTip, String getUIClassID()Returns the name of the L&F class that renders this component. @return the string "ToolTipUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JToolTip, String paramString()
Returns a string representation of thisClass JToolTip, void setComponent(JComponent)JToolTip
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJToolTip
.
Specifies the component that the tooltip describes. The componentClass JToolTip, void setTipText(String)c
may benull
and will have no effect. @param c theJComponent
being described @see JComponent#createToolTip
Sets the text to show when the tool tip is displayed. The stringClass JToolTip, void updateUI()tipText
may benull
. @param tipText theString
to display @beaninfo preferred: true bound: true description: Sets the text of the tooltip
Notification from theUIFactory
that the L&F has changed. Called to replace the UI with the latest version from theUIFactory
. @see JComponent#updateUI
A control that displays a set of hierarchical data as an outline. You can find task-oriented documentation and examples of using trees in How to Use Trees a section in The Java Tutorial.A specific node in a tree can be identified either by a
TreePath
(an object that encapsulates a node and all of its ancestors) or by its display row where each row in the display area displays one node.An expanded node is one displays its children. A collapsed node is one which hides them. A hidden node is one which is under a collapsedparentancestor.AAll of a viewablenode is undernodesa collapsed parentparents are expanded but may or may not be displayed. A displayed node is both viewable and in the display area where it can be seen.
TheseThe followingJTree
methods use "visible" to mean "displayed":
isRootVisible()
setRootVisible()
scrollPathToVisible()
scrollRowToVisible()
getVisibleRowCount()
setVisibleRowCount()
TheseThe next group ofJTree methods use "visible" to mean "viewable" (under an expanded parent):
isVisible()
makeVisible()
If you are interested in knowing when the selection changes implement the
TreeSelectionListener
interface and add the instance using the methodaddTreeSelectionListener
.valueChanged
will be invoked when the selection changes that is if the user clicks twice on the same nodevalueChanged
will only be invoked once.If you are interested in
knowingdetecting either doubleclicks-click events or when a user clicks on a node regardless of whether or not it was selectedit iswerecommendedrecommend you do the following:final JTree tree = ...; MouseListener ml = new MouseAdapter() { public voidNOTE: This example obtains both the path and row but you only need to get the one you're interested in.mouseClickedmousePressed(MouseEvent e) { int selRow = tree.getRowForLocation(e.getX() e.getY()); TreePath selPath = tree.getPathForLocation(e.getX() e.getY()); if(selRow = -1) { if(e.getClickCount() == 1) { mySingleClick(selRow selPath); } else if(e.getClickCount() == 2) { myDoubleClick(selRow selPath); } } } }; tree.addMouseListener(ml);To use
JTree
to display compound nodes (for example nodes containing both a graphic icon and text) subclass TreeCellRenderer and use #setTreeCellRenderersetCellRenderer to tell the tree to use it. To edit such nodes subclass TreeCellEditor and use #setTreeCellEditorsetCellEditorLike all
JComponent
classes you can useJComponent#registerKeyboardActionInputMap and ActionMap to associate an Action object with a KeyStroke and execute the action under specified conditions.
See How to Use Trees in The Java Tutorial for further documentation.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JTree key assignments.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @beaninfo attribute: isContainer false description: A component that displays a set of hierarchical data as an outline. @version
1.78$I%0503/1115/9800 @author Rob Davis @author Ray Ryan @author Scott Violet
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJTree
class.role forIt providesthisan implementation of the Java Accessibility API appropriate to tree user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Get the AccessibleAction associated with this object.Class JTree.AccessibleJTree.AccessibleJTreeNode, AccessibleComponent getAccessibleComponent()if oneIn theexists.implementationOtherwise returnof thenull.Java@Accessibility API for this class return this object which is responsible for implementing the AccessibleActionorinterface on behalf ofnullitself. @return this object
Get the AccessibleComponent associated with thisClass JTree.AccessibleJTree.AccessibleJTreeNode, AccessibleContext getAccessibleContext()treeobject.nodeInNOTE: ifthenode isimplementationnot displayedof the(eitherJavascrolled off of the screen or notAccessibility API for this class return thisexpanded)objectthis will return nullwhich is responsible for@returnimplementing the AccessibleComponent interface on behalf ofthisitself. @returntree nodethis object
Get the AccessibleContext associated with this tree node.Class JTree.AccessibleJTree.AccessibleJTreeNode, Accessible getAccessibleSelection(int)@returnIn theAccessibleContextimplementation of the Java Accessibility API for this class return this object which is its own AccessibleContext. @return thisJComponentobject
Returns an Accessible representing the specified selected item in the object. If there isn't a selection or there are fewer itemsselctedselected than the integer passed in the return value will be null. @param i the zero-based index of selected items @return an Accessible containing the selected item
Fire a visible data property change notification. A 'visible' data property isClass JTree.AccessibleJTree, Accessible getAccessibleAt(Point)that itone that represents something about the way the component appears on the display where that appearance isn't bound to any other property. It notifies screen readers that the visual appearance of the component has changed so they can notify the user.
Returns the Accessible child if one exists contained at the local coordinate Point. @param p point in local coordinates ofClass JTree.AccessibleJTree, Accessible getAccessibleSelection(int)thethis Accessible @return the Accessible if it exists at the specified location; else null
Returns an Accessible representing the specified selected item in the object. If there isn't a selection or there are fewer itemsselctedselected than the integer passed in the return value will be null. @param i the zero-based index of selected items @return an Accessible containing the selected item
Class JTree.DynamicUtilTreeNode, constructor JTree.DynamicUtilTreeNode(Object, Object)DynamicUtilTreeNode
can wrap vectors/hashtables/arrays/strings and create the appropriate children tree nodes as necessary. It is dynamic in that it'llwill only create the children as necessary.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Creates a node with the specified object as its value and with the specified children. For the node to allow children the children-object must be an array of objects aClass JTree.DynamicUtilTreeNode, void createChildren(DefaultMutableTreeNode, Object)Vector
or aHashtable
-- even if empty. Otherwise the node is not allowed to have children. @param value theObject
that is the value for the new node @param children an array ofObjectsObject
s aVector
or aHashtable
used to create the child nodes. If; if any other object is specified or if the value isnull
then the node is not allowed to have children.
Adds to parent all the children inClass JTree.DynamicUtilTreeNode, boolean isLeaf()children
. Ifchildren
is an array orVectorvector all of its elements are added is children otherwise ifchildren
is aHashtablehashtable all the key/value pairs are added in the orderEnumeration
returns them.
Returns true if this node allows children. Whether the node allows children depends on how it was created. @return true if this node allows children false otherwiseClass JTree.DynamicUtilTreeNode, void loadChildren().@see #JTree.DynamicUtilTreeNode#DynamicUtilTreeNode(Object Object)
Loads the children based onchildValue
. IfchildValue
is aVector
orarrayor array each element is added as a child ifchildValue
is aHashtable
each key/value pair is added in the order thatEnumeration
returns the keys.
Class JTree.EmptySelectionModel, void addSelectionPaths(TreePath[])EmptySelectionModel
is aTreeSelectionModel
that does not allow anything to be selected.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
A null
implementation that adds nothing.
Class JTree.EmptySelectionModel, void removeSelectionPaths(TreePath[])A null
implementation that removes nothing.
Class JTree.EmptySelectionModel, void setSelectionPaths(TreePath[])A null
implementation that selects nothing.
Class JTree.EmptySelectionModel, EmptySelectionModel sharedInstance()Returns a shared instance of an empty selection model.
Listens to the model and updates the expandedState
accordingly when nodes are removed or changed.
Handles creating a newClass JTree.TreeSelectionRedirector, void valueChanged(TreeSelectionEvent)TreeSelectionEvent
with theJTree
as the source and passing it off to all the listeners.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Invoked by theTreeSelectionModel
when the selection changes. @param e theTreeSelectionEvent
generated by theTreeSelectionModel
Returns aClass JTree, constructor JTree(Hashtable)JTree
with a sample model. The default model used by the tree defines a leaf node as any node without children. @return aJTree
with the default model which defines a leaf node as any node without children. @see DefaultTreeModel#asksAllowsChildren
Returns aClass JTree, constructor JTree(Object[])JTree
created from aHashtable
which does not displaythewith root. Each value-half of the key/value pairs in theHashTable
becomes a child of the new root node. By default the tree defines a leaf node as any node without children. @param value aHashtable
@return aJTree
with the contents of theHashtable
as children of the root node @see DefaultTreeModel#asksAllowsChildren
Returns aClass JTree, constructor JTree(TreeModel)JTree
with each element of the specified array as the child of a new root node which is not displayed. By default the tree defines a leaf node as any node without children. @param value an array ofObjectsObject
s @return aJTree
with the contents of the array as children of the root node @see DefaultTreeModel#asksAllowsChildren
Returns an instance ofClass JTree, constructor JTree(TreeNode)JTree
which displays the root node -- the tree is created using the specified data model. @param newModel theTreeModel
to use as the data model @return aJTree
based on theTreeModel
Returns aClass JTree, constructor JTree(TreeNode, boolean)JTree
with the specified TreeNode as its root which displays the root node. By default the tree defines a leaf node as any node without children. @param root aTreeNode
object @return aJTree
with the specified root node @see DefaultTreeModel#asksAllowsChildren
Returns aClass JTree, constructor JTree(Vector)JTree
with the specifiedTreeNode
as its root which displays the root node and which decides whether a node is a leaf node in the specified manner. @param root aTreeNode
object @param asksAllowsChildren if false any node without children is a leaf node. If; if true only nodes that do not allow children are leaf nodes.@return aJTree
with the specified root node @see DefaultTreeModel#asksAllowsChildren
Returns aClass JTree, void addSelectionInterval(int, int)JTree
with each element of the specifiedVector
as the child of a new root node which is not displayed. By default the tree defines a leaf node as any node without children. @param value aVector
@return aJTree
with the contents of theVector
as children of the root node @see DefaultTreeModel#asksAllowsChildren
Adds the paths between index0 and index1 inclusive to the selection. @param index0 anClass JTree, void addSelectionPath(TreePath)intinteger specifying a display row where 0 is the first row in the display @paramindex0index1 anintinteger specifying a second display row
Adds the node identified by the specifiedClass JTree, void addSelectionPaths(TreePath[])TreePath
to the current selection. If any component of the path isn't viewable andgetExpandsSelectedPaths
is true it is made viewable. @param path theTreePath
to add
Adds each path in the array of paths to the current selection. If any component of any of the paths isn't viewable andClass JTree, void addSelectionRow(int)getExpandsSelectedPaths
is true it is made viewable. @param paths an array ofTreePath
objects that specifies the nodes to add
Adds the path at the specified row to the current selection. @param row anClass JTree, void addTreeExpansionListener(TreeExpansionListener)intinteger specifying the row of the node to add where 0 is the first row in the display
Adds a listener for TreeExpansion
events. @param tel a TreeExpansionListener that will be notified when a tree node is expanded or collapsed (a "negative expansion")
Class JTree, void addTreeSelectionListener(TreeSelectionListener)Adds a listener forClass JTree, void addTreeWillExpandListener(TreeWillExpandListener)TreeSelection
events. @param tsl theTreeSelectionListener
that will be notified when a node is selected or deselected (a "negative selection")
Adds a listener forClass JTree, void clearToggledPaths()TreeWillExpand
events. @param tel aTreeWillExpandListener
that will be notified when a tree node will be expanded or collapsed (a "negative expansion")
Clears the cache of toggled tree paths. This does NOT send out any TreeExpansionListener
events.
Class JTree, void collapsePath(TreePath)Ensures that the node identified by the specified path is collapsed and viewable. @param path the TreePath
identifying a node
Class JTree, void collapseRow(int)Ensures that the node in the specified row is collapsed.Class JTree, String convertValueToText(Object, boolean, boolean, boolean, int, boolean)If
row
is <0 or >=getRowCount
this will have no effect. @param row anintinteger specifying a display row where 0 is the first row in the display
Called by the renderers to convert the specified value to text. This implementation returnsClass JTree, TreeModel createTreeModel(Object)value.toString
ignoring all other arguments. To control the conversion subclass this method and use any of the arguments you need. @param value the()Object
to convert to text @param selected true if the node is selected @param expanded true if the node is expanded @param leaf true if the node is a leaf node @param row anintinteger specifying the node's display row where 0 is the first row in the display @param hasFocus true if the node has the focus @return theString
representation of the node's value
Returns aClass JTree, TreeModelListener createTreeModelListener()TreeModel
wrapping the specified object. If the object is:then a new root node is created with each of the incoming objects as children. Otherwise a new root is created with the specified object as its value. @param value the
- an array of
ObjectsObject
s- a
Hashtable
or- a
Vector
Object
used as the foundation for theTreeModel
@return aTreeModel
wrapping the specified object
Creates and returns an instance ofClass JTree, void expandPath(TreePath)TreeModelHandler
. The returned object is responsible for updating the expanded state when theTreeModel
changes.For more information on what expanded state means see the JTree description above.
Ensures that the node identified by the specified path is expanded and viewable. @param path the TreePath
identifying a node
Class JTree, void expandRow(int)Ensures that the node in the specified row is expanded and viewable.Class JTree, void fireTreeCollapsed(TreePath)If
row
is <0 or >=getRowCount
this will have no effect. @param row anintinteger specifying a display row where 0 is the first row in the display
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. @param path the TreePath
indicating the node that was collapsed @see EventListenerList
Class JTree, void fireTreeExpanded(TreePath)Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. @param path the TreePath
indicating the node that was expanded @see EventListenerList
Class JTree, void fireTreeWillCollapse(TreePath)Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. @param path the TreePath
indicating the node that was expanded @see EventListenerList
Class JTree, void fireTreeWillExpand(TreePath)Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. @param path the TreePath
indicating the node that was expanded @see EventListenerList
Class JTree, void fireValueChanged(TreeSelectionEvent)Class JTree, AccessibleContext getAccessibleContext()NotifyNotifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. @param e theTreeSelectionEvent
generated by theTreeSelectionModel
when a node is selected or deselected @see EventListenerList
Class JTree, TreeCellEditor getCellEditor()GetGets the AccessibleContext associated with thisJComponentJTree. For JTrees the AccessibleContext takes the form of an AccessibleJTree. A new AccessibleJTree instance is created if necessary. @return an AccessibleJTree that serves as the AccessibleContext of thisJComponentJTree
Returns the editor used to edit entries in the tree. @return theClass JTree, TreeCellRenderer getCellRenderer()TreeCellEditor
in use ornull
if the tree cannot be edited
Returns the currentClass JTree, TreePath getClosestPathForLocation(int, int)TreeCellRenderer
that is rendering each cell. @return theTreeCellRenderer
that is rendering each cell
Returns the path to the node that is closest to x y. If no nodes are currently viewable or there is no model returnsClass JTree, int getClosestRowForLocation(int, int)null
otherwise it always returns a valid path. To test if the node is exactly at x y get the node's bounds and test x y against that. @param x anintinteger giving the number of pixels horizontally from the left edge of the display area minus any left margin @param y anintinteger giving the number of pixels vertically from the top of the display area minus any top margin @return theTreePath
for the node closest to that locationnull
if nothing is viewable or there is no model @see #getPathForLocation @see #getPathBounds
Returns the row to the node that is closest to x y. If no nodes are viewable or there is no model returns -1. Otherwise it always returns a valid row. To test if the returned object is exactly at x y get the bounds for the node at the returned row and test x y against that. @param x anClass JTree, TreeModel getDefaultTreeModel()intinteger giving the number of pixels horizontally from the left edge of the display area minus any left margin @param y anintinteger giving the number of pixels vertically from the top of the display area minus any top margin @return the row closest to the location -1 if nothing is viewable or there is no model @see #getRowForLocation @see #getRowBounds
Creates and returns a sampleClass JTree, Enumeration getDescendantToggledPaths(TreePath)TreeModel
. Used primarily for beanbuilders.to show something interesting. @return the defaultTreeModel
Returns anClass JTree, TreePath getEditingPath()Enumeration
ofTreePaths
that have been expanded that are descendants ofparent
.
Returns the path to the element that is currently being edited. @return the TreePath
for the node being edited
Class JTree, Enumeration getExpandedDescendants(TreePath)Returns anClass JTree, Object getLastSelectedPathComponent()Enumeration
of the descendants of the pathparent
that are currently expanded. Ifis not currently expanded this will return
pathparentnull
. If you expand/collapse nodes while iterating over the returnedEnumeration
this may not return all the expanded paths or may return paths that are no longer expanded. @param parent the path which is to be examined @return anEnumeration
of the descendents ofparent
ornull
ifparent
is not currently expanded
Returns the last path component in the first node of the current selection. @return the lastClass JTree, TreePath getLeadSelectionPath()Object
in the first selected node'sTreePath
ornull
if nothing is selected @see TreePath#getLastPathComponent
Returns the pathClass JTree, int getLeadSelectionRow()ofidentifiedthe last node addedastotheselectionlead. @returnthe TreePath of the last nodepathadded toidentified as theselection.lead
Returns the row indexClass JTree, int getMaxSelectionRow()of the last nodecorrespondingaddedto theselectionlead path. @return anintinteger giving the row index of thelast node added to theleadselectionpath where 0 is the first row in the display; or -1 ifleadPath
isnull
Class JTree, int getMinSelectionRow()GetsReturns the last selected row. @return anintinteger designating the last selected row where 0 is the first row in the display
Gets the first selected row. @return anClass JTree, TreeModel getModel()intinteger designating the first selected row where 0 is the first row in the display
Returns theClass JTree, TreePath[] getPathBetweenRows(int, int)TreeModel
that is providing the data. @return theTreeModel
that is providing the data
ReturnsClass JTree, Rectangle getPathBounds(TreePath)JTreePath
instances representing the path between index0 and index1 (including index1). Returnsnull
if there is no tree. @param index0 anintinteger specifying a display row where 0 is the first row in the display @paramindex0index1 anintinteger specifying a second display row @return an array ofTreePath
objects one for each node between index0 and index1 inclusive; ornull
if there is no tree
Returns theClass JTree, TreePath getPathForLocation(int, int)Rectangle
that the specified node will be drawn into. Returnsnull
if any component in the path is hidden (under a collapsed parent).Note:
This method returns a valid rectangle even if the specified node is not currently displayed. @param path theTreePath
identifying the node @return theRectangle
the node is drawn in ornull
Returns the path for the node at the specified location. @param x anClass JTree, TreePath getPathForRow(int)intinteger giving the number of pixels horizontally from the left edge of the display area minus any left margin @param y anintinteger giving the number of pixels vertically from the top of the display area minus any top margin @return theTreePath
for the node at that location
Returns the path for the specified row.Class JTree, Dimension getPreferredScrollableViewportSize()--Ifrow
is not visiblenull
is returned.-@param row anintinteger specifying a row @return theTreePath
to the specified nodenull
ifrow <0
orrow > getRowCount()
Returns the preferred display size of aClass JTree, Rectangle getRowBounds(int)JTree
. The height is determined fromgetVisibleRowCount
and the width is the current preferred width. @return aDimension
object containing the preferred size
Returns theClass JTree, int getRowForLocation(int, int)Rectangle
that the node at the specified row is drawn in. @param row the row to be drawn where 0 is the first row in the display @return theRectangle
the node is drawn in
Returns the row for the specified location. @param x anClass JTree, int getRowForPath(TreePath)intinteger giving the number of pixels horizontally from the left edge of the display area minus any left margin @param y anintinteger giving the number of pixels vertically from the top of the display area minus any top margin @return the row corresponding to the location or -1 if the location is not within the bounds of a displayed cell @see #getClosestRowForLocation
Returns the row that displays the node identified by the specified path. @param path theClass JTree, int getRowHeight()TreePath
identifying a node @return anintinteger specifying the display row where 0 is the first row in the display or -1 if any of the elements in path are hidden under a collapsed parent.
Returns the height of each row. If the returned value is less than or equal to 0 the height for each row is determined by the renderer. @param the height of each cell in pixelsClass JTree, int getScrollableBlockIncrement(Rectangle, int, int). Zero; zero or negative if the height of each row is determined by the tree cell renderer
Returns the amount for a blockClass JTree, int getScrollableUnitIncrement(Rectangle, int, int)inrecmentincrement which is the height or width ofvisibleRect
based onorientation
. @param visibleRectThethe view area visible within the viewport @param orientationEithereitherSwingConstants.VERTICAL
orSwingConstants.HORIZONTAL
@param direction.Lessless than zero to scroll up/left greater than zero for down/right. @returnThethe "block" increment for scrolling in the specified direction.@see JScrollBar#setBlockIncrement(int)
Returns the amount to increment when scrolling. The amount is the height of the first displayed row that isn't completely in view or if it is totally displayed the height of the next row in the scrolling direction. @param visibleRectClass JTree, boolean getScrollsOnExpand()Thethe view area visible within the viewport @param orientationEithereitherSwingConstants.VERTICAL
orSwingConstants.HORIZONTAL
@param direction.Lessless than zero to scroll up/left greater than zero for down/right.@returnThethe "unit" increment for scrolling in the specified direction @see JScrollBar#setUnitIncrement(int)
Returns true if the tree scrolls to show previously hidden children. @return true if when a node is expanded as many of the descendants as possible are scrolled to be visibleClass JTree, TreeSelectionModel getSelectionModel().
Returns the model for selections. This should always return a non-Class JTree, TreePath getSelectionPath()null
value. If you don't want to allow anything to be selected set the selection model tonull
which forces an empty selection model to be used. @param theTreeSelectionModel
in use @see #setSelectionModel
Returns the path to the first selected node. @return theClass JTree, TreePath[] getSelectionPaths()TreePath
for the first selected node ornull
if nothing is currently selected
Returns the paths of all selected values. @return an array ofClass JTree, int[] getSelectionRows()TreePath
objects indicating the selected nodes ornull
if nothing is currently selected.
Returns all of the currently selected rows. This method is simply forwarded to theClass JTree, String getToolTipText(MouseEvent)TreeSelectionModel
. If nothing is selectednull
or an empty arraywithwill be returned based on theTreeSelectionModel
implementation. @return an array ofintsintegers that identifies all currently selected rows where 0 is the first row in the display
OverridesClass JTree, String getUIClassID()JComponent
'sgetToolTipText
method in order to allow renderer's tips to be used if it has text set.NOTE: For
JTree
to properly display tooltips of its renderersJTree
must be a registered component with theToolTipManager
. This can be done by invokingToolTipManager.sharedInstance().registerComponent(tree)
. This is not doneautomaticlyautomatically @param event theMouseEvent
that initiated theToolTip
display @return a string containing the tooltip ornull
ifevent
is null
Returns the name of the L&F class that renders this component. @return the string "TreeUI" @see JComponent#getUIClassID @see UIDefaults#getUIClass JTree, boolean hasBeenExpanded(TreePath)
Returns true if the node identified by the path has ever been expanded. @return true if the path
has ever been expanded
Class JTree, boolean isCollapsed(TreePath)Returns true if the value identified by path is currently collapsed this will return false if any of the values in path are currently not being displayed. @param path the TreePath
to check @return true if any of the nodes in the node's path are collapsed false if all nodes in the path are expanded
Class JTree, boolean isEditable()Returns true if the tree is editable. @return true if the tree is editableClass JTree, boolean isExpanded(TreePath).
Returns true if the node identified by the path is currently expanded @param path the TreePath
specifying the node to check @return false if any of the nodes in the node's path are collapsed true if all nodes in the path are expanded
Class JTree, boolean isPathSelected(TreePath)Returns true if the item identified by the path is currently selected. @param path a TreePath
identifying a node @return true if the node is selected
Class JTree, boolean isRowSelected(int)Returns true if the node identitifed by row is selected. @param row anClass JTree, boolean isVisible(TreePath)intinteger specifying a display row where 0 is the first row in the display @return true if the node is selected
Returns true if the value identified by path is currently viewable which means it is either the root or all of its parents areClass JTree, void makeVisible(TreePath)exapndedexpanded. Otherwise this method returns false. @return true if the node is viewable otherwise false
Ensures that the node identified by path is currently viewable. @param path the TreePath
to make visible
Class JTree, String paramString()Returns a string representation of thisClass JTree, void removeDescendantToggledPaths(Enumeration)JTree
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJTree
.
Removes any descendants of theClass JTree, void removeSelectionInterval(int, int)TreePaths
intoRemove
that have been expanded.
Removes the nodes between index0 and index1 inclusive from the selection. @param index0 anClass JTree, void removeSelectionPath(TreePath)intinteger specifying a display row where 0 is the first row in the display @paramindex0index1 anintinteger specifying a second display row
Removes the node identified by the specified path from the current selection. @param path the TreePath
identifying a node
Class JTree, void removeSelectionPaths(TreePath[])Removes the nodes identified by the specified paths from the current selection. @param paths an array of TreePath
objects that specifies the nodes to remove
Class JTree, void removeTreeExpansionListener(TreeExpansionListener)Removes a listener forClass JTree, void removeTreeSelectionListener(TreeSelectionListener)TreeExpansion
events. @param tel theTreeExpansionListener
to remove
Removes aClass JTree, void removeTreeWillExpandListener(TreeWillExpandListener)TreeSelection
listener. @param tsl theTreeSelectionListener
to remove
Removes a listener forClass JTree, void scrollPathToVisible(TreePath)TreeWillExpand
events. @param tel theTreeWillExpandListener
to remove
Makes sure all the path components in path are expanded (except for the last path component) and scrolls so that the node identified by the path is displayed. Only works when thisClass JTree, void scrollRowToVisible(int)JTree
is contained in aJSrollPaneJScrollPane
. @param path theTreePath
identifying the node to bring into view
Scrolls the item identified by row until it is displayed. The minimum of amount of scrolling necessary to bring the row into view is performed. Only works when thisClass JTree, void setCellEditor(TreeCellEditor)JTree
is contained in aJSrollPaneJScrollPane
. @param row anintinteger specifying the row to scroll where 0 is the first row in the display
Sets the cell editor. AClass JTree, void setCellRenderer(TreeCellRenderer)null
value implies that the tree cannot be edited. If this represents a change in thecellEditor
thepropertyChange
method is invoked on all listeners. @param cellEditor theTreeCellEditor
to use @beaninfo bound: true description: The cell editor. A null value implies the tree cannot be edited.
Sets theClass JTree, void setExpandedState(TreePath, boolean)TreeCellRenderer
that will be used to draw each cell. @param x theTreeCellRenderer
that is to render each cell @beaninfo bound: true description: The TreeCellRenderer that will be used to draw each cell.
Sets the expanded state ofClass JTree, void setInvokesStopCellEditing(boolean)thethisreceiverJTree
. Ifstate
is true all parents ofpath
and path are marked as expanded. Ifstate
is false all parents ofpath
are marked EXPANDED butpath
itself is marked collapsed.This will fail if a
TreeWillExpandListener
vetos it.
Determines what happens when editing is interrupted by selecting another node in the tree a change in the tree's data or by some other means. Setting this property toClass JTree, void setModel(TreeModel)true
causes the changes to be automatically saved when editing is interrupted.Fires a property change for the INVOKES_STOP_CELL_EDITING_PROPERTY. @param newValue true means that
stopCellEditing
is invoked when editing is interruped and data is saved. False; false means thatcancelCellEditing
is invoked and changes are lost.@beaninfo bound: true description: Determines what happens when editing is interrupted selecting another node in the tree a change in the tree's data or some other means.
Sets theClass JTree, void setRootVisible(boolean)TreeModel
that will provide the data. @param newModel theTreeModel
that is to provide the data @beaninfo bound: true description: The TreeModel that will provide the data.
Determines whether or not the root node from the TreeModel
is visible. @param rootVisible true if the root node of the tree is to be displayed @see #rootVisible @beaninfo bound: true description: Whether or not the root node from the TreeModel is visible.
Class JTree, void setRowHeight(int)Sets the height of each cell in pixels. If the specified value is less than or equal to zero the current cell renderer is queried for each row's height. @param rowHeight the height of each cell in pixels @beaninfo bound: true description: The height of each cell.Class JTree, void setScrollsOnExpand(boolean)
Determines whether or not when a node is expanded as many of the descendants are scrolled to be inside the viewport as possible. The default is true. @beaninfo bound: true description: Indicates if a node descendent should be scrolled when expanded.Class JTree, void setSelectionInterval(int, int)
Selects the nodes between index0 and index1 inclusive. @param index0 anClass JTree, void setSelectionModel(TreeSelectionModel)intinteger specifying a display row where 0 is the first row in the display @paramindex0index1 anintinteger specifying a second display row
Sets the tree's selection model. When aClass JTree, void setSelectionPath(TreePath)null
value is specified anemptyemtpyelectionModelselectionModel
is used which does not allow selections. @param selectionModel theTreeSelectionModel
to use ornull
to disable selections @see TreeSelectionModel @beaninfo bound: true description: The tree's selection model.
Selects the node identified by the specified path. If any component of the path is hidden (under a collapsed node) andClass JTree, void setSelectionPaths(TreePath[])getExpandsSelectedPaths
is true it is exposed (made viewable). @param path theTreePath
specifying the node to select
Selects the nodes identified by the specified array of paths. If any component in any of the paths is hidden (under a collapsed node) andClass JTree, void setSelectionRows(int[])getExpandsSelectedPaths
is true it is exposed (made viewable). @param paths an array ofTreePath
objects that specifies the nodes to select
Selects the nodes corresponding to each of the specified rows in the display. If a particular element ofClass JTree, void setVisibleRowCount(int)rows
is <0 or >=getRowCount
it will be ignored. If none of the elements inrows
are valid rows the selection will be cleared. That is it will be as ifclearSelection
was invoked. @param rows an array of ints specifying the rows to select where 0 indicates the first row in the display
Sets the number of rows that are to be displayed. This will only work if the reciever is contained in a JScrollPane
and will adjust the preferred size and size of that scrollpane. @param newCount the number of rows to display @beaninfo bound: true description: The number of rows that are to be displayed.
Class JTree, void startEditingAtPath(TreePath)Selects the node identified by the specified path and initiates editing. The edit-attempt fails if theClass JTree, boolean stopEditing()CellEditor
does not allow editing for the specified item. @param path theTreePath
identifying a node
Ends the current editing session. (TheClass JTree, void updateUI()DefaultTreeCellEditor
object saves any edits that are currently in progress on a cell. Other implementations may operate differently.) Has no effect if the tree isn't being edited.Note:@return true if editing was in progress and is now stopped false if editing was not in progress
To make edit-saves automatic whenever the user changes their position in the tree use #setInvokesStopCellEditing
Notification from theClass JTree, String CELL_EDITOR_PROPERTYUIManager
that the L&F has changed. Replaces the current UI object with the latest version from theUIManager
. @see JComponent#updateUI
Bound property name for cellEditor
.
Class JTree, String CELL_RENDERER_PROPERTYBound property name for cellRenderer
.
Class JTree, String EDITABLE_PROPERTYBound property name for editable
.
Class JTree, String INVOKES_STOP_CELL_EDITING_PROPERTYBound property name for messagesStopCellEditing
.
Class JTree, String LARGE_MODEL_PROPERTYBound property name for largeModel
.
Class JTree, String ROOT_VISIBLE_PROPERTYBound property name for rootVisible
.
Class JTree, String ROW_HEIGHT_PROPERTYBound property name for rowHeight
.
Class JTree, String SCROLLS_ON_EXPAND_PROPERTYBound property name for scrollsOnExpand
.
Class JTree, String SHOWS_ROOT_HANDLES_PROPERTYBound property name for showsRootHandles
.
Class JTree, String TREE_MODEL_PROPERTYBound property name for treeModel
.
Class JTree, String VISIBLE_ROW_COUNT_PROPERTYBound property name for visibleRowCount
.
Class JTree, TreeCellEditor cellEditorEditor for the entries. Default is null
(tree is not editable).
Class JTree, TreeCellRenderer cellRendererThe cell used to draw nodes. IfClass JTree, boolean invokesStopCellEditingnull
the UI uses a defaultcellRenderer
.
If true when editing is to be stopped by way of selection changing data in tree changing or other meansClass JTree, TreeSelectionRedirector selectionRedirectorstopCellEditing
is invoked and changes are saved. If falsecancelCellEditing
is invoked and changes are discarded. Default is false.
Creates a new event and passed it off the selectionListeners
.
Class JTree, TreeModelListener treeModelListenerUpdates the expandedState
.
Class JTree, int visibleRowCountNumber of rows to make visible at one time. This value is used for the Scrollable
interface. It determines the preferred size of the display area.
The "viewport" or "porthole" through which you see the underlying information. When you scroll what moves is the viewport.ItsIt is like peering through a camera's viewfinder. Moving the viewfinder upwards brings new things into view at the top of the picture and loses things that were at the bottom.By default
JViewport
is opaque. To change this use thesetOpaque
method.NOTE:We have implemented a faster scrolling algorithm that does not require a buffer to draw in. The algorithm works as follows:
In general this approach is much faster. Compared to the backing store approach this avoids the overhead of maintaining an offscreen buffer and having to do two
- The view and parent view and checked to see if they are
JComponents
if they aren't stop and repaint the whole viewport.- If the viewport is obscured by an ancestor stop and repaint the whole viewport.
- Compute the region that will become visible if it is as big as the viewport stop and repaint the whole view region.
- Obtain the ancestor Windows graphics and do a
copyArea
on the scrolled region.- Message the view to repaint the newly visible region.
- The next time paint is invoked on the viewport if the clip region is smaller than the viewport size a timer is kicked off to repaint the whole region.
copyAreascopyArea
s. Compared to the non backing store case this approach will greatly reduce the painted region.This approach can cause slower times than the backing store approach when the viewport is obscured by another window or partially offscreen. When another window obscures the viewport the copyArea will copy garbage and a paint event will be generated by the system to inform us we need to paint the newly exposed region. The only way to handle this is to repaint the whole viewport which can cause slower performance than the backing store case. In most applications very rarely will the user be scrolling while the viewport is obscured by another window or offscreen so this optimization is usually worth the performance hit when obscured.
To turn this behavior on put the client property "EnableWindowBlit" (a method will added to enable/disable this in the future).Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.63 0484 03/2214/9900 @author Hans Muller @author Philip Milne @see JScrollPane
TheThis classusedimplementstoaccessibility supportobtainfor theaccessibleJViewport
class.role forIt providesthisan implementation of the Java Accessibility API appropriate to viewport user-interfaceobjectelements.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Class JViewport, void addChangeListener(ChangeListener)CreateCreates aJViewport
.
Class JViewport, void addImpl(Component, Object, int)AddAdds aChangeListener
to the list that'sis notified each time the view's size position or the viewport's extent size has changed. @param l theChangeListener
to add @see #removeChangeListener @see #setViewPosition @see #setViewSize @see #setExtentSize
Sets theClass JViewport, boolean computeBlit(int, int, Point, Point, Dimension, Rectangle)Viewport'JViewport
s one lightweight child which can benull
. (Since there is only one child which occupies the entire viewport the constraints and index arguments are ignored.) @param child theComponentlightweightchild
of______________the viewport @param constraints theObjectconstraints
to be______________respected @param index theint ______________index @see #setView
Computes the parameters for a blit where the backing store image currently containsClass JViewport, LayoutManager createLayoutManager()oldLoc
in the upper left hand corner and we're scrolling tonewLoc
. The parameters are modified to return the values required for the blit. @param dx the horizontal delta @param dy the vertical delta @param blitFrom thePoint
we're blitting from @param blitTo thePoint
we're blitting to @param blitSize theDimension
of the area to blit @param blitPaint the area to blit @return true if the parameters are modified and we're ready to blit; false otherwise
Subclassers can override this to install a different layout manager (orClass JViewport, ViewListener createViewListener()null
) in the constructor. Returns a newJViewportLayoutViewportLayout
object. @return aLayoutManager
Class JViewport, void firePropertyChange(String, Object, Object)CreateCreates a listener for the view. @return aViewListener
Notifies listeners of a property change. This is subclassed to update theClass JViewport, AccessibleContext getAccessibleContext()windowBlit
ivarproperty. (TheputClientProperty property is final). @param propertyName a string containing the property name @param oldValue the old value of the property @param newValue the new value of the property
Class JViewport, Dimension getExtentSize()GetGets the AccessibleContext associated with thisJComponentJViewport. For viewports the AccessibleContext takes the form of an AccessibleJViewport. A new AccessibleJViewport instance is created if necessary. @return an AccessibleJViewport that serves as the AccessibleContext of thisJComponentJViewport
Returns the size of the visible part of the view in view coordinates. @return a Dimension
object giving the size of the view
Class JViewport, Insets getInsets()Returns the insets (border) dimensions as (0 0 0 0) since borders are not supported on aClass JViewport, Insets getInsets(Insets)JViewport
. @returnnewaInsets(0Rectange
0 0of zero0)dimension and zero origin @see #setBorder
Returns anClass JViewport, String getUIClassID()Insets
object containing thisJViewport
s inset values. The passed-in'Insets
object will be reinitialized and all existing values within this object are overwritten. @param insets theInsets
object which can be reused.@return this viewports inset values @see #getInsets @beaninfo expert: true
Class JViewport, Component getView()ReturnReturnsthe UIDefaults key usedato look upstring that specifies the name of theswing.plaf.ComponentUIL&F class thatdefines the look and feelrendersforthis component.Most applications will never need to call this method. Subclasses of JComponent that support pluggable look and feel should override this method to@returna UIDefaults key that maps totheComponentUI subclass that defines their look andstringfeel."ViewportUI" @return The UIDefaults key for a ComponentUIseesubclass.JComponent#getUIClassID @see UIDefaults#getUI@beaninfo expert: true description: UIClassID
Returns theClass JViewport, Point getViewPosition()Viewport'JViewport
s one child ornull
. @return the viewports child ornull
if none exists @see #setView
Returns the view coordinates that appear in the upper left hand corner of the viewport or 0 0 if there's no view. @return a Point
object giving the upper left coordinates
Class JViewport, Rectangle getViewRect()Class JViewport, Dimension getViewSize()ReturnReturns a rectangle whose origin isgetViewPosition
and size isgetExtentSize
. This is the visible part of the view in view coordinates. @return a()Rectangle
giving the visible part of the view using view coordinates.
If the view's size hasn't been explicitly set return the preferred size otherwise return the view's current size. If there is no view return 0 0. @return a Dimension
object specifying the size of the view
Class JViewport, boolean isBackingStoreEnabled()Returns true if this viewport is maintaining an offscreen image of its contents. @return true ifClass JViewport, boolean isOptimizedDrawingEnabled()scrollMode
is BACKINGSTORE_SCROLL_MODE @deprecated As of Java 2 platform v1.3 replaced bygetScrollMode()
.
TheClass JViewport, void paint(Graphics)JViewport
overrides the default implementation of this method (inJComponent
) to return false. This ensures that the drawing machinery will call theViewport
s'paint
implementation rather than messaging the()JViewport
s children directly. @return false'
Depending on whether theClass JViewport, String paramString()backingStore
is enabled either paint the image through the backing store or paint just the recently exposed part using the backing store to "blit" the remainder.The term "blit" is the pronounced version of the PDP-10 BLT (BLock Transfer) instruction which copied a block of bits. (In case you were curious.)@param g theGraphics
context within which to paint
Returns a string representation of thisClass JViewport, void remove(Component)JViewport
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJViewport
.
Removes the Viewport'
s one lightweight child. @see #setView
Class JViewport, void removeChangeListener(ChangeListener)Class JViewport, void repaint(long, int, int, int, int)RemoveRemoves aChangeListener
from the list that's notified each time the views size position or the viewports extent size has changed. @param l theChangeListener
to remove @see #addChangeListener
Class JViewport, void reshape(int, int, int, int)WeAlwaysalwaysrepaint inour parentthe parents coordinate system to make sure only one paint is performed by theRepaintManager
. @param tm maximum time in milliseconds before update @param x thex
coordinate (pixels over from left) @param y they
coordinate (pixels down from top) @param width the width @param height the height @see java.awt.Component#update(java.awt.Graphics)
Sets the bounds of this viewport. If the viewports width or height has changed fire a StateChanged
event. @param x left edge of the origin @param y top edge of the origin @param w width in pixels @param h height in pixels @see JComponent#reshape(int int int int)
Class JViewport, void scrollRectToVisible(Rectangle)Overridden to scroll the view so thatClass JViewport, void setBackingStoreEnabled(boolean)Rectangle
within the view becomes visible. @param contentRect theRectangle
to display
If true if this viewport will maintain an offscreen image of its contents. The image is used to reduce the cost of small one dimensional changes to theClass JViewport, void setBorder(Border)viewPosition
. Rather than repainting the entire viewport we useGraphics.copyArea()
to effect some of the scroll. @param enabled if true maintain an offscreen backing store @deprecated As of Java 2 platform v1.3 replaced bysetScrollMode()
.
The viewport "scrolls" it's child (called the "view") by the normal parent/child clipping (typically the view is moved in the opposite direction of the scroll). A non-Class JViewport, void setExtentSize(Dimension)null
border or non-zero insets isn't supported to prevent the geometry of this component from becoming complex enough to inhibit subclassing. To create aJViewport
with a border add it to aJPanel
that has a border.Note: If
border
is non-null
this method will throw an exception as borders are not supported on aJViewPort
. @param border theBorder
to set @exception IllegalArgumentException this method is not implemented
Class JViewport, void setView(Component)SetSets the size of the visible part of the view using view coordinates. @param newExtent aDimension
object specifying the size of the view
Sets theClass JViewport, void setViewPosition(Point)Viewport'JViewport
s one lightweight child (view
) which can benull
. @param view the viewports new lightweight child @see #getView
Sets the view coordinates that appear in the upper left hand corner of the viewport does nothing if there's no view. @param p a Point
object giving the upper left coordinates
Class JViewport, void setViewSize(Dimension)Sets the view coordinates that appear in the upper left hand corner of the viewport and the size of the view. @param newSize aClass JViewport, Dimension toViewCoordinates(Dimension)Dimension
object specifying the size and location of the new view coordinates ornull
if there is no view
Class JViewport, Point toViewCoordinates(Point)ConvertConverts a size in pixel coordinates to view coordinates. Subclasses of viewport that support "logical coordinates" will override this method. @param size aDimension
object using pixel coordinates @return aDimension
object converted to view coordinates
Class JViewport, void updateUI()ConvertConverts a point in pixel coordinates to view coordinates. Subclasses of viewport that support "logical coordinates" will override this method. @param p aPoint
object using pixel coordinates @return aPoint
object converted to view coordinates
Class JViewport, boolean backingStoreResetsNotificationthe UI property to a valuefrom thecurrent look and feel. JComponent subclasses must override this method likeUIFactory
this:thatpublic voidtheupdateUI()L&F{hassetUI((SliderUI)UIManagerchanged.getUI(this); } @see#setUI @see UIManager#getLookAndFeel@seeUIManagerJComponent#getUIupdateUI
True when this viewport is maintaining an offscreen image of its contents so that some scrolling can take place using fast "bit-blit" operations instead of by accessing the view object to construct the display. The default is false. @deprecated As of Java 2 platform v1.3 @see #setScrollModeClass JViewport, boolean isViewSizeSet
True when the viewport dimensions have been determined. The default is false.Class JViewport, Point lastPaintPosition
The last viewPosition
that we've painted so we know how much of the backing store image is valid.
Class JViewport, boolean scrollUnderwayThescrollUnderway
flag is used for components likeJList
. When the downarrow key is pressed on aJList
and the selected cell is the last in the list thescrollpane
autoscrolls. Here the old selected cell needs repainting and so we need a flag to make the viewport do theoptimisedoptimized painting only when there is an explicit call tosetViewPosition(Point)
. WhensetBounds
is called through other routes the flag is off and the view repaints normally. Another approach would be to remove this from the()ViewportJViewport
class and have theJList
manage this case by usingsetBackingStoreEnabled
. The default is false.()
AJWindow
is a container that can be displayed anywhere on the user's desktop. It does not have the title bar window-management buttons or other trimmings associated with aJFrame
but it is still a "first-class citizen" of the user's desktop and can exist anywhere on it.The
JWindow
component contains aJRootPane
as it's only child. ThecontentPane
should be the parent of any children of the()JWindow
. From the olderjava.awt.Window
object you would normally do something like this:window.add(child);
However usingJWindow
you would code: window.getContentPane().add(child); The same is true of settingLayoutManagersLayoutManager
s removing components listing children etc. All these methods should normally be sent to thecontentPane
instead of the()JWindow
itself. ThecontentPane
will always be non-()null
. Attempting to set it tonull
will cause theJWindow
to throw an exception. The defaultcontentPane
will have a()BorderLayout
manager set on it.Please see the JRootPane documentation for a complete description of the
contentPane
()glassPane
and()layeredPane
components.()In a multi-screen environment you can create a
JWindow
on a different screen device. See java.awt.Window for more information.For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions see the JWindow key assignments.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JRootPane @beaninfo attribute: isContainer true attribute: containerDelegate getContentPane description: A toplevel window which has no system border or controls. @version 1.
27 0435 01/2221/9901 @author David Kloba
Class JWindow.AccessibleJWindow, AccessibleComponent getAccessibleComponent()TheThis classusedimplementstoaccessibility supportobtainfor theAccessibleRoleJWindow
forclass. It provides an implementation of the Java Accessibility API appropriate to windowthisuser-interfaceobjectelements.
Get the AccessibleComponent associated with this object if one exists. Otherwise return null. @return the componentClass JWindow.AccessibleJWindow, void setBackground(Color)
Set the background color of this object. (For transparency see isOpaque
.) @param c the new Color for the background @see Component#isOpaque
Class JWindow.AccessibleJWindow, void setLocation(Point)Sets the location of the object relative to the parent.@param p the Point object specifying the location of the object's upper left corner
Creates a window with the specified owner frame. IfClass JWindow, constructor JWindow(Window)owner
isnull
the shared owner will be used. @param owner the frame from which the window is displayed
Creates a window with the owner and the specifiedClass JWindow, void addImpl(Component, Object, int)ownerGraphicsConfiguration
windowof a screen device. @param owner the windowfromto act as owner @paramwhichgc thewindowGraphicsConfiguration
that is used to construct the newWindow
; ifgc
isnull
the system defaultGraphicsConfiguration
is assumed @exception IllegalArgumentException ifgc
is not from a screen device. @exception IllegalArgumentException if owner isdisplayednull
@since 1.3
By default children may not be added directly to a this component they must be added to itsClass JWindow, JRootPane createRootPane()contentPane
instead. For example:thisComponent.getContentPane().add(child)An attempt to add to directly to this component will cause an runtime exception to be thrown. Subclasses can disable this behavior. @param comp the component to be enhanced @param constraints the constraints to be enforced on the component @param index the index of the component @see #setRootPaneCheckingEnabled @exception Error if called withrootPaneChecking
true
Called by the constructor methods to create the default rootPane
.
Class JWindow, AccessibleContext getAccessibleContext()Class JWindow, Container getContentPane()GetGets the AccessibleContext associated with this JWindow. For JWindows the AccessibleContext takes the form of an AccessibleJWindow. A new AccessibleJWindow instance is created if necessary. @return an AccessibleJWindow that serves as the AccessibleContext of this JWindow
Returns theClass JWindow, Component getGlassPane()contentPaneContainer
which is theobjectcontentPane
for this window. @return theContainer which is thecontentPane
property @see #setContentPane @see RootPaneContainer#getContentPane
Returns theClass JWindow, JLayeredPane getLayeredPane()glassPane
for this window. @return theobjectComponentComponent which is theglassPane
property @see #setGlassPane @see RootPaneContainer#getGlassPane
Returns theClass JWindow, JRootPane getRootPane()layeredPane
object for this window. @return theJLayeredPanelayeredPane
objectproperty @see #setLayeredPane @see RootPaneContainer#getLayeredPane
Returns theClass JWindow, boolean isRootPaneCheckingEnabled()rootPane
object for this window. @return therootPane
property for this window @see #setRootPane @see RootPaneContainer#getRootPane
Returns whether calls toClass JWindow, String paramString()add
andsetLayout
will cause an exception to be thrown. @return true ifadd
andsetLayout
are checked @see #addImpl @see #setLayout @see #setRootPaneCheckingEnabled
Returns a string representation of thisClass JWindow, void setContentPane(Container)JWindow
. This method is intended to be used only for debugging purposes and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. @return a string representation of thisJWindow
.
Sets theClass JWindow, void setGlassPane(Component)contentPane
property for this window. This method is called by the constructor. @param contentPane thecontentPane objectnewfor this windowcontentPane
@exceptionjava.awt.IllegalComponentStateException (a runtime exception) if the content pane parameter isnull
@see #getContentPane @see RootPaneContainer#setContentPane @beaninfo hidden: true description: The client area of the window where child components are normally inserted.
Sets theClass JWindow, void setLayeredPane(JLayeredPane)glassPane
property. This method is called by the constructor. @param glassPane theglassPane
object for this window @see #getGlassPane @see RootPaneContainer#setGlassPane @beaninfo hidden: true description: A transparent pane used for menu rendering.
Sets theClass JWindow, void setLayout(LayoutManager)layeredPane
property. This method is called by the constructor. @param layeredPane the newlayeredPane object
for this window@exceptionjava.awt.IllegalComponentStateException (a runtime exception) if the content pane parameter isnull
@see #getLayeredPane @see RootPaneContainer#setLayeredPane @beaninfo hidden: true description: The pane which holds the various window layers.
By default the layout of this component may not be set the layout of its contentPane should be set instead. For example:Class JWindow, void setRootPane(JRootPane)thisComponent.getContentPane().setLayout(new BorderLayout())An attempt to set the layout of this component will cause an runtime exception to be thrown. Subclasses can disable this behavior. @param manager the layout manager for the window @see #setRootPaneCheckingEnabled @exception Error if called withrootPaneChecking
true
Sets the newClass JWindow, void setRootPaneCheckingEnabled(boolean)rootPane
propertyobject for this window. This method is called by the constructor. @param root therootPane object fornewthisrootPane
windowproperty @see #getRootPane @beaninfo hidden: true description: the RootPane object for this window.
Determines whether calls toClass JWindow, void windowInit()add
andsetLayout
will cause an exception to be thrown. @param enabled a boolean value true if checking is to be enabled which cause the exceptions to be thrown @see #addImpl @see #setLayout @see #isRootPaneCheckingEnabled @beaninfo hidden: true description: Whether the add and setLayout methods throw exceptions when invoked.
Called by the constructors to init the JWindow
properly.
Class JWindow, AccessibleContext accessibleContextThe accessible context property.Class JWindow, JRootPane rootPane
TheClass JWindow, boolean rootPaneCheckingEnabledJRootPane
instance that manages thecontentPane
and optionalmenuBar
for this frame as well as theglassPane
. @see #getRootPane @see #setRootPane
If true then calls toadd
andsetLayout
will cause an exception to be thrown. @see #isRootPaneCheckingEnabled @see #setRootPaneCheckingEnabled
A KeyStroke instance represents a key being typed on the keyboard -- it contains both a char code for the key and a modifier (alt shift ctrl meta or a combination).Class KeyStroke, KeyStroke getKeyStroke(char)KeyStroke objects are used to define high-level (semantic) action events. Instead of trapping every keystroke and throwing away the ones you are not interested in those keystrokes you care about automatically initiate actions on the components they are registered with.
KeyStroke objects handle both character-code generating keystrokes you would trap with a KeyTyped event handler and key-code generating keystrokes (like Enter or F1) that you would trap with a KeyPressed event handler.
KeyStroke objects are immutable and unique.
All KeyStroke objects are cached. To get one use
getKeyStroke
.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see
JComponent#registerKeyboardActionjavax.swing.text.Keymap @see #getKeyStroke @version 1.31 1137 02/1002/9800 @author Arnaud Weber
Return a shared instance of a key stroke that is activated when the key is pressed (i.e.that is a KeyStroke for theKeyEvent.KEY_TYPED event). @param keyChar the character value for a keyboard key @return a KeyStroke object for that key
Identifies components that can be used as "rubber stamps" to paint the cells in a JList. For example to use a JLabel as a ListCellRenderer you would write something like this:class MyCellRenderer extends JLabel implements ListCellRenderer { public MyCellRenderer() { setOpaque(true); } public Component getListCellRendererComponent( JList list Object value int index boolean isSelected boolean cellHasFocus) { setText(value.toString()); setBackground(isSelected Color.red : Color.white); setForeground(isSelected Color.white : Color.black); return this; } }@see JList @see DefaultListCellRenderer @version 1.12 0814 02/2602/9800 @author Hans Muller
This interface represents the current state of the selection for any of the components that display a list of values with stable indices. The selection is modeled as a set of intervals each interval represents a contiguous range of selected list elements. The methods for modifying the set of selected intervals all take a pair of indices index0 and index1 that represent a closed interval i.e. the interval includes both index0 and index1. @version 1.15 1017 02/2102/9800 @author Hans Muller @author Philip Milne @see DefaultListSelectionModel
Completely characterizes a look and feel from the point of view of the pluggable look and feel components. @version 1.Class LookAndFeel, KeyBinding[] makeKeyBindings(Object[])18 0824 02/2602/9800 @author Tom Ball @author Hans Muller
Convenience method for building lists of KeyBindings.Return an array of KeyBindings one for each KeyStroke Action pair in keyBindingList. A KeyStroke can either be a string in the format specified by the
privatemethod or a KeyStroke object.
parseKeyStrokeKeyStroke.getKeyStrokeActions are strings. Here's an example:
JTextComponent.KeyBinding[] multilineBindings = makeKeyBindings( new Object[] { "UP" DefaultEditorKit.upAction "DOWN" DefaultEditorKit.downAction "PAGE_UP" DefaultEditorKit.pageUpAction "PAGE_DOWN" DefaultEditorKit.pageDownAction "ENTER" DefaultEditorKit.insertBreakAction "TAB" DefaultEditorKit.insertTabAction });@param keyBindingList an array of KeyStroke Action pairs @return an array of KeyBindings
Any component that can be placed into a menu should implement this interface. This interface is used by MenuSelection to handle selection and navigation in menu hierarchies. @version 1.6 088 02/2602/9800 @author Arnaud Weber
A MenuSelectionManager owns the selection in menu hierarchy. @version 1.20 1123 02/2002/9800 @author Arnaud Weber
A mutable version ofClass MutableComboBoxModel, void addElement(Object)ComboBoxModel
. @version 1.5 088 02/2602/9800 @author Tom Santos
Adds an item to the end of the model. @param obj the Object
to be added
Class MutableComboBoxModel, void insertElementAt(Object, int)Adds an item at a specific index @param obj the Object
to be added @param index location to add the object
Class MutableComboBoxModel, void removeElement(Object)Class MutableComboBoxModel, void removeElementAt(int)AddsRemoves an itemtofrom theendmodel. @paramofobj themodel.Object
to be removed
Removes an item at a specific index @param index location of object to be removed
A layout manager to arrange components over the top of each other. The requested size of the container will be the largest requested size of the children taking alignment needs into consideration. The alignment is based upon what is needed to properly fit the children in the allocation area. The children will be placed such that their alignment points are all on top of each other.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
17 0819 02/2802/9800 @author Timothy Prinzing
A class to monitor the progress of some operation. If it looks likeClass ProgressMonitor, constructor ProgressMonitor(Component, Object, String, int, int)itthe operation will take a while a progress dialog will be popped up. When the ProgressMonitor is created it is given a numeric range and a descriptive string. As the operation progresses call the setProgress method to indicate how far along the [min max] range the operation is. Initially there is no ProgressDialog. After the first millisToDecideToPopup milliseconds (default 500) the progress monitor will predict how long the operation will take. If it is longer than millisToPopup (default 2000 2 seconds) a ProgressDialog will be popped up.From time to time when the Dialog box is visible the progress bar will be updated when setProgress is called. setProgress won't always update the progress bar it will only be done if the amount of progress is visibly significant.
For further documentation and examples see How to Monitor Progress a section in The Java Tutorial. @see ProgressMonitorInputStream @author James Gosling @version 1.
18 1022 02/2102/9800
Constructs a graphic object that shows progress typically by filling in a rectangular bar as the process nears completion. @param parentComponent the parent component for the dialog box @param message a descriptive message that will be shown to the user to indicate what operation is being monitored. This does not change as the operation progresses. See the message parameters to methods inJOptionsPaneJOptionPane#message for the range of values. @param note a short note describing the state of the operation. As the operation progresses you can call setNote to change the note displayed. This is used for example in operations that iterate through a list of files to show the name of the file being processes. If note is initially null there will be no note line in the dialog box and setNote will be ineffective @param min the lower bound of the range @param max the upper bound of the range @see JDialog @see JOptionPane
Monitors the progress of reading from some InputStream. This ProgressMonitor is normally invoked in roughly this form:InputStream in = new BufferedInputStream( new ProgressMonitorInputStream( parentComponent "Reading " + fileName new FileInputStream(fileName)));This creates a progress monitor to monitor the progress of reading the input stream. If it's taking a while a ProgressDialog will be popped up to inform the user. If the user hits the Cancel button an InterruptedIOException will be thrown on the next read. All the right cleanup is done when the stream is closed.
For further documentation and examples see How to Monitor Progress a section in The Java Tutorial. @see ProgressMonitor @see JOptionPane @author James Gosling @version 1.
13 1016 02/2002/9800
Defines the requirements for an object responsible for "rendering" (displaying) a value. @version 1.7 089 02/2602/9800 @author Arnaud Weber
This class manages repaint requests allowing the number of repaints to be minimized for example by collapsing multiple requests into a single repaint for members of a component tree. @version 1.35 0439 02/2202/9900 @author Arnaud Weber
This interface is implemented by components that have a single JRootPane child: JDialog JFrame JWindow JApplet JInternalFrame. The methods in this interface are just covers for the JRootPane properties e.g.getContentPane()
is generally implemented like this:public Container getContentPane() { return getRootPane().getContentPane(); }This interface serves as a marker for Swing GUI builders that need to treat components like JFrame that contain a single JRootPane specially. For example in a GUI builder dropping a component on a RootPaneContainer would be interpreted asframe.getContentPane().add(child)
. @see JRootPane @see JFrame @see JDialog @see JWindow @see JApplet @see JInternalFrame @version 1.9 0811 02/2602/9800 @author Hans Muller
Constants used with the JScrollPane component. @version 1.11 0814 02/2602/9800 @author Hans Muller
The layout manager used by JScrollPane. JScrollPaneLayout is responsible for nine components: a viewport two scrollbars a row header a column header and four "corner" components.Class ScrollPaneLayout, void addLayoutComponent(String, Component)Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see JScrollPane @see JViewport @version 1.
34 0447 02/2202/9900 @author Hans Muller
Adds the specified component to the layout. The layout is identified using one of:Class ScrollPaneLayout, Component addSingletonComponent(Component, Component)@param s the component identifier @param comp the the component to be added
- JScrollPane.VIEWPORT
- JScrollPane.VERTICAL_SCROLLBAR
- JScrollPane.HORIZONTAL_SCROLLBAR
- JScrollPane.ROW_HEADER
- JScrollPane.COLUMN_HEADER
- JScrollPane.LOWER_LEFT_CORNER
- JScrollPane.LOWER_RIGHT_CORNER
- JScrollPane.UPPER_LEFT_CORNER
- JScrollPane.UPPER_RIGHT_CORNER
The method used toClass ScrollPaneLayout, JScrollBar getHorizontalScrollBar()replaceremove an existing component(if any) with a new one.Used to add each different kind of component toSincea JScrollPane sincethere can be one and only one left corner vertical scrollbar and so on. So only one of each subcomponent is allowed the old one is removed (if it exists) when a new one is added.This method returns
newC
. IfoldC
is not equal tonewC
and is non-null
it will be removed from its parent. @param oldC theComponent
to replace @param newC theComponent
to add @return thenewC
Returns theClass ScrollPaneLayout, JScrollBar getVerticalScrollBar()JScrollbarJScrollBar object that handles horizontal scrolling. @return theJScrollbarJScrollBar object that handles horizontal scrolling @see JScrollPane#getHorizontalScrollBar
Returns theClass ScrollPaneLayout, JScrollBar hsbJScrollbarJScrollBar object that handles vertical scrolling. @return theJScrollbarJScrollBar object that handles vertical scrolling @see JScrollPane#getVerticalScrollBar
The scrollpanes horizontal scrollbar child. Default is a JScrollBar. @see JScrollPane#Class ScrollPaneLayout, JScrollBar vsbsetHorizontalScrollbarsetHorizontalScrollBar
The scrollpanes vertical scrollbar child. Default is a JScrollBar. @see JScrollPane#setVerticalScrollbarsetVerticalScrollBar
An interface that provides information to a scrolling container like JScrollPane. A complex component that's likely to be used as a viewin a JScrollPane viewport (or other scrolling container) should implement this interface. @see JViewport @see JScrollPane @see JScrollBar @version 1.4 086 02/2602/9800 @author Hans Muller
For the convenience of layout managers calculates information about the size and position of components. All size and position calculation methods are class methods that take arrays of SizeRequirements as arguments. The SizeRequirements class supports two types of layout:
- tiled
- The components are placed end-to-end starting at coordinate 0 (the leftmost or topmost position).
- aligned
- The components are aligned as specified by each component's X or Y alignment value.
Each SizeRequirements object contains information about either the width (and X alignment) or height (and Y alignment) of a single component or a group of components:
minimum
- The smallest reasonable width/height of the component or component group in pixels.
preferred
- The natural width/height of the component or component group in pixels.
maximum
- The largest reasonable width/height of the component or component group in pixels.
alignment
- The X/Y alignment of the component or component group.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see Component#getMinimumSize @see Component#getPreferredSize @see Component#getMaximumSize @see Component#getAlignmentX @see Component#getAlignmentY @version 1.
24 1026 02/2002/9800 @author Timothy Prinzing
A collection of constants generally used for positioning and orienting components on the screen. @version 1.9 0811 02/2602/9800 @author Jeff Dinkins @author Ralph Kar (orientation support)
A collection of utility methods for Swing. @version 1.Class SwingUtilities, Rectangle computeIntersection(int, int, int, int, Rectangle)80 0494 02/2202/9900 @author unknown
Convenience to calculateClass SwingUtilities, MouseEvent convertMouseEvent(Component, MouseEvent, Component)anthe intersection of two rectangles without allocating a new rectangle.ReturnIfdestthe two rectangles don't intersect then the returned rectangle begins at (0 0) and has zero width and height. @param x the X coordinate of the first rectangle's top-left point @param y the Y coordinate of the first rectangle's top-left point @param width the width of the first rectangle @param height the height of the first rectangle @param dest the second rectangle @returndest
modified to specify the intersection
Returns a MouseEvent similar toClass SwingUtilities, Accessible getAccessibleChild(Component, int)sourceEvent
except that its x and y members have been converted todestination
's coordinate system. Ifsource
is nullsourceEvent
x and y members are assumed to be intodestination
's root component coordinate system. Ifdestination
isnull
the returned MouseEvent will be insource
's coordinate system.sourceEvent
will not be changed. A new event is returned. thesource
field of the returned event will be set todestination
if destination is non null use the translateMouseEvent() method to translate a mouse event from one component to another without changing the source.
Return the nth Accessible child of the object.Class SwingUtilities, int getAccessibleChildrenCount(Component)Note: as of the Java 2 platform v1.3 it is recommended that developers call Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead of using this method. @param i zero-based index of child @return the nth Accessible child of the object
Returns the number of accessible children in the object. If all of the children of this object implement Accessible than this method should return the number of children of this object.Class SwingUtilities, int getAccessibleIndexInParent(Component)Note: as of the Java 2 platform v1.3 it is recommended that developers call Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead of using this method. @return the number of accessible children in the object.
Get the index of this object in its accessible parent.Class SwingUtilities, AccessibleStateSet getAccessibleStateSet(Component)Note: as of the Java 2 platform v1.3 it is recommended that developers call Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead of using this method. @return -1 of this object does not have an accessible parent. Otherwise the index of the child in its accessible parent.
Get the state of this object.Class SwingUtilities, void invokeAndWait(Runnable)Note: as of the Java 2 platform v1.3 it is recommended that developers call Component.AccessibleAWTComponent.getAccessibleIndexInParent() instead of using this method. @return an instance of AccessibleStateSet containing the current state set of the object @see AccessibleState
Causes doRun.run() to be executed synchronously on the AWT event dispatching thread. This call will block until all pending AWT events have been processed and (then) doRun.run() returns. This method should be used when an application thread needs to update the GUI. It should not be called from the EventDispatchThread. Here's an example that creates a new application thread that uses invokeAndWait() to print a string from the event dispatching thread and then when that's finished print a string from the application thread.Class SwingUtilities, void invokeLater(Runnable)final Runnable doHelloWorld = new Runnable() { public void run() { System.out.println("Hello World on " + Thread.currentThread()); } }; Thread appThread = new Thread() { public void run() { try { SwingUtilities.invokeAndWait(doHelloWorld); } catch (Exception e) { e.printStackTrace(); } System.out.println("Finished on " + Thread.currentThread()); } }; appThread.start();Note that if the Runnable.run() method throws an uncaught exception (on the event dispatching thread) it's caught and rethrown as an InvocationTargetException on the callers thread.Additional documentation and examples for this method can be found in How to Use Threads in The Java Tutorial.
As of 1.3 this method is just a cover for
java.awt.EventQueue.invokeAndWait()
. @exception InterruptedExceptionIfif we're interrupted while waiting for the event dispatching thread to finish excecuting doRun.run() @exception InvocationTargetExceptionIfif doRun.run() throws @see #invokeLater
Causes doRun.run() to be executed asynchronously on the AWT event dispatching thread. This will happen after all pending AWT events have been processed. This method should be used when an application thread needs to update the GUI. In the following example theClass SwingUtilities, boolean isEventDispatchThread()invokeAndWait()invokeLater
callscall queues thedoHelloWorldRunnable
forobjectdoHelloWorld
on the event dispatching thread and then prints a message.Runnable doHelloWorld = new Runnable() { public void run() { System.out.println("Hello World on " + Thread.currentThread()); } }; SwingUtilities.IfinvokeAndWaitinvokeLater(doHelloWorld); System.out.println("WaitingThis...might well be displayed before the other message.");invokeAndWaitinvokeLater is called from the event dispatching threade.g.-- for example from aJButtonsJButton's ActionListener -- the doRun.run() will still be deferredtilluntil all pending events have been processed. Note that if the doRun.run() throws an uncaught exception the event dispatching thread will unwind (not the current thread).Additional documentation and examples for this method can be found in How to Use Threads in The Java Tutorial.
As of 1.3 this method is just a cover for
java.awt.EventQueue.invokeLater()
. @see #invokeAndWait
Returns true if the current thread is an AWT event dispatching thread.Class SwingUtilities, void updateComponentTreeUI(Component)As of 1.3 this method is just a cover for
java.awt.EventQueue.isEventDispatchThread()
. @return true if the current thread is an AWT event dispatching thread
A simple minded look and feel change: ask each node in the tree to updateUI()i.e.-- that is to initialize its UI property with the current look and feel.
ObjectCausessubclass that causesan action to occur at a predefined rate. For example an animation object can use a Timer as the trigger for drawing its next frame. For documentation and examples of using timers see How to Use Timers in The Java Tutorial.Each Timer has a list of ActionListeners and a delay (
the time betweenactionPerfomedactionPerformed() calls). When delay milliseconds have passed a Timer sends the actionPerformed() message to its listeners. This cycle repeats until stop() is called or halts immediately if theJimerTimer is configured to send its message just once.Using a Timer involves first creating it then starting it using the start() method.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
28 0432 02/2202/9900 @author Dave Moore
Manages all the ToolTips in the system. @see JComponent#createToolTip @version 1.Class ToolTipManager, void registerComponent(JComponent)40 0444 06/2201/99 @author Dave Moore @author Rich Schiavi
Register a component for tooltip management.Class ToolTipManager, void setDismissDelay(int)This will register key bindings to show and hide the tooltip text only if
component
has focus bindings. This is done so that components that are not normally focus traversable such as JLabel are not made focus traversable as a result of invoking this method. @param component a JComponent object @see JComponent#isFocusTraversable
Specifies the dismisal delay value. @paramClass ToolTipManager, void setInitialDelay(int)microSecondsmillisecondsan int specifyingthe number ofmicrosecondsmilliseconds to delay (after the cursor has moved on) before taking away the tooltip @see #getDismissDelay
Specifies the initial delay value. @paramClass ToolTipManager, void setLightWeightPopupEnabled(boolean)microSecondsmillisecondsan int specifyingthe number ofmicrosecondsmilliseconds to delay (after the cursor has paused) before displaying the tooltip @see #getInitialDelay
When displaying the JToolTip the ToolTipManager choose to use a light weight JPanel if it fits. This method allows you to disable this feature. You have to do disable it if your application mixes light weight and heavy weights components.Class ToolTipManager, void setReshowDelay(int)@deprecated As of Swing1.1 replaced by setToolTipWindowUsePolicy(int).
Specifies the time to delay before reshowing the tooltip. @parammicroSecondsmillisecondsan int specifyingthe time inmicrosecondsmilliseconds to delay before reshowing the tooltip if the cursor stops again @see #getReshowDelay
A table of defaults for Swing components. Applications can set/get default values via theUIManager
.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @see UIManager @version 1.
31 0437 02/2202/9900 @author Hans Muller
This class enables one to store an entry in the defaults table that's constructed each time it's looked up with one of theClass UIDefaults.ActiveValue, Object createValue(UIDefaults)getXXX(key)
methods. Here's an example of anActiveValue
that constructs aDefaultListCellRenderer
:Object cellRendererActiveValue = new UIDefaults.ActiveValue() { public Object createValue(UIDefaults table) { return new DefaultListCellRenderer(); } }; uiDefaultsTable.put("MyRenderer" cellRendererActiveValue);@see UIDefaults#get
Creates the value retrieved from theUIDefaults
table. The object is created each time it is accessed. @param table aUIDefaults
table @return the createdObject
This class enables one to store an entry in the defaults table that isn't constructed until the first time it's looked up with one of theClass UIDefaults.LazyValue, Object createValue(UIDefaults)getXXX(key)
methods. Lazy values are useful for defaults that are expensive to construct or are seldom retrieved. The first time aLazyValue
is retrieved its "real value" is computed by callingLazyValue.createValue()
and the real value is used to replace theLazyValue
in theUIDefaults
table. Subsequent lookups for the same key return the real value. Here's an example of aLazyValue
that constructs aBorder
:Object borderLazyValue = new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return new BorderFactory.createLoweredBevelBorder(); } }; uiDefaultsTable.put("MyBorder" borderLazyValue);@see UIDefaults#get
Creates the actual value retrieved from theUIDefaults
table. When an object that implements this interface is retrieved from the table this method is used to create the real value which is then stored in the table and returned to the calling method. @param table aUIDefaults
table @return the createdObject
Create a defaults table initialized with the specified key/value pairs. For example:Class UIDefaults, void addPropertyChangeListener(PropertyChangeListener)Object[] uiDefaults = { "Font" new Font("Dialog" Font.BOLD 12) "Color" Color.red "five" new Integer(5) } UIDefaults myDefaults = new UIDefaults(uiDefaults);@param keyValueList an array of objects containing the key/value pairs
Class UIDefaults, void firePropertyChange(String, Object, Object)AddAdds aPropertyChangeListener
to the listener list. The listener is registered for all properties.A
PropertyChangeEvent
will get fired whenever a default is changed. @param listenerThethePropertyChangeListener
to be added @see java.beans.PropertyChangeSupport
Support for reporting bound property changes. If oldValue and newValue are not equal and theClass UIDefaults, Object get(Object)PropertyChangeEvent
x listener list isn't empty then fire aPropertyChange
event to each listener. @param propertyNameThethe programmatic name of the property that was changed.@param oldValueThethe old value of the property.@param newValueThethe new value of the property.@see java.beans.PropertyChangeSupport
Returns the value for key. If the value is aClass UIDefaults, Border getBorder(Object)UIDefaults.LazyValue
then the real value is computed withLazyValue.createValue()
the table entry is replaced and the real value is returned. If the value is anUIDefaults.ActiveValue
the table entry is not replaced - the value is computed withActiveValue.createValue()
for eachget()
call. @param key the desired key @return the value forkey
@see LazyValue @see ActiveValue @see java.util.Hashtable#get
If the value ofClass UIDefaults, Color getColor(Object)key
is aBorder
return it otherwise returnnull
. @param key the desired key @return if the value forkey
is aBorder
return theBorder
object; otherwise returnnull
If the value ofClass UIDefaults, Dimension getDimension(Object)key
is aColor
return it otherwise returnnull
. @param key the desired key @return if the value forkey
is aColor
return theColor
object; otherwise returnnull
If the value ofClass UIDefaults, Font getFont(Object)key
is aDimension
return it otherwise returnnull
. @param key the desired key @return if the value forkey
is aDimension
return theDimension
object; otherwise returnnull
If the value ofClass UIDefaults, Icon getIcon(Object)key
is aFont
return it otherwise returnnull
. @param key the desired key @return if the value forkey
is aFont
return theFont
object; otherwise returnnull
If the value ofClass UIDefaults, Insets getInsets(Object)key
is anIcon
return it otherwise returnnull
. @param key the desired key @return if the value forkey
is anIcon
return theIcon
object; otherwise returnnull
If the value ofClass UIDefaults, int getInt(Object)key
isaanInsets
return it otherwise returnnull
. @param key the desired key @return if the value forkey
is anInsets
return theInsets
object; otherwise returnnull
If the value ofClass UIDefaults, String getString(Object)key
isaanInteger
return its integer value otherwise return 0. @param key the desired key @return if the value forkey
is anInteger
return its value otherwise return 0
If the value ofClass UIDefaults, ComponentUI getUI(JComponent)key
is aString
return it otherwise returnnull
. @param key the desired key @return if the value forkey
is aString
return theString
object; otherwise returnnull
Class UIDefaults, Class getUIClass(String)CreateCreates anComponentUI
implementation for the specified component. In other words create the look and feel specific delegate object fortarget
. This is done in two steps:@param target the
LookupLook up the name of theComponentUI
implementation class under the value returned bytarget.getUIClassID()
.- Use the implementation classes static
createUI()
method to construct a look and feel delegate.JComponent
which needs a UI @return theComponentUI
object
Returns the L&F class that renders this component. @param uiClassID a string containing the class ID @return the Class object returned by getUIClass(uiClassID null)
Class UIDefaults, Class getUIClass(String, ClassLoader)The value ofClass UIDefaults, void getUIError(String)get(uidClassID)
must be theString
name of a class that implements the correspondingComponentUI
class. If the class hasn't been loaded before this method looks up the class withuiClassLoader.loadClass()
if a nonnull
class loader is providedclassForName()
otherwise.If a mapping for
uiClassID
exists or if the specified class can't be found returnnull
.This method is used by
getUI
it's usually not neccessary to call it directly. @param uiClassID a string containing the class ID @param uiClassLoader the object which will load the class @returnThethe value ofClass.forName(get(uidClassID))
.@see #getUI
IfClass UIDefaults, Object put(Object, Object)getUI()
fails for any reason it calls this method before returningnull
. Subclasses may choose to do more or less here. @param msgMessagemessage string to print.@see #getUI
Class UIDefaults, void putDefaults(Object[])SetSets the value ofkey
tovalue
. Ifkey
is a string and the new value isn't equal to the old one fire aPropertyChangeEvent
. If value isnull
the key is removed from the table. @param key the uniqueObject
who's value will be used toretreiveretrieve the data value associated with it @param value the newObject
to store as data under that key @return the previousObject
value ornull
@see #putDefaults @see java.util.Hashtable#put
Class UIDefaults, void removePropertyChangeListener(PropertyChangeListener)PutPuts all of the key/value pairs in the database and unconditionallygenerategenerates onePropertyChangeEvent
. The events oldValue and newValue will benull
and itspropertyName
will be "UIDefaults". @param keyValueList an array of key/value pairs @see #put @see java.util.Hashtable#put
RemoveRemoves aPropertyChangeListener
from the listener list. This removes aPropertyChangeListener
that was registered for all properties. @param listenerThethePropertyChangeListener
to be removed @see java.beans.PropertyChangeSupport
This class keeps track of the current look and feel and its defaults.Class UIManager, String getCrossPlatformLookAndFeelClassName()We manage three levels of defaults: user defaults look and feel defaults system defaults. A call to UIManager.get() checks all three levels in order and returns the first non-null value for a key if any. A call to UIManager.put() just affects the user defaults. Note that a call to setLookAndFeel() doesn't affect the user defaults it just replaces the middle defaults "level".
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
74 0583 02/2802/9900 @author Thomas Ball @author Hans Muller
Returns the name of the LookAndFeel class that implements the default cross platform look and feelClass UIManager, LookAndFeelInfo[] getInstalledLookAndFeels()i.e.-- the"Java Look and Feel" or(JLF). @return a string with the JLF implementation-class @see #setLookAndFeel @see #getSystemLookAndFeelClassName
Return an array of objects that provide some information about the LookAndFeel implementations that have been installed with thisClass UIManager, Object put(Object, Object)javasoftware development kit. The LookAndFeel info objects can be used by an application to construct a menu of look and feel options for the user or to set the look and feel at start up time. Note that we do not return the LookAndFeel classes themselves here to avoid the cost of unnecessarily loading them.Given a LookAndFeelInfo object one can set the current look and feel like this:
UIManager.setLookAndFeel(info.getClassName());@see #setLookAndFeel
Stores an object in the defaults table. @param key an Object specifying the retrieval key @param value the Object to store @return the Object returned by UIDefaults.#put
An exception that indicates the request look & feel management classes are not present on the user's system.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @author unattributed @version 1.
10 0812 02/2802/9800
The default layout manager forClass ViewportLayout, void layoutContainer(Container)JViewport
.JViewportLayoutViewportLayout
defines a policy for layout that should be useful for most applications. The viewport makes its view the same size as the viewport however it will not make the view smaller than its minimum size. As the viewport grows the view is kept bottom justified until the entire view is visible subsequently the view is kept top justified.Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence. @version 1.
27 0429 02/2202/9900 @author Hans Muller
Called by the AWT when the specified container needs to be laid out. @param parent the container to lay out @exception AWTError if the target isn't the container specified to the BoxLayout
constructor
Class ViewportLayout, Dimension minimumLayoutSize(Container)Returns the minimum dimensions needed to layout the components contained in the specified target container. @param target the component which needs to be laid out @return a Dimension
object containing the minimum dimensions @see #preferredLayoutSize
Class ViewportLayout, Dimension preferredLayoutSize(Container)Returns the preferred dimensions for this layout given the components in the specified target container. @param target the component which needs to be laid out @return a Dimension
object containing the preferred dimensions @see #minimumLayoutSize
Constants used to control the window-closing operation. ThesetDefaultCloseOperation
andgetDefaultCloseOperation
methods provided byJFrame
JInternalFrame
andJDialog
use these constants. Forexampleexamples of setting the default window-closing operation seeJFrame#setDefaultCloseOperationResponding to Window-Closing Events a section in The Java Tutorial. @version 1.8 1113 02/1302/9800 @author Amy Fowler