📄 guiapplication.java
字号:
*/
public void setJMenuBar(JMenuBar menuBar);
/*****************************************************************************/
/**
* Sets the language for this GUI application and all of its dialogs,
* UI widgets, etc.<p>
*
* @param language The language to use. If <code>null</code>,
* English will be used.
*/
public void setLanguage(final String language);
/*****************************************************************************/
/**
* Sets the status bar to use in this application.
*
* @param statusBar The status bar to use.
* @see #getStatusBar
*/
public void setStatusBar(StatusBar statusBar);
/*****************************************************************************/
/**
* Sets whether the status bar is visible.
*
* @param visible Whether the status bar is to be visible.
* @see #getStatusBarVisible
*/
public void setStatusBarVisible(boolean visible);
/*****************************************************************************/
/**
* Sets the toolbar used by this GUI application.
*
* @param toolBar The toolbar to use.
* @see #getToolBar
*/
public void setToolBar(CustomizableToolBar toolBar);
/*****************************************************************************/
/**
* Sets whether the toolbar used by this GUI application is visible.
*
* @param visible Whether the toolbar should be visible.
* @see #getToolBarVisible
*/
public void setToolBarVisible(boolean visible);
/*****************************************************************************/
/************************* INNER CLASSES *************************************/
/*****************************************************************************/
/**
* The action that displays the application's About dialog. This action
* should be sufficient for most applications; it simply displays the
* modal About dialog obtained from <code>getAboutDialog</code>.
*/
public static class AboutAction extends StandardAction {
/**
*
*/
private static final long serialVersionUID = -6858427553478334189L;
private GUIApplication app;
/**
* Creates a new <code>AboutAction</code>.
*
* @param text The text associated with the action.
* @param app The GUI application that owns this action.
*/
public AboutAction(String text, GUIApplication app) {
this(text, null, null, null, null, app);
}
/**
* Creates a new <code>AboutAction</code>.
*
* @param text The text associated with the action.
* @param icon The icon associated with the action.
* @param desc The description of the action (used in tooltips???).
* @param mnemonic The mnemonic for the action.
* @param accelerator The accelerator key for the action.
* @param app The GUI application that owns this action.
*/
public AboutAction(String text, Icon icon, String desc,
Integer mnemonic, KeyStroke accelerator,
GUIApplication app) {
super(text, icon, desc, mnemonic, accelerator);
this.app = app;
}
/**
* Displays the About dialog.
*
* @param e The action event.
*/
public void actionPerformed(ActionEvent e) {
try {
app.getAboutDialog().setVisible(true);
} catch (Exception ex) {
app.displayException(ex);
}
}
}
/*****************************************************************************/
/**
* Action that attempts to close the application. This action calls
* the application's <code>doExit</code> method.
*/
public static class ExitAction extends StandardAction {
private GUIApplication app;
/**
* Creates a new <code>ExitAction</code>.
*
* @param text The text associated with the action.
* @param app The GUI application that owns this action.
*/
public ExitAction(String text, GUIApplication app) {
this(text, null, null, null, null, app);
}
/**
* Creates a new <code>ExitAction</code>.
*
* @param text The text associated with the action.
* @param icon The icon associated with the action.
* @param desc The description of the action (used in tooltips???).
* @param mnemonic The mnemonic for the action.
* @param accelerator The accelerator key for the action.
* @param app The GUI application that owns this action.
*/
public ExitAction(String text, Icon icon, String desc,
Integer mnemonic, KeyStroke accelerator,
GUIApplication app) {
super(text, icon, desc, mnemonic, accelerator);
this.app = app;
}
/**
* Calls the application's <code>doExit</code> method.
*
* @param e The action event.
*/
public void actionPerformed(ActionEvent e) {
app.doExit();
}
}
/*****************************************************************************/
/**
* The action that displays the application's Help dialog. This action
* should be sufficient for most applications; it simply displays the
* modal Help dialog obtained from <code>getHelpDialog</code>.
*/
public static class HelpAction extends StandardAction {
/**
*
*/
private static final long serialVersionUID = -6849240994422591890L;
private GUIApplication app;
/**
* Creates a new <code>HelpAction</code>.
*
* @param text The text associated with the action.
* @param app The GUI application that owns this action.
*/
public HelpAction(String text, GUIApplication app) {
this(text, null, null, null, null, app);
}
/**
* Creates a new <code>HelpAction</code>.
*
* @param text The text associated with the action.
* @param icon The icon associated with the action.
* @param desc The description of the action (used in tooltips???).
* @param mnemonic The mnemonic for the action.
* @param accelerator The accelerator key for the action.
* @param app The GUI application that owns this action.
*/
public HelpAction(String text, Icon icon, String desc,
Integer mnemonic, KeyStroke accelerator,
GUIApplication app) {
super(text, icon, desc, mnemonic, accelerator);
this.app = app;
}
/**
* Displays the Help dialog, if it is non-<code>null</code>.
*
* @param e The action event.
*/
public void actionPerformed(ActionEvent e) {
if (app instanceof Component) {
((Component)app).setCursor(Cursor.
getPredefinedCursor(Cursor.WAIT_CURSOR));
}
HelpDialog hd = null;
try {
hd = app.getHelpDialog();
} finally {
// Make sure cursor returns to normal.
if (app instanceof Component) {
((Component)app).setCursor(Cursor.getPredefinedCursor(
Cursor.DEFAULT_CURSOR));
}
}
if (hd!=null) {
try {
hd.setVisible(true);
} catch (Exception ex) {
app.displayException(ex);
}
}
}
}
/*****************************************************************************/
/**
* Action to toggle a <code>GUIApplication</code>'s status bar.
*/
public static class ToggleStatusBarAction extends StandardAction {
/**
*
*/
private static final long serialVersionUID = -4251915611849378428L;
private GUIApplication app;
/**
* Creates a new <code>ToggleStatusBarAction</code>.
*
* @param text The text associated with the action.
* @param app The GUI application that owns this action.
*/
public ToggleStatusBarAction(String text, GUIApplication app) {
this(text, null, null, null, null, app);
}
/**
* Creates a new <code>ToggleStatusBarAction</code>.
*
* @param text The text associated with the action.
* @param icon The icon associated with the action.
* @param desc The description of the action (used in tooltips???).
* @param mnemonic The mnemonic for the action.
* @param accelerator The accelerator key for the action.
* @param app The GUI application that owns this action.
*/
public ToggleStatusBarAction(String text, Icon icon, String desc,
Integer mnemonic, KeyStroke accelerator,
GUIApplication app) {
super(text, icon, desc, mnemonic, accelerator);
this.app = app;
}
/**
* Toggles the status bar.
*
* @param e The action event.
*/
public void actionPerformed(ActionEvent e) {
app.setStatusBarVisible(!app.getStatusBarVisible());
}
}
/*****************************************************************************/
/**
* Action to toggle a <code>GUIApplication</code>'s toolbar.
*/
public static class ToggleToolBarAction extends StandardAction {
/**
*
*/
private static final long serialVersionUID = -8948745114061606096L;
private GUIApplication app;
/**
* Creates a new <code>ToggleToolBarAction</code>.
*
* @param text The text associated with the action.
* @param app The GUI application that owns this action.
*/
public ToggleToolBarAction(String text, GUIApplication app) {
this(text, null, null, null, null, app);
}
/**
* Creates a new <code>ToggleToolBarAction</code>.
*
* @param text The text associated with the action.
* @param icon The icon associated with the action.
* @param desc The description of the action (used in tooltips???).
* @param mnemonic The mnemonic for the action.
* @param accelerator The accelerator key for the action.
* @param app The GUI application that owns this action.
*/
public ToggleToolBarAction(String text, Icon icon, String desc,
Integer mnemonic, KeyStroke accelerator,
GUIApplication app) {
super(text, icon, desc, mnemonic, accelerator);
this.app = app;
}
/**
* Toggles the toolbar.
*
* @param e The action event.
*/
public void actionPerformed(ActionEvent e) {
app.setToolBarVisible(!app.getToolBarVisible());
}
}
/*****************************************************************************/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -