swingwtx.swing
Class JComponent

java.lang.Object
  extended byswingwt.awt.Component
      extended byswingwt.awt.Container
          extended byswingwtx.swing.JComponent
All Implemented Interfaces:
ImageObserver, MenuContainer
Direct Known Subclasses:
AbstractButton, JClosableTabbedPane, JComboBox, JCoolBar, JInternalFrame, JLabel, JList, JMenuBar, JPanel, JProgressBar, JScrollBar, JSlider, JSplitPane, JTabbedPane, JTable, JTableHeader, JTaskTrayItem, JTextComponent, JToolBar, JTree

public class JComponent
extends Container


Nested Class Summary
protected  class JComponent.InternalFrameSelectionListener
          Event adapter for managing internal frame selection if this component is an internal frame child.
 
Field Summary
protected  AccessibleContext accessibleContext
          The component's accessible context
protected  ActionMap actionMap
           
protected  InputMap ancestorInputMap
           
protected  Border border
          The border for the component
protected  java.util.Hashtable clientProperties
          The table of client properties
protected  boolean descendantHasPeer
          Whether or not subclasses are supplying a peer in their setSwingWTParent() call - if they don't, this component will supply a Composite peer (this is for Swing code that descends JComopnent and paints on it)
protected  InputMap focusInputMap
           
protected  JComponent.InternalFrameSelectionListener internalFrameAdapter
          Event adapter for calling the setSelection on the JInternalFrame parent if there is one.
protected  JInternalFrame internalFrameParent
          JInternalFrame parent if this component has one
protected  boolean opaque
           
protected  java.util.Vector propertyChangeListeners
           
static int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
           
static int WHEN_FOCUSED
           
static int WHEN_IN_FOCUSED_WINDOW
           
protected  InputMap windowInputMap
           
 
Fields inherited from class swingwt.awt.Container
composite, comps, containerListeners, layout, queuedValidateRequest
 
Fields inherited from class swingwt.awt.Component
actionCommand, actionListeners, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListeners, componentName, consumeAvailableHeight, consumeAvailableWidth, focusable, focusListeners, graphicsConfig, inputMethodListeners, isUserSetFont, keyListeners, layoutModifier, LEFT_ALIGNMENT, LOCK, mouseListeners, mouseMotionListeners, mouseWheelListeners, parent, pBackground, pCursor, pDoubleBuffered, peer, pEnabled, pFont, pForeground, pLayoutData, pLocation, pMaxSize, pMinSize, ppeer, pPrefSize, pSize, pToolTipText, pVisible, RIGHT_ALIGNMENT, swingWTDefaultActionEventAdapter, swingWTEventAdapter, TOP_ALIGNMENT
 
Fields inherited from interface swingwt.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JComponent()
          Creates an empty JComponent which by default will use a Composite peer (allowing you to paint on it).
 
Method Summary
 Component add(Component c)
           
 Component add(Component c, int index)
           
 void add(Component c, java.lang.Object layoutModifier)
          Addition for layouts requiring object based modifiers
 void add(Component c, java.lang.Object layoutModifier, int index)
           
 Component add(java.lang.String name, Component c)
           
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a PropertyChangeListener to the component
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
          Adds a PropertyChangeListener to the component
