javax.swing
類別 JCheckBox
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JToggleButton
javax.swing.JCheckBox
- 所有已實作的介面:
- ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants
public class JCheckBox
- extends JToggleButton
- implements Accessible
複選框的實作,複選框是一個可以被選定和取消選定的項,它將其狀態顯示給使用者。按照慣例,可以選定組中任意數量的複選框。有關使用複選框的範例和資訊,請參閱 The Java Tutorial 中的 How to Use Buttons, Check Boxes, and Radio Buttons。
通過 Action
可配置按鈕,並進行某種程度的控制。將 Action
用於按鈕具有許多直接配置按鈕所不及的優點。有關更多詳細資訊,請參閱支持 Action
的 Swing 元件,可在 The Java Tutorial 中的 How
to Use Actions 一節找到更多資訊。
警告: Swing 不是執行緒安全的。有關更多資訊,請參閱 Swing's Threading
Policy。
警告:此類別的序列化物件將與以後的 Swing 版本不相容。當前序列化支持適用於短期存儲,或適用於在運行相同 Swing 版本的應用程序之間進行 RMI(Remote Method Invocation,遠端方法調用)。從 1.4 版本開始,已在 java.beans
套件中添加了支持所有 JavaBeansTM 長期存儲的功能。請參見 XMLEncoder
。
- 另請參見:
JRadioButton
從類別 javax.swing.AbstractButton 繼承的欄位 |
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY |
從介面 javax.swing.SwingConstants 繼承的欄位 |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
從類別 javax.swing.AbstractButton 繼承的方法 |
actionPropertyChanged, addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, configurePropertiesFromAction, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, removeNotify, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setEnabled, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition |
從類別 javax.swing.JComponent 繼承的方法 |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
從類別 java.awt.Container 繼承的方法 |
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
從類別 java.awt.Component 繼承的方法 |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
BORDER_PAINTED_FLAT_CHANGED_PROPERTY
public static final String BORDER_PAINTED_FLAT_CHANGED_PROPERTY
- 標識 flat 屬性的更改。
- 另請參見:
- 常數欄位值
JCheckBox
public JCheckBox()
- 創建一個沒有文本、沒有圖標並且最初未被選定的複選框。
JCheckBox
public JCheckBox(Icon icon)
- 創建有一個圖標、最初未被選定的複選框。
- 參數:
icon
- 要顯示的 Icon 圖像
JCheckBox
public JCheckBox(Icon icon,
boolean selected)
- 創建一個帶圖標的複選框,並指定其最初是否處於選定狀態。
- 參數:
icon
- 要顯示的 Icon 圖像selected
- 指示最初選擇狀態的 boolean 值。如果該參數為 true
,則複選框被選定
JCheckBox
public JCheckBox(String text)
- 創建一個帶文本的、最初未被選定的複選框。
- 參數:
text
- 複選框的文本
JCheckBox
public JCheckBox(Action a)
- 創建一個複選框,其屬性從所提供的 Action 獲取。
- 從以下版本開始:
- 1.3
JCheckBox
public JCheckBox(String text,
boolean selected)
- 創建一個帶文本的複選框,並指定其最初是否處於選定狀態。
- 參數:
text
- 複選框的文本selected
- 指示最初選擇狀態的 boolean 值。如果該參數為 true
,則複選框被選定
JCheckBox
public JCheckBox(String text,
Icon icon)
- 創建帶有指定文本和圖標的、最初未選定的複選框。
- 參數:
text
- 複選框的文本icon
- 要顯示的 Icon 圖像
JCheckBox
public JCheckBox(String text,
Icon icon,
boolean selected)
- 創建一個帶文本和圖標的複選框,並指定其最初是否處於選定狀態。
- 參數:
text
- 複選框的文本icon
- 要顯示的 Icon 圖像selected
- 指示最初選擇狀態的 boolean 值。如果該參數為 true
,則複選框被選定
setBorderPaintedFlat
public void setBorderPaintedFlat(boolean b)
- 設置
borderPaintedFlat
屬性,該屬性為外觀提供了關於複選框邊框外觀的提示。在 JCheckBox
實例用作元件(如 JTable
或 JTree
)中的渲染器時,該屬性通常被設置為 true
。borderPaintedFlat
屬性的預設值為 false
。此方法觸發一個屬性更改事件。一些外觀也許不實作平面邊框;它們將忽略此屬性。
- 參數:
b
- 為 true
則請求將邊框繪製為平面的;為 false
則請求為普通邊框- 從以下版本開始:
- 1.3
- 另請參見:
isBorderPaintedFlat()
isBorderPaintedFlat
public boolean isBorderPaintedFlat()
- 獲取
borderPaintedFlat
屬性的值。
- 返回:
borderPaintedFlat
屬性的值- 從以下版本開始:
- 1.3
- 另請參見:
setBorderPaintedFlat(boolean)
updateUI
public void updateUI()
- 根據當前外觀重置 UI 屬性值。
- 覆寫:
- 類別
JToggleButton
中的 updateUI
- 另請參見:
JComponent.updateUI()
getUIClassID
public String getUIClassID()
- 返回指定呈現此元件的 L&F 類別名的字元串。
- 覆寫:
- 類別
JToggleButton
中的 getUIClassID
- 返回:
- 字元串 "CheckBoxUI"
- 另請參見:
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
paramString
protected String paramString()
- 返回此 JCheckBox 的字元串表示形式。此方法僅在進行除錯的時候使用,對於各個實作,所返回字元串的內容和格式可能有所不同。返回的字元串可能為空,但不可能為
null
。JFC 元件的一些特定的新的方面。
- 覆寫:
- 類別
JToggleButton
中的 paramString
- 返回:
- a 此 JCheckBox 的字元串表示形式。
getAccessibleContext
public AccessibleContext getAccessibleContext()
- 獲取與此 JCheckBox 關聯的 AccessibleContext。對於 JCheckBoxes,AccessibleContext 採用 AccessibleJCheckBox 的形式。如有必要,可創建一個新的 AccessibleJCheckBox 實例。
- 指定者:
- 介面
Accessible
中的 getAccessibleContext
- 覆寫:
- 類別
JToggleButton
中的 getAccessibleContext
- 返回:
- 一個 AccessibleJCheckBox,它將充當此 JCheckBox 的 AccessibleContext
提交錯誤或意見版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。