javax.swing.AbstractAction

此類提供 JFC Action 接口的默認實現。它定義了一些標準行為,比如 Action 對象屬性(icon、text 和 enabled)的 get 和 set 方法。開發人員只需為此抽象類創建子類並定義 actionPerformed 方法即可。

基本介紹

  • 外文名:javax.swing.AbstractAction
  • 存儲類型:短期存儲
  • 實現的接口:ActionListener,Serializable,
  • 類結構:extendsObject 
簡介,所有已實現的接口,直接已知子類,類結構,欄位摘要,構造方法摘要,方法摘要,欄位詳細信息,構造方法信息,方法詳細,

簡介

此類的已序列化對象與以後的Swing版本不兼容。當前序列化支持適用於短期存儲,或適用於在運行相同Swing版本的應用程式之間進行RMI(RemoteMethodInvocation,遠程方法調用)。從1.4版本開始,已在java.beans包中添加了支持所有JavaBeansTM長期存儲的功能。

所有已實現的接口

ActionListener,Serializable,Cloneable,EventListener,Action

直接已知子類

BasicDesktopPaneUI.CloseAction,BasicDesktopPaneUI.MaximizeAction,BasicDesktopPaneUI.MinimizeAction,BasicDesktopPaneUI.NavigateAction,BasicDesktopPaneUI.OpenAction,BasicFileChooserUI.ApproveSelectionAction,BasicFileChooserUI.CancelSelectionAction,BasicFileChooserUI.ChangeToParentDirectoryAction,BasicFileChooserUI.GoHomeAction,BasicFileChooserUI.NewFolderAction,BasicFileChooserUI.UpdateAction,BasicInternalFrameTitlePane.CloseAction,BasicInternalFrameTitlePane.IconifyAction,BasicInternalFrameTitlePane.MaximizeAction,BasicInternalFrameTitlePane.MoveAction,BasicInternalFrameTitlePane.RestoreAction,BasicInternalFrameTitlePane.SizeAction,BasicSliderUI.ActionScroller,BasicTreeUI.TreeCancelEditingAction,BasicTreeUI.TreeHomeAction,BasicTreeUI.TreeIncrementAction,BasicTreeUI.TreePageAction,BasicTreeUI.TreeToggleAction,BasicTreeUI.TreeTraverseAction,MetalFileChooserUI.DirectoryComboBoxAction,TextAction

類結構

publicabstractclassAbstractAction
extendsObject
implementsAction,Cloneable,Serializable

欄位摘要

protectedSwingPropertyChangeSupport changeSupport
如果已經註冊了任意PropertyChangeListener,則changeSupport欄位負責描述它們。
protectedboolean enabled
指定是否啟用操作;默認值為true。
從接口javax.swing.Action繼承的欄位
ACCELERATOR_KEY,ACTION_COMMAND_KEY,DEFAULT,DISPLAYED_MNEMONIC_INDEX_KEY,LARGE_ICON_KEY,LONG_DESCRIPTION,MNEMONIC_KEY,NAME,SELECTED_KEY,SHORT_DESCRIPTION,SMALL_ICON

構造方法摘要

AbstractAction()
用默認描述字元串和默認圖示定義一個Action對象。
AbstractAction(Stringname)
用指定描述字元串和默認圖示定義一個Action對象。
AbstractAction(Stringname,Iconicon)
用指定描述字元串和指定圖示定義一個Action對象。

方法摘要

void addPropertyChangeListener(PropertyChangeListenerlistener)
向偵聽器列表添加一個PropertyChangeListener。
protectedObject clone()
複製抽象操作。
protectedvoid firePropertyChange(StringpropertyName,ObjectoldValue,ObjectnewValue)
支持報告綁定(bound)屬性的改變。
Object[] getKeys()
返回Object的數組,這些對象是一些已經為其設定此AbstractAction值的鍵,如果沒有已經設定該值的鍵,則返回null。
PropertyChangeListener[] getPropertyChangeListeners()
返回使用addPropertyChangeListener()添加到此AbstractAction中的所有PropertyChangeListener組成的數組。
Object getValue(Stringkey)
獲得與指定鍵關聯的Object。
boolean isEnabled()
如果啟用該操作,則返回true。
void putValue(Stringkey,ObjectnewValue)
設定與指定鍵關聯的Value。
void removePropertyChangeListener(PropertyChangeListenerlistener)
從偵聽器列表中移除一個PropertyChangeListener。
void setEnabled(booleannewValue)
啟用或禁用該操作。
從類java.lang.Object繼承的方法
equals,finalize,getClass,hashCode,notify,notifyAll,toString,wait,wait,wait