protected  void checkInternalFrameChild()
          Checks whether this JComponent is a child of a JInternalFrame and if so, attaches a focus and mouse listener - when the component is clicked/gets the focus, the desktop pane of the JInternalFrame is called to tell it to make the frame active.
 void dispose()
          Destroys the component
 AccessibleContext getAccessibleContext()
          Override in subclass to return something more specific
 ActionMap getActionMap()
           
 boolean getAutoscrolls()
          NOT IMPLEMENTED
 Border getBorder()
          Returns the components border.
 java.lang.Object getClientProperty(java.lang.Object key)
          Retrieves a property from the client, or null if the key does not exist.
 InputMap getInputMap(int condition, boolean create)
          Gets the InputMap for this component
 Insets getInsets()
          Returns the Insets for the components (taking into account any Border)
 Point getToolTipLocation(MouseEvent e)
          Returns the appropriate location for the tooltip text for a given mouse event.
 java.lang.String getToolTipText(MouseEvent e)
          Returns the appropriate tooltip text for a given MouseEvent.
 Container getTopLevelAncestor()
          Retrieves the top-level ancestor of this component (submitted by Fernando Petrola)
 Rectangle getVisibleRect()
          Not implemented correctly - rather than returning the visible portion of the component, this returns a Rectangle sized to match the component
 boolean isDoubleBuffered()
          Whether or not this component is using double-buffering.
 boolean isOpaque()
          Hardcoded to return true - there's no other way for platform widgets.
 boolean isOptimizedDrawingEnabled()
          Always returns true - we're using native widgets!
 boolean isValidateRoot()
          Used to determine whether this component is a top level container (overriden in subclasses), so validation code knows to work up the tree to that point before validating down.
 void paint(Graphics g)
          Paints this component and any associated borders on it.
 void paintBackground(int x, int y, int width, int height)
           
protected  void paintChildren(Graphics g)
          NOT IMPLEMENTED
protected  void paintComponent(Graphics g)
          Override in subclass
 void paintImmediately(int x, int y, int w, int h)
          Forces a repaint of the whole component
 void paintImmediately(Rectangle r)
          Forces a repaint of the whole component.
 void putClientProperty(java.lang.Object key, java.lang.Object value)
          Sets a property against the component
 void remove(Component c)
          Removes a component from the the container by destroying the peer.
 void remove(int index)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a PropertyChangeListener from the component
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
          Removes a PropertyChangeListener from the component
 void repaint(Rectangle r)
          Forces a repaint of a specified rectangle (actually repaints the whole thing)
 void revalidate()
          Calls invalidate
 void scrollRectToVisible(Rectangle aRect)
          NOT IMPLEMENTED - used to scroll parent JViewPort containers to the specified rectangle
 void setActionMap(ActionMap actionMap)
           
 void setAutoscrolls(boolean b)
          NOT IMPLEMENTED
 void setBorder(Border b)
          Sets the components border
 void setDoubleBuffered(boolean b)
          Used to determine whether or not to double buffer the component.
 void setInputMap(int condition, InputMap inputMap)
          Sets the InputMap for this component
 void setMargin(Insets i)
          NOT IMPLEMENTED
 void setNextFocusableComponent(Component acomponent)
          NOT IMPLEMENTED
 void setOpaque(boolean b)
          Ignored - platform widgets are always opaque
 void setPreferredSize(Dimension d)
          Overridden here - we still use the implementation in the superclass, but we are just checking if we are in a scrollpane container and set the preferred size on that if necessary.
 void setRequestFocusEnabled(boolean b)
          NOT IMPLEMENTED
 void setSwingWTParent(Container parent)
          Callback for when this JComponent is added to a container.
 
Methods inherited from class swingwt.awt.Container
addComponentToLayout, addContainerListener, debug_showContainmentTree, doAdd, doLayout, getComponent, getComponentCount, getComponentOrientation, getComponents, getComposite, getLayout, getMaximumSize, getMinimumSize, getParent, getPreferredSize, invalidate, minimumSize, preferredSize, processContainerEvent, processEvent, queuedValidate, removeAll, removeComponentFromCache, removeContainerListener, setLayout, setLayoutImpl, validate
 
Methods inherited from class swingwt.awt.Component
add, addActionListener, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, calculatePreferredSize, componentOnlyDispose, computePreferredSize, contains, contains, createImage, createListenerArrayFromVector, createVolatileImage, dispatchEvent, getActionCommand, getAlignmentX, getAlignmentY, getBackground, getBounds, getCursor, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getListeners, getLocation, getLocationOnScreen, getName, getPeer, getPeerSize, getSize, getSize, getSWTPeer, getToolkit, getToolTipText, getTreeLock, getWidth, getX, getY, grabFocus, hasFocus, hasSetFont, hide, imageUpdate, inside, isEnabled, isFocusable, isMinimumSizeSet, isShowing, isVisible, processActionEvent, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, processTraverseEvent, registerActionEvents, registerComponentEvents, registerEvents, registerExtendedModifyEvents, registerFocusEvents, registerKeyEvents, registerModifyEvents, registerMouseEvents, registerPaintEvents, registerTraversalEvents, remove, removeActionListener, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, repaint, repaint, repaint, requestFocus, setActionCommand, setAlignmentX, setAlignmentY, setBackground, setBounds, setBounds, setCachedProperties, setComponentOrientation, setComponentRemoved, setCursor, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setFont, setForeground, setHeight, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setSize, setSize, setToolTipText, setVisible, setWidth, show, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

