public class MainFrame
extends java.lang.Object
MainFrame
contains a static convenience method to
handle the initialization of a Swing based application. Assuming
the main panel of the application is a JPanel
subclass, MyPanel
, the main class for the application
would reduce to
public class MyApplication public static main(String[] args) { MainFrame.setFrame(new MyPanel(), "MyApplication"); }
There is also a static method to display a frame containing the text "Loading, please wait...". It may be used when the loading and initialization of the main panel takes some time, so that the user is kept reasonably happy. The main program in that case would be
public class MyApplication public static main(String[] args) { MainFrame.showLoading(); MainFrame.setFrame(new MyPanel(), "MyApplication"); }
Note that the instantiation of MyPanel
should not take
place until after the return of
MainFrame.showLoading()
so that the "Loading ... "
frame is displayed before the instantiation starts.
Constructor and Description |
---|
MainFrame() |
Modifier and Type | Method and Description |
---|---|
static void |
setPanel(javax.swing.JPanel jp,
java.lang.String name)
Handles the initialization of the main
JFrame of an
application. |
static void |
showLoading()
Displays a frame with the text "Loading, please wait...".
|
public static void showLoading()
public static void setPanel(javax.swing.JPanel jp, java.lang.String name)
JFrame
of an
application. If a "Loading, please wait..." frame has been
displayed, then it is removed immediately before the main
JFrame
is shown.jp
- The JPanel
that should be the
contentPane
of the JFrame
.name
- The name to be displayed for the frame.