從接口java.awt.event.ActionListener繼承的方法
actionPerformed

欄位詳細信息

enabled
protectedbooleanenabled
指定是否啟用操作;默認值為true。
changeSupport
protectedSwingPropertyChangeSupportchangeSupport
如果已經註冊了任意PropertyChangeListener,則changeSupport欄位負責描述它們。

構造方法信息

AbstractAction
publicAbstractAction()
用默認描述字元串和默認圖示定義一個Action對象。
AbstractAction
publicAbstractAction(Stringname)
用指定描述字元串和默認圖示定義一個Action對象。
AbstractAction
publicAbstractAction(Stringname,
Iconicon)
用指定描述字元串和指定圖示定義一個Action對象。

方法詳細

getValue
publicObjectgetValue(Stringkey)
獲得與指定鍵關聯的Object。
指定者:接口Action中的getValue
參數:key-包含指定key的字元串
返回:用此鍵存儲的綁定Object;如果沒有鍵,則將返回null
另請參見:Action.getValue(java.lang.String)
putValue
publicvoidputValue(Stringkey,
ObjectnewValue)
設定與指定鍵關聯的Value。
指定者:接口Action中的putValue
參數:key-標識所存儲對象的String;newValue-將使用此鍵存儲的Object
另請參見:Action.putValue(java.lang.String,java.lang.Object)
isEnabled
publicbooleanisEnabled()
如果啟用該操作,則返回true。
指定者:接口Action中的isEnabled
返回:如果啟用該操作,則返回true;否則返回false
另請參見:Action.isEnabled()
setEnabled
publicvoidsetEnabled(booleannewValue)
啟用或禁用該操作。
指定者:接口Action中的setEnabled
參數:newValue-為true表示啟用該操作,為false表示禁用該操作
另請參見:Action.setEnabled(boolean)
getKeys
publicObject[]getKeys()
返回Object的數組,這些對象是一些已經為其設定此AbstractAction值的鍵,如果沒有已經設定該值的鍵,則返回null。
返回:一個鍵對象數組,如果沒有已經設定好值的鍵,則返回null
firePropertyChange
protectedvoidfirePropertyChange(StringpropertyName,
ObjectoldValue,
ObjectnewValue)
支持報告綁定(bound)屬性的改變。當改變了綁定屬性時可調用此方法,它將向所有已註冊的PropertyChangeListener傳送相應的PropertyChangeEvent。
addPropertyChangeListener
publicvoidaddPropertyChangeListener(PropertyChangeListenerlistener)
向偵聽器列表添加一個PropertyChangeListener。該偵聽器是為所有屬性註冊的。
在回響對綁定屬性(例如SetFont、setBackground或setForeground)的設定時,將觸發一個PropertyChangeEvent。注意,如果當前組件將繼承其容器的前景、背景或字型,則在回響所繼承屬性中的更改時不會觸發任何事件。
指定者:接口Action中的addPropertyChangeListener
參數:listener-要添加的PropertyChangeListener
另請參見:Action.addPropertyChangeListener(java.beans.PropertyChangeListener)
removePropertyChangeListener
publicvoidremovePropertyChangeListener(PropertyChangeListenerlistener)
從偵聽器列表中移除一個PropertyChangeListener。此方法移除了一個為所有屬性註冊的PropertyChangeListener。
指定者: 接口Action中的removePropertyChangeListener
參數:listener-要移除的PropertyChangeListener
另請參見:Action.removePropertyChangeListener(java.beans.PropertyChangeListener)
getPropertyChangeListeners
publicPropertyChangeListener[]getPropertyChangeListeners()
返回使用addPropertyChangeListener()添加到此AbstractAction中的所有PropertyChangeListener組成的數組。
返回: 添加的所有PropertyChangeListener,如果沒有添加偵聽器,則返回一個空數組
clone
protectedObjectclone()
throwsCloneNotSupportedException
複製抽象操作。此方法給出了它自己的鍵/值列表的副本,該副本不能通過Object.clone()為您處理。
覆蓋:類Object中的clone
返回: 此實例的一個副本。
拋出:CloneNotSupportedException-如果對象的類不支持Cloneable接口,則重寫clone方法的子類也會拋出此異常,以指示無法複製某個實例。

相關詞條

熱門詞條

聯絡我們