border

protected Border border
The border for the component


accessibleContext

protected AccessibleContext accessibleContext
The component's accessible context


descendantHasPeer

protected boolean descendantHasPeer
Whether or not subclasses are supplying a peer in their setSwingWTParent() call - if they don't, this component will supply a Composite peer (this is for Swing code that descends JComopnent and paints on it)


clientProperties

protected java.util.Hashtable clientProperties
The table of client properties


opaque

protected boolean opaque

focusInputMap

protected InputMap focusInputMap

ancestorInputMap

protected InputMap ancestorInputMap

windowInputMap

protected InputMap windowInputMap

actionMap

protected ActionMap actionMap

propertyChangeListeners

protected java.util.Vector propertyChangeListeners

WHEN_FOCUSED

public static final int WHEN_FOCUSED
See Also:
Constant Field Values

WHEN_ANCESTOR_OF_FOCUSED_COMPONENT

public static final int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
See Also:
Constant Field Values

WHEN_IN_FOCUSED_WINDOW

public static final int WHEN_IN_FOCUSED_WINDOW
See Also:
Constant Field Values

internalFrameAdapter

protected JComponent.InternalFrameSelectionListener internalFrameAdapter
Event adapter for calling the setSelection on the JInternalFrame parent if there is one.


internalFrameParent

protected JInternalFrame internalFrameParent
JInternalFrame parent if this component has one

Constructor Detail

JComponent

public JComponent()
Creates an empty JComponent which by default will use a Composite peer (allowing you to paint on it).

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a PropertyChangeListener to the component


addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener l)
Adds a PropertyChangeListener to the component


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener from the component


removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener from the component


add

public void add(Component c,
                java.lang.Object layoutModifier)
Description copied from class: Container
Addition for layouts requiring object based modifiers

Overrides:
add in class Container

add

public void add(Component c,
                java.lang.Object layoutModifier,
                int index)
Overrides:
add in class Container

add

public Component add(java.lang.String name,
                     Component c)
Overrides:
add in class Container

add

public Component add(Component c)
Overrides:
add in class Container

add

public Component add(Component c,
                     int index)
Overrides:
add in class Container

remove

public void remove(Component c)
Description copied from class: Container
Removes a component from the the container by destroying the peer.

Overrides:
remove in class Container

remove

public void remove(int index)
Overrides:
remove in class Container

checkInternalFrameChild

