Example usage for Java javax.swing JComponent fields, constructors, methods, implement or subclass
The text is from its open source code.
int | WHEN_FOCUSED Constant used for registerKeyboardAction that means that the command should be invoked when the component has the focus. |
int | WHEN_ANCESTOR_OF_FOCUSED_COMPONENT Constant used for registerKeyboardAction that means that the command should be invoked when the receiving component is an ancestor of the focused component or is itself the focused component. |
int | WHEN_IN_FOCUSED_WINDOW Constant used for registerKeyboardAction that 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. |
JComponent() Default JComponent constructor. |
Component | add(Component comp) Appends the specified component to the end of this container. |
Component | add(String name, Component comp) Adds the specified component to this container. |
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. |
void | addComponentListener(ComponentListener l) Adds the specified component listener to receive component events from this component. |
void | addFocusListener(FocusListener l) Adds the specified focus listener to receive focus events from this component when this component gains input focus. |
void | addHierarchyListener(HierarchyListener l) Adds the specified hierarchy listener to receive hierarchy changed events from this component when the hierarchy to which this container belongs changes. |
void | addKeyListener(KeyListener l) Adds the specified key listener to receive key events from this component. |
void | addMouseListener(MouseListener l) Adds the specified mouse listener to receive mouse events from this component. |
void | addMouseMotionListener(MouseMotionListener l) Adds the specified mouse motion listener to receive mouse motion events from this component. |
void | addPropertyChangeListener(PropertyChangeListener listener) Adds a PropertyChangeListener to the listener list. |
void | addPropertyChangeListener(String propertyName, PropertyChangeListener listener) Adds a PropertyChangeListener to the listener list for a specific property. |
void | addVetoableChangeListener(VetoableChangeListener listener) Adds a VetoableChangeListener to the listener list. |
Image | createImage(ImageProducer producer) Creates an image from the specified image producer. |
void | doLayout() Causes this container to lay out its components. |
boolean | equals(Object obj) Indicates whether some other object is "equal to" this one. |
AccessibleContext | getAccessibleContext() Gets the AccessibleContext associated with this Component . |
ActionMap | getActionMap() Returns the ActionMap used to determine what Action to fire for particular KeyStroke binding. |
AncestorListener[] | getAncestorListeners() Returns an array of all the ancestor listeners registered on this component. |
Color | getBackground() Gets the background color of this component. |
Border | getBorder() Returns the border of this component or null if no border is currently set. |
Rectangle | getBounds() Gets the bounds of this component in the form of a Rectangle object. |
Class> | getClass() Returns the runtime class of this Object . |
Object | getClientProperty(Object key) Returns the value of the property with the specified key. |
Component | getComponent(int n) Gets the nth component in this container. |
int | getComponentCount() Gets the number of components in this panel. |
ComponentListener[] | getComponentListeners() Returns an array of all the component listeners registered on this component. |
ComponentOrientation | getComponentOrientation() Retrieves the language-sensitive orientation that is to be used to order the elements or text within this component. |
JPopupMenu | getComponentPopupMenu() Returns JPopupMenu that assigned for this component. |
Component[] | getComponents() Gets all the components in this container. |
Locale | getDefaultLocale() Returns the default locale used to initialize each JComponent's locale property upon creation. |
FocusListener[] | getFocusListeners() Returns an array of all the focus listeners registered on this component. |
Set | getFocusTraversalKeys(int id) Returns the Set of focus traversal keys for a given traversal operation for this Container. |
Font | getFont() Gets the font of this component. |
FontMetrics | getFontMetrics(Font font) Gets the FontMetrics for the specified Font . |
Color | getForeground() Gets the foreground color of this component. |
Graphics | getGraphics() Returns this component's graphics context, which lets you draw on a component. |
int | getHeight() Returns the current height of this component. |
HierarchyBoundsListener[] | getHierarchyBoundsListeners() Returns an array of all the hierarchy bounds listeners registered on this component. |
HierarchyListener[] | getHierarchyListeners() Returns an array of all the hierarchy listeners registered on this component. |
InputMap | getInputMap(int condition) Returns the InputMap that is used during condition . |
InputMap | getInputMap() Returns the InputMap that is used when the component has focus. |
InputMethodListener[] | getInputMethodListeners() Returns an array of all the input method listeners registered on this component. |
Insets | getInsets() If a border has been set on this component, returns the border's insets; otherwise calls super.getInsets . |
Insets | getInsets(Insets insets) Returns an Insets object containing this component's inset values. |
KeyListener[] | getKeyListeners() Returns an array of all the key listeners registered on this component. |
LayoutManager | getLayout() Gets the layout manager for this container. |
Point | getLocationOnScreen() Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space. |
Dimension | getMaximumSize() If the maximum size has been set to a non- null value just returns it. |
Dimension | getMinimumSize() If the minimum size has been set to a non- null value just returns it. |
MouseListener[] | getMouseListeners() Returns an array of all the mouse listeners registered on this component. |
MouseMotionListener[] | getMouseMotionListeners() Returns an array of all the mouse motion listeners registered on this component. |
MouseWheelListener[] | getMouseWheelListeners() Returns an array of all the mouse wheel listeners registered on this component. |
String | getName() Gets the name of the component. |
Container | getParent() Gets the parent of this component. |
Dimension | getPreferredSize() If the preferredSize has been set to a non-null value just returns it. |
PropertyChangeListener[] | getPropertyChangeListeners() Returns an array of all the property change listeners registered on this component. |
JRootPane | getRootPane() Returns the JRootPane ancestor for this component. |
Dimension | getSize() Returns the size of this component in the form of a Dimension object. |
Toolkit | getToolkit() Gets the toolkit of this component. |
String | getToolTipText(MouseEvent event) Returns the string to be used as the tooltip for event. |
String | getToolTipText() Returns the tooltip string that has been set with setToolTipText . |
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. |
TransferHandler | getTransferHandler() Gets the transferHandler property. |
Object | getTreeLock() Gets this component's locking object (the object that owns the thread synchronization monitor) for AWT component-tree and layout operations. |
String | getUIClassID() Returns the UIDefaults key used to look up the name of the swing.plaf.ComponentUI class that defines the look and feel for this component. |
VetoableChangeListener[] | getVetoableChangeListeners() Returns an array of all the vetoable change listeners registered on this component. |
Rectangle | getVisibleRect() Returns the Component 's "visible rectangle" - the intersection of this component's visible rectangle, new Rectangle(0, 0, getWidth(), getHeight()) , and all of its ancestors' visible rectangles. |
int | getWidth() Returns the current width of this component. |
boolean | hasFocus() Returns true if this Component is the focus owner. |
void | invalidate() Invalidates the container. |
boolean | isEnabled() Determines whether this component is enabled. |
boolean | isFocusable() Returns whether this Component can be focused. |
boolean | isFocusOwner() Returns true if this Component is the focus owner. |
boolean | isOpaque() Returns true if this component is completely opaque. |
boolean | isRequestFocusEnabled() Returns true if this JComponent should get focus; otherwise returns false . |
boolean | isShowing() Determines whether this component is showing on screen. |
boolean | isVisible() Determines whether this component should be visible when its parent is visible. |
void | paint(Graphics g) Invoked by Swing to draw components. |
void | paintImmediately(Rectangle r) Paints the specified region now. |
void | paintImmediately(int x, int y, int w, int h) Paints the specified region in this component and all of its descendants that overlap the region, immediately. |
void | print(Graphics g) Invoke this method to print the component to the specified Graphics . |
void | putClientProperty(Object key, Object value) Adds an arbitrary key/value "client property" to this component. |
void | registerKeyboardAction(ActionListener anAction, KeyStroke aKeyStroke, int aCondition) This method is now obsolete, please use a combination of getActionMap() and getInputMap() for similar behavior. |
void | remove(int index) Removes the component, specified by index , from this container. |
void | removeAll() Removes all the components from this container. |
void | removeAncestorListener(AncestorListener listener) Unregisters listener so that it will no longer receive AncestorEvents . |
void | removeComponentListener(ComponentListener l) Removes the specified component listener so that it no longer receives component events from this component. |
void | removeFocusListener(FocusListener l) Removes the specified focus listener so that it no longer receives focus events from this component. |
void | removeHierarchyBoundsListener(HierarchyBoundsListener l) Removes the specified hierarchy bounds listener so that it no longer receives hierarchy bounds events from this component. |
void | removeHierarchyListener(HierarchyListener l) Removes the specified hierarchy listener so that it no longer receives hierarchy changed events from this component. |
void | removeInputMethodListener(InputMethodListener l) Removes the specified input method listener so that it no longer receives input method events from this component. |
void | removeKeyListener(KeyListener l) Removes the specified key listener so that it no longer receives key events from this component. |
void | removeMouseListener(MouseListener l) Removes the specified mouse listener so that it no longer receives mouse events from this component. |
void | removeMouseMotionListener(MouseMotionListener l) Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component. |
void | removeMouseWheelListener(MouseWheelListener l) Removes the specified mouse wheel listener so that it no longer receives mouse wheel events from this component. |
void | removeNotify() Notifies this component that it no longer has a parent component. |
void | removePropertyChangeListener(PropertyChangeListener listener) Removes a PropertyChangeListener from the listener list. |
void | removeVetoableChangeListener(VetoableChangeListener listener) Removes a VetoableChangeListener from the listener list. |
void | repaint() Repaints this component. |
void | requestFocus() Requests that this Component gets the input focus. |
boolean | requestFocusInWindow() Requests that this Component gets the input focus. |
void | revalidate() Supports deferred automatic layout. |
void | scrollRectToVisible(Rectangle aRect) Forwards the scrollRectToVisible() message to the JComponent 's parent. |
void | setActionMap(ActionMap am) Sets the ActionMap to am . |
void | setAlignmentX(float alignmentX) Sets the horizontal alignment. |
void | setAlignmentY(float alignmentY) Sets the vertical alignment. |
void | setBackground(Color bg) Sets the background color of this component. |
void | setBorder(Border border) Sets the border of this component. |
void | setBounds(Rectangle r) Moves and resizes this component to conform to the new bounding rectangle r . |
void | setBounds(int x, int y, int width, int height) Moves and resizes this component. |
void | setComponentOrientation(ComponentOrientation o) Sets the language-sensitive orientation that is to be used to order the elements or text within this component. |
void | setComponentPopupMenu(JPopupMenu popup) Sets the JPopupMenu for this JComponent . |
void | setCursor(Cursor cursor) Sets the cursor image to the specified cursor. |
void | setDefaultLocale(Locale l) Sets the default locale used to initialize each JComponent's locale property upon creation. |
void | setDoubleBuffered(boolean aFlag) Sets whether this component should use a buffer to paint. |
void | setEnabled(boolean enabled) Sets whether or not this component is enabled. |
void | setFocusable(boolean focusable) Sets the focusable state of this Component to the specified value. |
void | setFocusTraversalKeys(int id, Set extends AWTKeyStroke> keystrokes) Sets the focus traversal keys for a given traversal operation for this Component. |
void | setFont(Font font) Sets the font for this component. |
void | setForeground(Color fg) Sets the foreground color of this component. |
void | setInputMap(int condition, InputMap map) Sets the InputMap to use under the condition condition to map . |
void | setInputVerifier(InputVerifier inputVerifier) Sets the input verifier for this component. |
void | setLayout(LayoutManager mgr) Sets the layout manager for this container. |
void | setLocation(int x, int y) Moves this component to a new location. |
void | setMaximumSize(Dimension maximumSize) Sets the maximum size of this component to a constant value. |
void | setMinimumSize(Dimension minimumSize) Sets the minimum size of this component to a constant value. |
void | setName(String name) Sets the name of the component to the specified string. |
void | setOpaque(boolean isOpaque) If true the component paints every pixel within its bounds. |
void | setPreferredSize(Dimension preferredSize) Sets the preferred size of this component. |
void | setRequestFocusEnabled(boolean requestFocusEnabled) Provides a hint as to whether or not this JComponent should get focus. |
void | setSize(Dimension d) Resizes this component so that it has width d.width and height d.height . |
void | setSize(int width, int height) Resizes this component so that it has width width and height height . |
void | setToolTipText(String text) Registers the text to display in a tool tip. |
void | setTransferHandler(TransferHandler newHandler) Sets the TransferHandler , which provides support for transfer of data into and out of this component via cut/copy/paste and drag and drop. |
void | setVerifyInputWhenFocusTarget(boolean verifyInputWhenFocusTarget) Sets the value to indicate whether input verifier for the current focus owner will be called before this component requests focus. |
void | setVisible(boolean aFlag) Makes the component visible or invisible. |
String | toString() Returns a string representation of this component and its values. |
void | updateUI() Resets the UI property to a value from the current look and feel. |
void | validate() Validates this container and all of its subcomponents. |