Package jmri.util

Class JmriJFrame

All Implemented Interfaces:
ComponentListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, BeanInterface, ModifiedFlag, WindowInterface
Direct Known Subclasses:
AbstractAudioFrame, AbstractMonFrame, AbstractPacketGenFrame, AbstractRouteAddEditFrame, AcelaPacketGenFrame, AddEntryExitPairFrame, AddNodeFrame, AddSignalMastJFrame, AlignTableFrame, AnalogClockFrame, AppsLaunchFrame, AutomatTableFrame, AutoTrainsFrame, BeanTableFrame, BlockBossFrame, BlockPathEditFrame, CbusEventHighlightFrame, CbusFilterFrame, CbusNodeEditEventFrame, CbusNodeRestoreFcuFrame, CircuitBuilder.CBFrame, CMRInetManagerFrame, CMRInetMetricsFrame, ConditionalFrame, ConfigBaseStationFrame, ConsistToolFrame, ControllerFilterFrame, CoordinateEdit, DataSource, DebuggerFrame, DiagnosticFrame, DispatcherFrame, DisplayFrame, DrawFrame, DualDecoderSelectFrame, EasyDccPacketGenFrame, EditFrame, EditNodeFrame, Editor, Editor.JFrameItem, EditorFrame, FollowerFrame, HexFileFrame, ImageIndexEditor, ItemDialog, JmriServerFrame, JmriSRCPServerFrame, LcdClockFrame, LearnThrottleFrame, LI101Frame, ListFrame, ListFrame, LIUSBConfigFrame, LnTcpServerFrame, LoaderFrame, LogFrame, LogFrame, LV102Frame, LZ100Frame, LZV100Frame, ManageLocationsFrame, MastBuilderPane, MdiMainFrame, MeterFrame, MultiPaneWindow, MultiSensorIconFrame, NixieClockFrame, NodeConfigFrame, NodeConfigFrame, NodeConfigFrame, NodeConfigFrame, NodeConfigFrame, NodeConfigFrame, NodeConfigFrame, NodeConfigManagerFrame, NodeIOListFrame, NodeTableFrame, OperationsFrame, OsIndicatorFrame, PacketGenFrame, PacketGenFrame, PacketGenFrame, PacketTableFrame, PaneProgFrame, PickFrame, PollTableFrame, PortalEditFrame, PowerPanelFrame, PragotronClockFrame, PreferencesFrame, ProtocolOptionsFrame, RenumberFrame, ReportFrame, RosterGroupTableFrame, RpsTrackingFrame, SendPacketFrame, SensorGroupFrame, SensorTextEdit, SerialFilterFrame, SerialPacketGenFrame, SerialPacketGenFrame, SerialPacketGenFrame, SerialPacketGenFrame, SerialPacketGenFrame, SerialPacketGenFrame, SerialPacketGenFrame, ServerFrame, SignalEditFrame, SignallingFrame, SignallingSourceFrame, SignalMastRepeaterJFrame, SimpleClockFrame, SimpleLightCtrlFrame, SimpleProgFrame, SimpleServerFrame, SimpleTurnoutCtrlFrame, SlipTurnoutTextEdit, SoundSetFrame, SpeedoConsoleFrame, SpeedometerFrame, SpeedProfileFrame, SpeedProfileTable, SprogCbusModeSwitcherFrame, SprogHexFile, SprogPacketGenFrame, SprogSlotMonFrame, SprogUpdateFrame, SprogVersionFrame, StackMonFrame, StatusFrame, SystemInfoFrame, TabbedPreferencesFrame, ThreePaneTLRWindow, ThrottleWindow, TieToolFrame, TimeTableFrame, TrackerTableAction.TableFrame, TreeFrame, TwoPaneTBWindow, UsbBrowserFrame, UserInterface, VSDManagerFrame, WarrantRoute, WarrantTableFrame, WhereUsedFrame, XpaConfigureFrame, XpaPacketGenFrame, Z21ConfigFrame

public class JmriJFrame
extends JFrame
implements WindowListener, ModifiedFlag, ComponentListener, WindowInterface, BeanInterface
JFrame extended for common JMRI use.

We needed a place to refactor common JFrame additions in JMRI code, so this class was created.

Features:

  • Size limited to the maximum available on the screen, after removing any menu bars (macOS) and taskbars (Windows)
  • Cleanup upon closing the frame: When the frame is closed (WindowClosing event), the dispose() method is invoked to do cleanup. This is inherited from JFrame itself, so super.dispose() needs to be invoked in the over-loading methods.
  • Maintains a list of existing JmriJFrames

Window Closing

Normally, a JMRI window wants to be disposed when it closes. This is what's needed when each invocation of the corresponding action can create a new copy of the window. To do this, you don't have to do anything in your subclass.

If you want this behavior, but need to do something when the window is closing, override the windowClosing(java.awt.event.WindowEvent) method to do what you want. Also, if you override dispose(), make sure to call super.dispose().

If you want the window to just do nothing or just hide, rather than be disposed, when closed, set the DefaultCloseOperation to DO_NOTHING_ON_CLOSE or HIDE_ON_CLOSE depending on what you're looking for.

See Also:
Serialized Form