org.jdesktop.jdnc
Class JNComponent

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.jdesktop.jdnc.JNComponent
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, MessageSource, Serializable, Targetable
Direct Known Subclasses:
JNEditor, JNForm, JNTable, JNTree

public class JNComponent
extends JPanel
implements Targetable, MessageSource

Base class for all JN components.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Icon image
           
protected  MessageSourceSupport support
          A reference to the MessageSourceSupport.
protected  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.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JNComponent()
          Creates a new JNComponent configured with an instance of BorderLayout.
 
Method Summary
 JButton addAction(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  JToolBar addToolBar()
           
 void addToolBarComponent(JComponent component)
           
 boolean doCommand(Object command, Object value)
          Perform the command using the object value.
 Icon getBackgroundImage()
          Returns the background image for the component.
 Object[] getCommands()
          Returns an array of supported commands.
 JComponent getComponent()
           
 MessageListener[] getMessageListeners()
          Returns an array of listeners.
 JPopupMenu getPopupMenu()
           
 boolean hasCommand(Object command)
          Return a flag that indicates if a command is supported.
 void paint(Graphics g)
           
 void removeMessageListener(MessageListener l)
          Unregister the MessageListener from the MessageSource.
protected  void sendMessage(String message)
          Convenience method to send a transient message to the MessageListeners
 void setBackgroundImage(Icon image)
          Sets the background image for a transparent or translucent component.
 void setComponent(JComponent component)
          Set the component that this JNComponent wraps.
 void setFont(Font font)
           
 void setPopupMenu(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, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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.


toolBar

protected JToolBar toolBar

image

protected Icon image
Constructor Detail

JNComponent

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

Method Detail

setComponent

public void setComponent(JComponent component)
Set the component that this JNComponent wraps.


getComponent

public JComponent getComponent()

doCommand

public boolean doCommand(Object command,
                         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 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(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(String message)
Convenience method to send a transient message to the MessageListeners

Parameters:
message - text of message to send

addAction

public JButton addAction(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(JComponent component)

setFont

public void setFont(Font font)

setPopupMenu

public void setPopupMenu(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 JPopupMenu getPopupMenu()

getBackgroundImage

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

Returns:
the background image for the component.

setBackgroundImage

public void setBackgroundImage(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(Graphics g)

addToolBar

protected JToolBar addToolBar()


Copyright 2004 by Sun Microsystems, Inc. All Rights Reserved.