Package sc.fiji.snt.gui
Class GuiUtils.JTables.DetachableTable
java.lang.Object
sc.fiji.snt.gui.GuiUtils.JTables.DetachableTable
- Enclosing class:
GuiUtils.JTables
Stateful helper that extracts a
JScrollPane from its current
parent into a free-floating, modeless JDialog, and re-attaches
it on demand. Designed for "Detach Table / Dock Table" UI patterns.
Because Swing layouts (notably GridBagLayout) don't preserve
per-component constraints across remove/add, the
redocker callback supplied by the caller is responsible for
re-adding the scroll pane to its original parent with the appropriate
constraints.
Closing the detached dialog (window-close button) triggers a dock.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDetachableTable(JScrollPane scroll, String detachedTitle, Runnable redocker) DetachableTable(JScrollPane scroll, String detachedTitle, Runnable redocker, Dimension detachedSize) -
Method Summary
Modifier and TypeMethodDescriptionvoiddetach()Detaches into a floating dialog.voiddock()Re-attaches via the caller'sredocker.installMenuItem(JPopupMenu menu) Adds a "Detach Table" / "Dock Table" toggle item to the given popup menu.booleanvoidtoggle()
-
Constructor Details
-
DetachableTable
- Parameters:
scroll- the scroll pane that wraps the JTabledetachedTitle- title for the detachedJDialogredocker- caller-supplied logic that re-addsscrollto its original parent with the correct layout constraints; called once per dock (including when the user closes the detached window)
-
DetachableTable
public DetachableTable(JScrollPane scroll, String detachedTitle, Runnable redocker, Dimension detachedSize) - Parameters:
detachedSize- initial size of the detachedJDialog(e.g.new Dimension(500, 240))
-
-
Method Details
-
isDetached
public boolean isDetached()- Returns:
truewhen the table is currently floating in its own dialog.
-
detach
public void detach()Detaches into a floating dialog. No-op if already detached. -
dock
public void dock()Re-attaches via the caller'sredocker. No-op if already docked. -
toggle
public void toggle() -
installMenuItem
Adds a "Detach Table" / "Dock Table" toggle item to the given popup menu. The label is kept in sync via aPopupMenuListener, so closing the detached dialog with its window-close button is reflected next time the popup opens.- Parameters:
menu- the popup to append the item to- Returns:
- the installed
JMenuItem(already added tomenu)
-