protected void checkInternalFrameChild()
Checks whether this JComponent is a child of a JInternalFrame and if so, attaches a focus and mouse listener - when the component is clicked/gets the focus, the desktop pane of the JInternalFrame is called to tell it to make the frame active. Of course, it only does this if the JDesktopPane is not using tabbed emulation (as you can't see other child components in tabbed emulation).


paintImmediately

public void paintImmediately(int x,
                             int y,
                             int w,
                             int h)
Forces a repaint of the whole component


paintImmediately

public void paintImmediately(Rectangle r)
Forces a repaint of the whole component. Calls the Component.repaint() method in the superclass


repaint

public void repaint(Rectangle r)
Forces a repaint of a specified rectangle (actually repaints the whole thing)


paintComponent

protected void paintComponent(Graphics g)
Override in subclass

Overrides:
paintComponent in class Component

paintChildren

protected void paintChildren(Graphics g)
NOT IMPLEMENTED


paintBackground

public void paintBackground(int x,
                            int y,
                            int width,
                            int height)

paint

public void paint(Graphics g)
Paints this component and any associated borders on it. Note that if no subclass overrides the paint method, the component tells the native bits to show a widget and nothing else happens

Overrides:
paint in class Component

getBorder

public Border getBorder()
Returns the components border.


setBorder

public void setBorder(Border b)
Sets the components border


setRequestFocusEnabled

public void setRequestFocusEnabled(boolean b)
NOT IMPLEMENTED


setAutoscrolls

public void setAutoscrolls(boolean b)
NOT IMPLEMENTED


getToolTipText

public java.lang.String getToolTipText(MouseEvent e)
Returns the appropriate tooltip text for a given MouseEvent. Since platform lacks Swing's flexibility in this regard, always returns super.getToolTipText()


getTopLevelAncestor

public Container getTopLevelAncestor()
Retrieves the top-level ancestor of this component (submitted by Fernando Petrola)


getToolTipLocation

public Point getToolTipLocation(MouseEvent e)
Returns the appropriate location for the tooltip text for a given mouse event. This will just read the X/Y location of the cursor from the mouse event and return that.


getAutoscrolls

public boolean getAutoscrolls()
NOT IMPLEMENTED

Returns:
true

isOpaque

public boolean isOpaque()
Hardcoded to return true - there's no other way for platform widgets.


setOpaque

public void setOpaque(boolean b)
Ignored - platform widgets are always opaque


isDoubleBuffered

public boolean isDoubleBuffered()
Whether or not this component is using double-buffering. Only applies to components with Canvas peers, as the platform is responsible for painting widgets


setDoubleBuffered

public void setDoubleBuffered(boolean b)
Used to determine whether or not to double buffer the component. This only has meaning for Canvas peers, and if this is true, the subclass paint() method will receive a graphics context for a buffered image to paint on, which will then be painted onto the component. Otherwise, the paint() method will receive the component's graphics context to paint on.


scrollRectToVisible

public void scrollRectToVisible(Rectangle aRect)
NOT IMPLEMENTED - used to scroll parent JViewPort containers to the specified rectangle


revalidate

public void revalidate()
Calls invalidate

Overrides:
revalidate in class Container

getClientProperty

public final java.lang.Object getClientProperty(java.lang.Object key)
Retrieves a property from the client, or null if the key does not exist.


getVisibleRect

public Rectangle getVisibleRect()
Not implemented correctly - rather than returning the visible portion of the component, this returns a Rectangle sized to match the component


putClientProperty

public final void putClientProperty(java.lang.Object key,
                                    java.lang.Object value)
Sets a property against the component


setMargin

public void setMargin(Insets i)
NOT IMPLEMENTED


getAccessibleContext

public AccessibleContext getAccessibleContext()
Override in subclass to return something more specific

Overrides:
getAccessibleContext in class Component

isValidateRoot

public boolean isValidateRoot()
Used to determine whether this component is a top level container (overriden in subclasses), so validation code knows to work up the tree to that point before validating down.


isOptimizedDrawingEnabled

public boolean isOptimizedDrawingEnabled()
Always returns true - we're using native widgets!


setNextFocusableComponent

public void setNextFocusableComponent(Component acomponent)
NOT IMPLEMENTED


getInsets

public Insets getInsets()
Returns the Insets for the components (taking into account any Border)

Overrides:
getInsets in class Container

setPreferredSize

public void setPreferredSize(Dimension d)
Overridden here - we still use the implementation in the superclass, but we are just checking if we are in a scrollpane container and set the preferred size on that if necessary.

Overrides:
setPreferredSize in class Component

setInputMap

public final void setInputMap(int condition,
                              InputMap inputMap)
Sets the InputMap for this component


getInputMap

public final InputMap getInputMap(int condition,
                                  boolean create)
Gets the InputMap for this component


setActionMap

public final void setActionMap(ActionMap actionMap)

getActionMap

public final ActionMap getActionMap()

dispose

public void dispose()
Destroys the component

Overrides:
dispose in class Container

setSwingWTParent

public void setSwingWTParent(Container parent)
                      throws java.lang.Exception
Callback for when this JComponent is added to a container.

Overrides:
setSwingWTParent in class Container
Throws:
java.lang.Exception