public class TopComponent
extends javax.swing.JComponent
implements java.io.Externalizable, javax.accessibility.Accessible
| Modifier and Type | Class and Description |
|---|---|
static interface |
TopComponent.Cloneable
Each top component that wishes to be cloned should implement
this interface, so CloneAction can check it and call the cloneComponent
method.
|
static class |
TopComponent.NodeName
This class provides the connection between the node name and
a name of the component.
|
static interface |
TopComponent.Registry
Registry of all top components.
|
javax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
static int |
CLOSE_EACH
Behavior in which a top component closed (by the user) in one workspace
will be removed from every workspace.
|
static int |
CLOSE_LAST
Behavior in which a top component closed (by the user) in one workspace
may be left in other workspaces.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
TopComponent()
Create a top component.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNotify() |
java.util.List |
availableModes(java.util.List modes)
Allows top component to specify list of modes into which can be docked
by end user.
|
boolean |
canClose(Workspace workspace,
boolean last)
This method is called when top component is about to close.
|
boolean |
close()
Closes the top component on current workspace.
|
boolean |
close(Workspace workspace)
Closes the top component on given workspace, if closeOperation
is set to CLOSE_LAST.
|
protected void |
closeNotify()
Deprecated.
Use
componentClosed() instead. |
protected void |
componentActivated()
Called when this component is activated.
|
protected void |
componentClosed()
Called only when top component was closed so that now it is closed
on all workspaces in the system.
|
protected void |
componentDeactivated()
Called when this component is deactivated.
|
protected void |
componentHidden()
Called when
TopComponent was hidden. |
protected void |
componentOpened()
Called only when top component was closed on all workspaces before and
now is opened for the first time on some workspace.
|
protected void |
componentShowing()
Called when
TopComponent is about to be shown. |
javax.accessibility.AccessibleContext |
getAccessibleContext() |
javax.swing.Action[] |
getActions()
Gets the actions which will appear in the popup menu of this component.
|
Node[] |
getActivatedNodes()
Get the set of activated nodes in this component.
|
int |
getCloseOperation()
Get the current close mode for this component.
|
HelpCtx |
getHelpCtx()
Get the help context for this component.
|
java.awt.Image |
getIcon() |
Lookup |
getLookup()
Gets lookup which represents context of this component.
|
static TopComponent.Registry |
getRegistry()
Getter for class that allows obtaining of information about components.
|
SystemAction[] |
getSystemActions()
Deprecated.
Use
getActions() instead. |
UndoRedo |
getUndoRedo()
Get the undo/redo support for this component.
|
boolean |
isOpened()
Finds out if this top component is opened at least on one workspace.
|
boolean |
isOpened(Workspace workspace)
Finds out whether this top component is opened or not on specified
workspace.
|
void |
open()
Show the component on current workspace.
|
void |
open(Workspace workspace)
Show the component on given workspace.
|
protected void |
openNotify()
Deprecated.
Use
componentOpened() instead. |
void |
readExternal(java.io.ObjectInput in)
Deserialize this top component.
|
void |
requestFocus()
Request focus for the window holding this top component.
|
void |
requestVisible()
Set this component visible but not selected or focused if possible.
|
void |
setActivatedNodes(Node[] nodes)
Set the set of activated nodes in this component.
|
void |
setCloseOperation(int closeOperation)
Set the close mode for the component.
|
void |
setIcon(java.awt.Image icon)
Set the icon of this top component.
|
void |
setName(java.lang.String name)
Set the name of this top component.
|
void |
setToolTipText(java.lang.String toolTip)
Sets toolTip for this
TopComponent, adds notification
about the change to its WindowManager.TopComponentManager. |
void |
writeExternal(java.io.ObjectOutput out)
Serialize this top component.
|
protected java.lang.Object |
writeReplace()
Delegates instance of replacer class to be serialized instead
of top component itself.
|
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIadd, 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, transferFocusDownCycle, validate, validateTreeaction, 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, 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, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final int CLOSE_EACH
close() is called.
This is appropriate for top components such as Editor panes which
the user expects to really close (and prompt to save) when closed
in any workspace.public static final int CLOSE_LAST
close().
Appropriate for components containing no user data, for which closing
the component is only likely to result from the user's wanting to remove
it from active view (on the current workspace).public static final TopComponent.Registry getRegistry()
public final Node[] getActivatedNodes()
public final void setActivatedNodes(Node[] nodes)
nodes - activated nodes for this componentpublic UndoRedo getUndoRedo()
public void open()
requestFocus()public void open(Workspace workspace)
workspace - Workspace on which component should be opened.
Parameter can be null -> means current workspace.requestFocus()public final boolean isOpened()
public final boolean isOpened(Workspace workspace)
public void addNotify()
addNotify in class javax.swing.JComponentpublic final boolean close()
public final boolean close(Workspace workspace)
workspace - Workspace on which component should be closed.public boolean canClose(Workspace workspace,
boolean last)
workspace - the workspace on which we are about to close or
null which means that component will be closed
on all workspaces where it is opened (CLOSE_EACH mode)last - true if this is last workspace where top component is
opened, false otherwise. If close operation is set to
CLOSE_EACH, then this param is always trueprotected void openNotify()
componentOpened() instead.protected void closeNotify()
componentClosed() instead.public SystemAction[] getSystemActions()
getActions() instead.public javax.swing.Action[] getActions()
Subclasses are encouraged to override this method to specify their own sets of actions.
Remember to call the super method when overriding and add your actions to the superclass' ones (in some order), because the default implementation provides support for standard component actions like save, close, and clone.
public final void setCloseOperation(int closeOperation)
closeOperation - one of CLOSE_EACH or CLOSE_LASTjava.lang.IllegalArgumentException - if an unrecognized close mode was suppliedclose()public final int getCloseOperation()
CLOSE_EACH or CLOSE_LASTprotected void componentOpened()
protected void componentClosed()
protected void componentShowing()
TopComponent is about to be shown.
Shown here means the component is selected or resides in it own cell
in container in its Mode. The container is visible and not minimized.
Note: component is considered to be shown, even its container window is overlapped by another window.
protected void componentHidden()
TopComponent was hidden. Nore:
Note: Beside typical situations when component is hidden,
it is considered to be hidden even in that case
the component is in Mode container hierarchy,
the cointainer is visible, not minimized,
but the component is neither selected nor in its own cell,
i.e. it has it's own tab, but is not the selected one.
protected void componentActivated()
protected void componentDeactivated()
public void requestFocus()
opened first
if it is not already.
Subclasses should override this method to transfer focus to desired
focusable component. TopComponent itself is not focusable.
See for example org.openide.text.CloneableEditor#requestFocus.
requestFocus in class javax.swing.JComponentpublic void requestVisible()
public void setName(java.lang.String name)
setName in class java.awt.Componentname - the new display namepublic void setToolTipText(java.lang.String toolTip)
TopComponent, adds notification
about the change to its WindowManager.TopComponentManager.setToolTipText in class javax.swing.JComponentpublic void setIcon(java.awt.Image icon)
icon - New components' icon.public java.awt.Image getIcon()
public HelpCtx getHelpCtx()
public java.util.List availableModes(java.util.List modes)
So for example, by returning empty list, top component refuses to be docked anywhere.
Default implementation allows docking anywhere by returning input list unchanged.
modes - list of Mode which represent all modes of current
workspace, can contain nulls. Items are structured in logical groups
separated by null entries. Input array also contains special constant modes for docking into newly created frames. Their names are "SingleNewMode", "MultiNewMode", "SplitNewMode", can be used for their recognition. Please note that names and existence of special modes can change in future releases.
Mode which are available for dock, can contain nullspublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizableout - the stream to serialize tojava.io.IOExceptionpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablein - the stream to deserialize fromjava.io.IOExceptionjava.lang.ClassNotFoundExceptionprotected java.lang.Object writeReplace()
throws java.io.ObjectStreamException
java.io.ObjectStreamExceptionpublic javax.accessibility.AccessibleContext getAccessibleContext()
getAccessibleContext in interface javax.accessibility.AccessiblegetAccessibleContext in class java.awt.Componentpublic Lookup getLookup()
getActivatedNodes
method and result of this component ActionMap delegate.org.openide.util.ContextAwareAction,
org.openide.util.Utilities#actionsToPopup(Action[], Lookup)