Class TopComponent
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Externalizable
,Serializable
,Accessible
,org.openide.util.HelpCtx.Provider
,org.openide.util.Lookup.Provider
- Direct Known Subclasses:
CloneableTopComponent
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Each top component that wishes to be cloned should implement this interface, so CloneAction can check it and call the cloneComponent method.static @interface
Provides basic information about the persistence of aTopComponent
.static class
Deprecated.Please do not use.static @interface
Creates an action that can open the component.static @interface
RegistersTopComponent
into specified location among existingwindow system modes
.static interface
Registry of all top components.static final class
Representation of a visual sub-component displayed in a TopComponent, for example sub-tabs in a multiview window.Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Deprecated.Do not use.static final int
Deprecated.Do not use.static final int
Persistence type of TopComponent instance.static final int
Persistence type of TopComponent instance.static final int
Persistence type of TopComponent instance.static final String
Name of TopComponent's Boolean client property which removes close button from TopComponent's header and disables its 'Close Window' action when set to Boolean.TRUE.static final String
Name of TopComponent's Boolean client property which disables 'copy' drag and drop action of this TopComponent when set to Boolean.TRUE.static final String
Name of TopComponent's Boolean client property which disables drag and drop when set to Boolean.TRUE.static final String
Name of TopComponent's Boolean client property which forces the window system to respect TopComponent's preferred size when it is slided-in from left/right/bottom sliding bar when set to Boolean.TRUE.static final String
Name of TopComponent's Boolean client property which disables TopComponent maximization by double-clicking its header when set to Boolean.TRUE.static final String
Name of TopComponent's Boolean client property which removes 'minimized' button from TopComponent's header and disables its 'Minimize Window' action when set to Boolean.TRUE.static final String
Name of TopComponent's Boolean client property which disables TopComponent's 'Undock Window' action when set to Boolean.TRUE.Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
ConstructorsConstructorDescriptionCreate a top component.TopComponent
(org.openide.util.Lookup lookup) Creates a top component for a provided lookup that will delegate take and synchronize activated nodes and ActionMap from a provided lookup. -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected final void
associateLookup
(org.openide.util.Lookup lookup) Associates the provided lookup with the component.availableModes
(List<Mode> modes) Allows top component to specify list of modes into which can be docked by end user.final void
Cause this TopComponent's tab to stop flashing if it was flashing.boolean
canClose()
This method is called when thisTopComponent
is about to close.boolean
Deprecated.Do not use anymore.final boolean
close()
Closes thisTopComponent
.final boolean
Deprecated.Useclose()
instead.protected void
Deprecated.UsecomponentClosed()
instead.protected void
Called when this component is activated.protected void
Called only when top component was closed so that now it is closed on all workspaces in the system.protected void
Called when this component is deactivated.protected void
Called whenTopComponent
was hidden.protected void
Called only when top component was closed on all workspaces before and now is opened for the first time on some workspace.protected void
Called whenTopComponent
is about to be shown.Action[]
Gets the actions which will appear in the popup menu of this component.final org.openide.nodes.Node[]
Get the set of activated nodes in this component.final int
Deprecated.Do not use.Gets localized display name of thisTopComponent
.org.openide.util.HelpCtx
Get the help context for this component.Gets localized display name of thisTopComponent
with added html tags for text coloring and/or font style.getIcon()
Rather than overriding this method, consider usingTopComponent.Description
.org.openide.util.Lookup
Gets a lookup which represents the "selection" of this component.int
Rather than overriding this method, consider usingTopComponent.Description
.static final TopComponent.Registry
Getter for class that allows obtaining of information about components.Short version of TopComponent's name that doesn't include the name of activated Node.Retrieves sub-components this TopComponent contains.org.openide.util.actions.SystemAction[]
Deprecated.UsegetActions()
instead.final int
Gives position index of opened TopComponent in the mode.org.openide.awt.UndoRedo
Get the undo/redo support for this component.final boolean
isOpened()
Indicates whether thisTopComponent
is opened.final boolean
Deprecated.UseisOpened()
instead.final void
makeBusy
(boolean busy) Notify the user that some (possibly lengthy) process is being run in this window.void
open()
Shows thisTopComponent
.void
Deprecated.Useopen()
instead.static Action
openAction
(TopComponent component, String displayName, String iconBase, boolean noIconInMenu) Creates an action that opens and activates givenTopComponent
, when invoked.final void
openAtTabPosition
(int position) Opens TopComponent at given position in the mode.protected void
Deprecated.UsecomponentOpened()
instead.protected String
Rather than overriding this method, consider usingTopComponent.Description
.protected boolean
processKeyBinding
(KeyStroke ks, KeyEvent e, int condition, boolean pressed) Overrides superclass method, adds possible additional handling of global keystrokes in case thisTopComoponent
is ancestor of focused component.void
Deserialize this top component.void
Activates thisTopComponent
if it is opened.final void
requestAttention
(boolean brief) Cause this TopComponent's tab to flash or otherwise draw attention to itself.void
Request focus for the window holding this top component.boolean
Request focus for the top component inside focused window.void
Selects thisTopComponent
, if it is opened, but does not activate it unless it is in active mode already.final void
setActivatedNodes
(org.openide.nodes.Node[] activatedNodes) Set the set of activated nodes in this component.final void
setAttentionHighlight
(boolean highlight) Permanently highlights this TopComponent's tab until user activates it.final void
setCloseOperation
(int closeOperation) Deprecated.Do not use.void
setDisplayName
(String displayName) Sets localized display name of thisTopComponent
.void
setHtmlDisplayName
(String htmlDisplayName) Sets localized html display name of thisTopComponent
.void
Set the icon of this top component.void
Set the name of this top component.void
setToolTipText
(String toolTip) Sets toolTip for thisTopComponent
, adds notification about the change to itsWindowManager.TopComponentManager
.void
toFront()
Attempts to bring the parentWindow
orFrame
of thisTopComponent
to front of other windows.void
Serialize this top component.protected Object
Delegates instance of replacer class to be serialized instead of top component itself.Methods inherited from class javax.swing.JComponent
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, getUI, 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, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, 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, updateUI
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, 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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
CLOSE_EACH
Deprecated.Do not use. It is redundant since workspaces are not supported anymore.Behavior in which a top component closed (by the user) in one workspace will be removed from every workspace. Also,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- See Also:
-
CLOSE_LAST
Deprecated.Do not use. It is redundant since workspaces are not supported anymore.Behavior in which a top component closed (by the user) in one workspace may be left in other workspaces. Only when the last remaining manifestation in any workspace is closed will the object be deleted usingclose()
. 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).- See Also:
-
PERSISTENCE_ALWAYS
public static final int PERSISTENCE_ALWAYSPersistence type of TopComponent instance. TopComponent is persistent.- See Also:
-
PERSISTENCE_ONLY_OPENED
public static final int PERSISTENCE_ONLY_OPENEDPersistence type of TopComponent instance. TopComponent is persistent only when it is opened in Mode.- See Also:
-
PERSISTENCE_NEVER
public static final int PERSISTENCE_NEVERPersistence type of TopComponent instance. TopComponent is not persistent.- See Also:
-
PROP_KEEP_PREFERRED_SIZE_WHEN_SLIDED_IN
Name of TopComponent's Boolean client property which forces the window system to respect TopComponent's preferred size when it is slided-in from left/right/bottom sliding bar when set to Boolean.TRUE. Otherwise the slided-in TopComponent will fill the entire width/length of the IDE window (the default behavior). This switch is intended for tools/palette windows like e.g. color chooser, tool picker etc.- Since:
- 6.26
- See Also:
-
PROP_CLOSING_DISABLED
Name of TopComponent's Boolean client property which removes close button from TopComponent's header and disables its 'Close Window' action when set to Boolean.TRUE.- Since:
- 6.26
- See Also:
-
PROP_SLIDING_DISABLED
Name of TopComponent's Boolean client property which removes 'minimized' button from TopComponent's header and disables its 'Minimize Window' action when set to Boolean.TRUE. TopComponents which are already slided-out and have this property set to Boolean.TRUE will have 'pin' button removed from their header and their 'Minimize Window' action will be disabled.- Since:
- 6.26
- See Also:
-
PROP_UNDOCKING_DISABLED
Name of TopComponent's Boolean client property which disables TopComponent's 'Undock Window' action when set to Boolean.TRUE. TopComponents which are already floating and have this property set to Boolean.TRUE will have their 'Dock Window' action disabled.- Since:
- 6.26
- See Also:
-
PROP_DRAGGING_DISABLED
Name of TopComponent's Boolean client property which disables drag and drop when set to Boolean.TRUE.- Since:
- 6.26
- See Also:
-
PROP_MAXIMIZATION_DISABLED
Name of TopComponent's Boolean client property which disables TopComponent maximization by double-clicking its header when set to Boolean.TRUE. TopComponent's 'Maximize Window' action will be also disabled.- Since:
- 6.26
- See Also:
-
PROP_DND_COPY_DISABLED
Name of TopComponent's Boolean client property which disables 'copy' drag and drop action of this TopComponent when set to Boolean.TRUE.- Since:
- 6.48
- See Also:
-
-
Constructor Details
-
TopComponent
public TopComponent()Create a top component. -
TopComponent
public TopComponent(org.openide.util.Lookup lookup) Creates a top component for a provided lookup that will delegate take and synchronize activated nodes and ActionMap from a provided lookup. The lookup will also be returned fromgetLookup()
method, if not overriden.- Parameters:
lookup
- the lookup to associate with- Since:
- 4.19
-
-
Method Details
-
addNotify
public void addNotify()- Overrides:
addNotify
in classJComponent
-
getRegistry
Getter for class that allows obtaining of information about components. It allows to find out which component is selected, which nodes are currently or has been activated and list of all components.- Returns:
- the registry of components
-
getActivatedNodes
public final org.openide.nodes.Node[] getActivatedNodes()Get the set of activated nodes in this component.- Returns:
- the activated nodes for this component or
null
,null
means such component does not changeTopComponent.Registry.getActivatedNodes()
justTopComponent.Registry.getCurrentNodes()
when this component gets activated
-
setActivatedNodes
public final void setActivatedNodes(org.openide.nodes.Node[] activatedNodes) Set the set of activated nodes in this component.- Parameters:
activatedNodes
- activated nodes for this component
-
getPersistenceType
public int getPersistenceType()Rather than overriding this method, consider usingTopComponent.Description
. Overwrite when you want to change default persistence type. Default persistence type is PERSISTENCE_ALWAYS. Return value should be constant over a given TC's lifetime.- Returns:
- one of P_X constants
- Since:
- 4.20
-
getUndoRedo
public org.openide.awt.UndoRedo getUndoRedo()Get the undo/redo support for this component. The default implementation returns a dummy support that cannot undo anything.- Returns:
- undoable edit for this component
-
open
public void open()Shows thisTopComponent
. Note: This method only makes it visible, but does not activates it.- See Also:
-
open
-
openAtTabPosition
public final void openAtTabPosition(int position) Opens TopComponent at given position in the mode. TopComponent is inserted at given position, positions of already opened TopComponents in the same mode are incremented.- Does no operation if this TopComponent is already opened.
- For position value less then 0, TopComponent is opened at position 0, the very first one.
- For position value greater then count of opened TopComponents in the mode, TopComponent is opened at last position
- Parameters:
position
- Index of the requested position.- Since:
- 6.15
-
getTabPosition
public final int getTabPosition()Gives position index of opened TopComponent in the mode. For closed TopComponents, position value less then zero is returned.- Returns:
- Index of position.
- Since:
- 6.15
-
isOpened
public final boolean isOpened()Indicates whether thisTopComponent
is opened.- Returns:
- true if given top component is opened, false otherwise
-
isOpened
Deprecated.UseisOpened()
instead.Indicates whether thisTopComponent
is opened in current workspace. Node: Currently workspaces are not supported. The method has the same effect likeisOpened()
. -
close
public final boolean close()Closes thisTopComponent
.- Returns:
- true if top component was succesfully closed, false if top component for some reason refused to close.
-
close
-
canClose
public boolean canClose()This method is called when thisTopComponent
is about to close. Allows subclasses to decide ifTopComponent
is ready to close.- Since:
- 4.13
-
canClose
Deprecated.Do not use anymore. UsecanClose()
instead. Both parameters are redundant since workspaces are not supported anymore.This method is called when top component is about to close. Allows subclasses to decide if top component is ready for closing or not.
Default implementation always return true.- Parameters:
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 true- Returns:
- true if top component is ready to close, false otherwise.
-
openNotify
Deprecated.UsecomponentOpened()
instead.Called only when top component was closed on all workspaces before and now is opened for the first time on some workspace. The intent is to provide subclasses information about TopComponent's life cycle across all existing workspaces. Subclasses will usually perform initializing tasks here. -
closeNotify
Deprecated.UsecomponentClosed()
instead.Called only when top component was closed so that now it is closed on all workspaces in the system. The intent is to provide subclasses information about TopComponent's life cycle across workspaces. Subclasses will usually perform cleaning tasks here. -
getSystemActions
Deprecated.UsegetActions()
instead.Gets the system actions which will appear in the popup menu of this component.- Returns:
- array of system actions for this component
-
getActions
Gets the actions which will appear in the popup menu of this component.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.
- Returns:
- array of actions for this component
- Since:
- 3.32
-
openAction
public static Action openAction(TopComponent component, String displayName, String iconBase, boolean noIconInMenu) Creates an action that opens and activates givenTopComponent
, when invoked. This method can also be used from XML Layer directly by following XML definition:<file name="your-pkg-action-id.instance"> <attr name="instanceCreate" methodvalue="org.openide.windows.TopComponent.openAction"/> <attr name="component" methodvalue="your.pkg.YourComponent.factoryMethod"/> <attr name="displayName" bundlevalue="your.pkg.Bundle#key"/> <attr name="iconBase" stringvalue="your/pkg/YourComponent.png"/> <!-- if desired: <attr name="noIconInMenu" boolvalue="false"/> --> <!-- if desired: <attr name="preferredID" stringvalue="id.of.your.tc"/> --> </file>
ThepreferredID
attribute is supported since version 6.37. If specified the action first seeks for existingpreferredID
component and if found, it opens and activates it.Rather than doing all this in XML, consider using
TopComponent.OpenActionRegistration
.- Parameters:
component
- the component to opendisplayName
- the display name of the actioniconBase
- the location to the actions iconnoIconInMenu
- true if this icon shall not have an item in menu- Since:
- 6.24
- See Also:
-
setCloseOperation
Deprecated.Do not use. It is redundant since workspaces are not supported anymore.Set the close mode for the component.- Parameters:
closeOperation
- one ofCLOSE_EACH
orCLOSE_LAST
- Throws:
IllegalArgumentException
- if an unrecognized close mode was supplied- See Also:
-
getCloseOperation
Deprecated.Do not use. It is redundant since workspaces are not supported anymore.Get the current close mode for this component.- Returns:
- one of
CLOSE_EACH
orCLOSE_LAST
-
preferredID
Rather than overriding this method, consider usingTopComponent.Description
. Subclasses are encouraged to override this method to provide preferred value for unique TopComponent ID returned byWindowManager.findTopComponentID(org.openide.windows.TopComponent)
. Returned value should be a String, preferably describing semantics of TopComponent subclass, such as "PieChartViewer" or "HtmlEditor" etc. Value is then used by window system as prefix value for creating unique TopComponent ID. Returned String value should be preferably unique, but need not be.- Since:
- 4.13
-
componentOpened
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. The intent is to provide subclasses information about TopComponent's life cycle across all existing workspaces. Subclasses will usually perform initializing tasks here.- Since:
- 2.18
-
componentClosed
protected void componentClosed()Called only when top component was closed so that now it is closed on all workspaces in the system. The intent is to provide subclasses information about TopComponent's life cycle across workspaces. Subclasses will usually perform cleaning tasks here.- Since:
- 2.18
-
componentShowing
protected void componentShowing()Called whenTopComponent
is about to be shown. Shown here means the component is selected or resides in it own cell in container in itsMode
. The container is visible and not minimized.Note: component is considered to be shown, even its container window is overlapped by another window.
- Since:
- 2.18
-
componentHidden
protected void componentHidden()Called whenTopComponent
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.- Since:
- 2.18
-
componentActivated
protected void componentActivated()Called when this component is activated. This happens when the parent window of this component gets focus (and this component is the preferred one in it), or when this component is selected in its window (and its window was already focussed). Remember to call the super method. The default implementation does nothing. -
componentDeactivated
protected void componentDeactivated()Called when this component is deactivated. This happens when the parent window of this component loses focus (and this component is the preferred one in the parent), or when this component loses preference in the parent window (and the parent window is focussed). Remember to call the super method. The default implementation does nothing. -
requestFocus
public void requestFocus()Request focus for the window holding this top component. Also makes the component preferred in that window. The component will not be automaticallyopened
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 CloneableEditor#requestFocus.Note: Use
requestActive()
instead to make TopComponent active in the window system (not only focused). This method should be considered deprecated for calling from outside; but it may be overridden (inside of which you may call super).- Overrides:
requestFocus
in classJComponent
-
requestFocusInWindow
public boolean requestFocusInWindow()Request focus for the top component inside focused window. Also makes the component preferred in that window. The component will not be automaticallyopened
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 CloneableEditor#requestFocusInWindow.Note: Use
requestActive()
instead to make TopComponent active in the window system (not only focused). This method should be considered deprecated for calling from outside; but it may be overridden (inside of which you may call super).- Overrides:
requestFocusInWindow
in classJComponent
-
requestActive
public void requestActive()Activates thisTopComponent
if it is opened.- Since:
- 4.13
-
toFront
public void toFront()Attempts to bring the parentWindow
orFrame
of thisTopComponent
to front of other windows.- Since:
- 5.8
-
requestVisible
public void requestVisible()Selects thisTopComponent
, if it is opened, but does not activate it unless it is in active mode already. -
requestAttention
public final void requestAttention(boolean brief) Cause this TopComponent's tab to flash or otherwise draw attention to itself. This method is thread-safe.It will remain flashing until either
cancelRequestAttention
is called, the component becomes selected or its activated state changes, unless thebrief
argument is true, in which case it will stop after a few second.- Parameters:
brief
- True if the tab should blink a few times and stop- Since:
- 5.1
-
makeBusy
public final void makeBusy(boolean busy) Notify the user that some (possibly lengthy) process is being run in this window. It is safe to call this method outside EDT.- Parameters:
busy
- True to start 'busy' notification, 'false' to stop it.- Since:
- 6.51
- See Also:
-
cancelRequestAttention
public final void cancelRequestAttention()Cause this TopComponent's tab to stop flashing if it was flashing.- Since:
- 5.1
-
setAttentionHighlight
public final void setAttentionHighlight(boolean highlight) Permanently highlights this TopComponent's tab until user activates it.- Parameters:
highlight
- True to highlight the tab, false to switch the highlight off.- Since:
- 6.58
- See Also:
-
setName
-
setDisplayName
Sets localized display name of thisTopComponent
.- Parameters:
displayName
- localized display name which is set- Since:
- 4.13
-
getDisplayName
Gets localized display name of thisTopComponent
.- Returns:
- localized display name or
null
if there is none - Since:
- 4.13
-
getShortName
Short version of TopComponent's name that doesn't include the name of activated Node.- Returns:
- Short version of TopComponent's display name. The default implementation returns null.
- Since:
- 6.52
-
setHtmlDisplayName
Sets localized html display name of thisTopComponent
. Hmtl name usually contains basic html tags for text coloring and style. Html name may be null if not needed. Must apparently begin with<html>
.- Parameters:
htmlDisplayName
- localized html display name which is set- Since:
- 6.4
-
getHtmlDisplayName
Gets localized display name of thisTopComponent
with added html tags for text coloring and/or font style. May return null. Must apparently begin with<html>
.- Returns:
- localized html display name or
null
if there is none - Since:
- 6.4
-
setToolTipText
Sets toolTip for thisTopComponent
, adds notification about the change to itsWindowManager.TopComponentManager
.- Overrides:
setToolTipText
in classJComponent
-
setIcon
Set the icon of this top component. The icon will be used for the component's representation on the screen, e.g. in a multiwindow's tab. The default implementation just notifies the window manager.- Parameters:
icon
- New components' icon.
-
getIcon
Rather than overriding this method, consider usingTopComponent.Description
.- Returns:
- The icon of the top component
-
getHelpCtx
public org.openide.util.HelpCtx getHelpCtx()Get the help context for this component. Subclasses should generally override this to return specific help.- Specified by:
getHelpCtx
in interfaceorg.openide.util.HelpCtx.Provider
- Returns:
- the help context
-
availableModes
Allows top component to specify list of modes into which can be docked by end user. Subclasses should override this method if they want to alter docking policy of top component.So for example, by returning empty list, top component refuses to be docked anywhere.
Default implementation allows docking anywhere by returning input list unchanged.
- Parameters:
modes
- list ofMode
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.
- Returns:
- list of
Mode
which are available for dock, can contain nulls - Since:
- 2.14
-
processKeyBinding
Overrides superclass method, adds possible additional handling of global keystrokes in case thisTopComoponent
is ancestor of focused component.- Overrides:
processKeyBinding
in classJComponent
-
writeExternal
Serialize this top component. Subclasses wishing to store state must call the super method, then write to the stream.- Specified by:
writeExternal
in interfaceExternalizable
- Parameters:
out
- the stream to serialize to- Throws:
IOException
-
readExternal
Deserialize this top component. Subclasses wishing to store state must call the super method, then read from the stream.- Specified by:
readExternal
in interfaceExternalizable
- Parameters:
in
- the stream to deserialize from- Throws:
IOException
ClassNotFoundException
-
writeReplace
Delegates instance of replacer class to be serialized instead of top component itself. Replacer class calls writeExternal and constructor, readExternal and readResolve methods properly, so 8 any top component can behave like any other externalizable object. Subclasses can override this method to perform their serialization differentrly- Throws:
ObjectStreamException
-
getAccessibleContext
- Specified by:
getAccessibleContext
in interfaceAccessible
- Overrides:
getAccessibleContext
in classComponent
-
getLookup
public org.openide.util.Lookup getLookup()Gets a lookup which represents the "selection" of this component.By default the lookup includes all nodes from
getActivatedNodes()
, all objects from those nodes' own lookups (excepting the nodes themselves), and also the component'sActionMap
. This is useful for components with explorer views.The default implementation also has a special behavior when you look up
Node.class
: ifgetActivatedNodes()
is null (as opposed to an empty array), the result will contain an extra item whoseLookup.Item.getId()
isnone
and whoseLookup.Item.getInstance()
is null. This can be used by (say) node-sensitive actions to differentiate between a component with an explorer view that currently happens to have no selected nodes (zero-length array so noLookup.Item<Node>
), vs. a component with no explorer view that would never have a node selection (null so one dummyLookup.Item<Node>
); in either caseLookup.Result.allInstances()
would return an empty collection. In particular,NodeAction
relies on this behavior to avoid disabling an action just because focus is transferred from a component with a (potential) node selection to a component that does not have node selections.If you override the method in your subclass, the default activatedNodes<->lookup synchronization will not be performed. That can influence functionality that relies on activated Nodes being present in the TopComponent's lookup. If you want to preserve the synchronization, use
associateLookup(org.openide.util.Lookup)
instead.- Specified by:
getLookup
in interfaceorg.openide.util.Lookup.Provider
- Returns:
- a lookup with designates context of this component
- Since:
- 3.29
- See Also:
-
associateLookup
protected final void associateLookup(org.openide.util.Lookup lookup) Associates the provided lookup with the component. So it will be returned fromgetLookup()
method. When used, make sure the providedLookup
contains objects needed by other subsystems. For example, ifcallback actions
are about to search their actions in thisTopComponent
, it is good idea to includethis.getActionMap()
in the lookup.- Parameters:
lookup
- the lookup to associate- Throws:
IllegalStateException
- if there already is a lookup registered with this component- Since:
- 4.23
-
getSubComponents
Retrieves sub-components this TopComponent contains. The resulting array is a snapshot valid at the time of the call and shouldn't be held for too long. This method can be called from EDT only.- Returns:
- Array of internal sub-components or an empty array if the TopComponent has no internal sub-components.
- Since:
- 6.52
-