org.jdesktop.jdnc
Class JNComponent

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.jdesktop.jdnc.JNComponent
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.DesignMode, java.io.Serializable, javax.accessibility.Accessible, Targetable, MessageSource
Direct Known Subclasses:
JNEditor, JNForm, JNList, JNTable, JNTextField, JNTree

public abstract class JNComponent
extends javax.swing.JPanel
implements Targetable, MessageSource, java.beans.DesignMode

Base class for all JN components.

Author:
Ramesh Gupta, Amy Fowler, Mark Davidson
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.lang.String dataField
           
protected  java.lang.Object dataSource
           
protected  javax.swing.Icon image
           
protected  MessageSourceSupport support
          A reference to the MessageSourceSupport.
protected  javax.swing.JToolBar toolBar
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.beans.DesignMode
PROPERTYNAME
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
protected JNComponent()
          Creates a new JNComponent configured with an instance of BorderLayout.
protected JNComponent(javax.swing.JComponent comp)
           
 
Method Summary
 javax.swing.JButton addAction(javax.swing.Action action)
          Adds the specified action to the end of the tool bar for this component.
 void addMessageListener(MessageListener l)
          Register the MessageListener.
 void addSeparator()
          Adds a separator to the end of the tool bar, if any, for this component.
protected  javax.swing.JToolBar addToolBar()
           
 void addToolBarComponent(javax.swing.JComponent component)
           
 boolean doCommand(java.lang.Object command, java.lang.Object value)
          Perform the command using the object value.
 javax.swing.Icon getBackgroundImage()
          Returns the background image for the component.
 java.lang.Object[] getCommands()
          Returns an array of supported commands.
 javax.swing.JComponent getComponent()
           
 java.lang.String getDataField()
           
 java.lang.Object getDataSource()
           
 MessageListener[] getMessageListeners()
          Returns an array of listeners.
 javax.swing.JPopupMenu getPopupMenu()
           
 boolean hasCommand(java.lang.Object command)
          Return a flag that indicates if a command is supported.
 boolean isDesignTime()
           
 void paint(java.awt.Graphics g)
           
 void removeMessageListener(MessageListener l)
          Unregister the MessageListener from the MessageSource.
protected  void sendMessage(java.lang.String message)
          Convenience method to send a transient message to the MessageListeners
 void setBackground(java.awt.Color bg)
           
 void setBackgroundImage(javax.swing.Icon image)
          Sets the background image for a transparent or translucent component.
protected  void setComponent(javax.swing.JComponent component)
          Set the component that this JNComponent wraps.
 void setDataField(java.lang.String field)
           
 void setDataSource(java.lang.Object dataSource)
           
 void setDesignTime(boolean designTime)
           
 void setEnabled(boolean enabled)
           
 void setFont(java.awt.Font font)
           
 void setForeground(java.awt.Color fg)
           
 void setOpaque(boolean isOpaque)
           
 void setPopupMenu(javax.swing.JPopupMenu popup)
          Sets the popup menu for this component.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class 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, imageUpdate, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

support

protected MessageSourceSupport support
A reference to the MessageSourceSupport. Use the fire methods on this class to send messages to the status bar.


dataField

protected java.lang.String dataField

dataSource

protected java.lang.Object dataSource

toolBar

protected javax.swing.JToolBar toolBar

image

protected javax.swing.Icon image
Constructor Detail

JNComponent

protected JNComponent()
Creates a new JNComponent configured with an instance of BorderLayout.


JNComponent

protected JNComponent(javax.swing.JComponent comp)
Method Detail

setComponent

protected void setComponent(javax.swing.JComponent component)
Set the component that this JNComponent wraps.


getComponent

public javax.swing.JComponent getComponent()

doCommand

public boolean doCommand(java.lang.Object command,
                         java.lang.Object value)
Description copied from interface: Targetable
Perform the command using the object value.

Specified by:
doCommand in interface Targetable
Parameters:
command - is a Action.ACTION_COMMAND_KEY
value - an arbitrary value. Usually this will be EventObject which trigered the command.

getCommands

public java.lang.Object[] getCommands()
Description copied from interface: Targetable
Returns an array of supported commands. If this Targetable doesn't support any commands (which is unlikely) then an empty array is returned.

Specified by:
getCommands in interface Targetable
Returns:
array of supported commands

hasCommand

public boolean hasCommand(java.lang.Object command)
Description copied from interface: Targetable
Return a flag that indicates if a command is supported.

Specified by:
hasCommand in interface Targetable
Parameters:
command - is a Action.ACTION_COMMAND_KEY
Returns:
true if command is supported; false otherwise

addMessageListener

public void addMessageListener(MessageListener l)
Description copied from interface: MessageSource
Register the MessageListener.

Specified by:
addMessageListener in interface MessageSource
Parameters:
l - the listener to register

removeMessageListener

public void removeMessageListener(MessageListener l)
Description copied from interface: MessageSource
Unregister the MessageListener from the MessageSource.

Specified by:
removeMessageListener in interface MessageSource
Parameters:
l - the listener to unregister

getMessageListeners

public MessageListener[] getMessageListeners()
Description copied from interface: MessageSource
Returns an array of listeners.

Specified by:
getMessageListeners in interface MessageSource
Returns:
an non null array of MessageListeners.

sendMessage

protected void sendMessage(java.lang.String message)
Convenience method to send a transient message to the MessageListeners

Parameters:
message - text of message to send

addAction

public javax.swing.JButton addAction(javax.swing.Action action)
Adds the specified action to the end of the tool bar for this component. If no tool bar exists, a new tool bar is automatically created and added to the top of this component.

Parameters:
action - the action added to the tool bar
Returns:
the buton that must be clicked to perform the specified action

addSeparator

public void addSeparator()
Adds a separator to the end of the tool bar, if any, for this component. This method does nothing if there is no tool bar for this component.


addToolBarComponent

public void addToolBarComponent(javax.swing.JComponent component)

setFont

public void setFont(java.awt.Font font)
Overrides:
setFont in class javax.swing.JComponent

setPopupMenu

public void setPopupMenu(javax.swing.JPopupMenu popup)
Sets the popup menu for this component. TODO: if this is not the first time this method is called, should unregister the previous popup listener.


getPopupMenu

public javax.swing.JPopupMenu getPopupMenu()

getBackgroundImage

public javax.swing.Icon getBackgroundImage()
Returns the background image for the component.

Returns:
the background image for the component.

setBackgroundImage

public void setBackgroundImage(javax.swing.Icon image)
Sets the background image for a transparent or translucent component.

Parameters:
image - specifies the background image for the component

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class javax.swing.JComponent

addToolBar

protected javax.swing.JToolBar addToolBar()

setDataSource

public void setDataSource(java.lang.Object dataSource)

getDataSource

public java.lang.Object getDataSource()

setDataField

public void setDataField(java.lang.String field)

getDataField

public java.lang.String getDataField()

setDesignTime

public void setDesignTime(boolean designTime)
Specified by:
setDesignTime in interface java.beans.DesignMode

isDesignTime

public boolean isDesignTime()
Specified by:
isDesignTime in interface java.beans.DesignMode

setBackground

public void setBackground(java.awt.Color bg)
Overrides:
setBackground in class javax.swing.JComponent

setForeground

public void setForeground(java.awt.Color fg)
Overrides:
setForeground in class javax.swing.JComponent

setOpaque

public void setOpaque(boolean isOpaque)
Overrides:
setOpaque in class javax.swing.JComponent

setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class javax.swing.JComponent


Copyright © 2005 Sun Microsystems All Rights Reserved.