JComponent類是除頂層容器外所有Swing組件的基類。要使用繼承自JComponent 一個組成部分,必須把的容納層次結(jié)構(gòu),其根是一個頂層 Swing 容器組件。
以下是聲明的 javax.swing.JComponent類:
public abstract class JComponent extends Container implements Serializable
以下是java.awt.Component 類的字段:
protected AccessibleContext accessibleContext -- AccessibleContext 可以帶此JComponent。
protected EventListenerList listenerList -- 此組件的事件偵聽器的列表。
static String TOOL_TIP_TEXT_KEY -- 注釋顯示當光標在組件上,也被稱為 "value tip", "flyover help", 或 "flyover label".
protected ComponentUI ui -- 此組件代表的外觀和風格。
static int UNDEFINED_CONDITION -- Constant used by some of the APIs to mean that no condition is defined.
static int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT -- 常數(shù)用于registerKeyboardAction,意味著當接收組件是一個聚焦組件的基類,或者本身就是焦點的組件,該命令要調(diào)用。
static int WHEN_FOCUSED -- 常數(shù)用于registerKeyboardAction,意味著命令組件具有焦點時要調(diào)用。
static int WHEN_IN_FOCUSED_WINDOW -- 常數(shù)用于registerKeyboardAction,意味著當接收組件具有焦點的窗口,或者是本身的重點組成部分,該命令調(diào)用。
S.N. | 構(gòu)造函數(shù) & 描述 |
---|---|
1 |
JComponent() Default JComponent constructor. |
S.N. | 方法 & 描述 |
---|---|
1 |
void addAncestorListener(AncestorListener listener) Registers listener so that it will receive AncestorEvents when it or any of its ancestors move or are made visible or invisible. |
2 |
void addNotify() Notifies this component that it now has a parent component. |
3 |
void addVetoableChangeListener(VetoableChangeListener listener) Adds a VetoableChangeListener to the listener list. |
4 |
void computeVisibleRect(Rectangle visibleRect) Returns the Component's "visible rect rectangle" - the intersection of the visible rectangles for this component and all of its ancestors. |
5 |
boolean contains(int x, int y) Gives the UI delegate an opportunity to define the precise shape of this component for the sake of mouse processing. |
6 |
JToolTip createToolTip() Returns the instance of JToolTip that should be used to display the tooltip. |
7 |
void disable() Deprecated.As of JDK version 1.1, replaced by java.awt.Component.setEnabled(boolean). |
8 |
void enable() Deprecated. As of JDK version 1.1, replaced by java.awt.Component.setEnabled(boolean). |
9 |
void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) Support for reporting bound property changes for boolean properties. |
10 |
void firePropertyChange(String propertyName, char oldValue, char newValue) Reports a bound property change. |
11 |
void firePropertyChange(String propertyName, int oldValue, int newValue) Support for reporting bound property changes for integer properties. |
12 |
protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) Supports reporting constrained property changes. |
13 |
AccessibleContext getAccessibleContext() Returns the AccessibleContext associated with this JComponent. |
14 |
ActionListener getActionForKeyStroke(KeyStroke aKeyStroke) Returns the object that will perform the action registered for a given keystroke. |
15 |
ActionMap getActionMap() Returns the ActionMap used to determine what Action to fire for particular KeyStroke binding. |
16 |
float getAlignmentX() Overrides Container.getAlignmentX to return the vertical alignment. |
17 |
float getAlignmentY() Overrides Container.getAlignmentY to return the horizontal alignment. |
18 |
AncestorListener[] getAncestorListeners() Returns an array of all the ancestor listeners registered on this component. |
19 |
boolean getAutoscrolls() Gets the autoscrolls property. |
20 |
int getBaseline(int width, int height) Returns the baseline. |
21 |
Component.BaselineResizeBehavior getBaselineResizeBehavior() Returns an enum indicating how the baseline of the component changes as the size changes. |
22 |
Border getBorder() Returns the border of this component or null if no border is currently set. |
23 |
Rectangle getBounds(Rectangle rv) Stores the bounds of this component into "return value" rv and returns rv. |
24 |
Object getClientProperty(Object key) Returns the value of the property with the specified key. |
25 |
protected Graphics getComponentGraphics(Graphics g) Returns the graphics object used to paint this component. |
26 |
JPopupMenu getComponentPopupMenu() Returns JPopupMenu that assigned for this component. |
27 |
int getConditionForKeyStroke(KeyStroke aKeyStroke) Returns the condition that determines whether a registered action occurs in response to the specified keystroke. |
28 |
int getDebugGraphicsOptions() Returns the state of graphics debugging. |
29 |
static Locale getDefaultLocale() Returns the default locale used to initialize each JComponent's locale property upon creation. |
30 |
FontMetrics getFontMetrics(Font font) Gets the FontMetrics for the specified Font. |
31 |
Graphics getGraphics() Returns this component's graphics context, which lets you draw on a component. |
32 |
int getHeight() Returns the current height of this component. |
33 |
boolean getInheritsPopupMenu() Returns true if the JPopupMenu should be inherited from the parent. |
34 |
InputMap getInputMap() Returns the InputMap that is used when the component has focus. |
35 |
InputMap getInputMap(int condition) Returns the InputMap that is used during condition. |
36 |
InputVerifier getInputVerifier() Returns the input verifier for this component. |
37 |
Insets getInsets() If a border has been set on this component, returns the border's insets; otherwise calls super.getInsets. |
38 |
Insets getInsets(Insets insets) Returns an Insets object containing this component's inset values. |
39 |
<T extends EventListener> T[] getListeners(Class<T> listenerType) Returns an array of all the objects currently registered as FooListeners upon this JComponent. |
40 |
Point getLocation(Point rv) Stores the x,y origin of this component into "return value" rv and returns rv. |
41 |
Dimension getMaximumSize() If the maximum size has been set to a non-null value just returns it. |
42 |
Dimension getMinimumSize() If the minimum size has been set to a non-null value just returns it. |
43 |
Component getNextFocusableComponent() Deprecated. As of 1.4, replaced by FocusTraversalPolicy. |
44 |
Point getPopupLocation(MouseEvent event) Returns the preferred location to display the popup menu in this component's coordinate system. |
45 |
Dimension getPreferredSize() If the preferredSize has been set to a non-null value just returns it. |
46 |
KeyStroke[] getRegisteredKeyStrokes() Returns the KeyStrokes that will initiate registered actions. |
47 |
JRootPane getRootPane() Returns the JRootPane ancestor for this component. |
48 |
Dimension getSize(Dimension rv) Stores the width/height of this component into "return value" rv and returns rv. |
49 |
Point getToolTipLocation(MouseEvent event) Returns the tooltip location in this component's coordinate system. |
50 |
String getToolTipText() Returns the tooltip string that has been set with setToolTipText. |
51 |
String getToolTipText(MouseEvent event) Returns the string to be used as the tooltip for event. |
52 |
Container getTopLevelAncestor() 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. |
53 |
TransferHandler getTransferHandler() Gets the transferHandler property. |
54 |
String getUIClassID() |