* @param title window title, will be centered along the top border
* @param width width of window
* @param height height of window
+ * @return the new window
*/
public final TWindow addWindow(final String title, final int width,
final int height) {
* @param width width of window
* @param height height of window
* @param flags bitmask of RESIZABLE, CENTERED, or MODAL
+ * @return the new window
*/
public final TWindow addWindow(final String title,
final int width, final int height, final int flags) {
* @param y row relative to parent
* @param width width of window
* @param height height of window
+ * @return the new window
*/
public final TWindow addWindow(final String title,
final int x, final int y, final int width, final int height) {
* @param width width of window
* @param height height of window
* @param flags mask of RESIZABLE, CENTERED, or MODAL
+ * @return the new window
*/
public final TWindow addWindow(final String title,
final int x, final int y, final int width, final int height,
* active.
*
* @param file the file to open
+ * @return the new editor window
* @throws IOException if a java.io operation throws
*/
public final TEditorWindow addEditor(final File file) throws IOException {
* <li>Keypress events are seen if no other windows are open.</li>
* <li>Menu events are seen if no other windows are open.</li>
* <li>Command events are seen if no other windows are open.</li>
- * <ul>
+ * </ul>
*/
public class TDesktop extends TWindow {
* TFileOpenBox is a system-modal dialog for selecting a file to open. Call
* it like:
*
- * <p>
* <pre>
* {@code
* filename = application.fileOpenBox("/path/to/file.ext",
* TInputBox is a system-modal dialog with an OK button and a text input
* field. Call it like:
*
- * <p>
* <pre>
* {@code
* box = application.inputBox(title, caption);
* TMessageBox is a system-modal dialog with buttons for OK, Cancel, Yes, or
* No. Call it like:
*
- * <p>
* <pre>
* {@code
* box = application.messageBox(title, caption,
package jexer.bits;
/**
- * MnemonicString is used to render a string like "&File" into a highlighted
- * 'F' and the rest of 'ile'. To insert a literal '&', use two '&&'
- * characters, e.g. "&File && Stuff" would be "File & Stuff" with the first
- * 'F' highlighted.
+ * MnemonicString is used to render a string like "&File" into a
+ * highlighted 'F' and the rest of 'ile'. To insert a literal '&', use
+ * two '&&' characters, e.g. "&File && Stuff" would be
+ * "File & Stuff" with the first 'F' highlighted.
*/
public final class MnemonicString {
* Public constructor.
*
* @param label widget label or title. Label must contain a keyboard
- * shortcut, denoted by prefixing a letter with "&", e.g. "&File"
+ * shortcut, denoted by prefixing a letter with "&", e.g. "&File"
*/
public MnemonicString(final String label) {
* capabilities.
*/
public class Demo1 {
+
/**
* Main entry point.
*
*/
public class Demo5 implements WindowListener {
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* The first demo application instance.
*/
*/
DemoApplication app2 = null;
+ // ------------------------------------------------------------------------
+ // WindowListener ---------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Pass window events into the event queue.
*
// Ignore
}
+ // ------------------------------------------------------------------------
+ // Demo5 ------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Run two demo applications in separate panes.
*/
*/
public class DemoApplication extends TApplication {
- /**
- * Add all the widgets of the demo.
- */
- private void addAllWidgets() {
- new DemoMainWindow(this);
-
- // Add the menus
- addFileMenu();
- addEditMenu();
-
- TMenu demoMenu = addMenu("&Demo");
- TMenuItem item = demoMenu.addItem(2000, "&Checkable");
- item.setCheckable(true);
- item = demoMenu.addItem(2001, "Disabled");
- item.setEnabled(false);
- item = demoMenu.addItem(2002, "&Normal");
- TSubMenu subMenu = demoMenu.addSubMenu("Sub-&Menu");
- item = demoMenu.addItem(2010, "N&ormal A&&D");
- item = demoMenu.addItem(2050, "Co&lors...");
-
- item = subMenu.addItem(2000, "&Checkable (sub)");
- item.setCheckable(true);
- item = subMenu.addItem(2001, "Disabled (sub)");
- item.setEnabled(false);
- item = subMenu.addItem(2002, "&Normal (sub)");
-
- subMenu = subMenu.addSubMenu("Sub-&Menu");
- item = subMenu.addItem(2000, "&Checkable (sub)");
- item.setCheckable(true);
- item = subMenu.addItem(2001, "Disabled (sub)");
- item.setEnabled(false);
- item = subMenu.addItem(2002, "&Normal (sub)");
-
- if (getScreen() instanceof SwingTerminal) {
- TMenu swingMenu = addMenu("Swin&g");
- item = swingMenu.addItem(3000, "&Bigger +2");
- item = swingMenu.addItem(3001, "&Smaller -2");
- }
-
- addWindowMenu();
- addHelpMenu();
- }
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
* Public constructor.
addAllWidgets();
}
+ /**
+ * Public constructor.
+ *
+ * @param backendType one of the TApplication.BackendType values
+ * @throws Exception if TApplication can't instantiate the Backend.
+ */
+ public DemoApplication(final BackendType backendType) throws Exception {
+ super(backendType);
+ addAllWidgets();
+ getBackend().setTitle("Jexer Demo Application");
+ }
+
+ // ------------------------------------------------------------------------
+ // TApplication -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Handle menu events.
*
return super.onMenu(menu);
}
+ // ------------------------------------------------------------------------
+ // DemoApplication --------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
- * Public constructor.
- *
- * @param backendType one of the TApplication.BackendType values
- * @throws Exception if TApplication can't instantiate the Backend.
+ * Add all the widgets of the demo.
*/
- public DemoApplication(final BackendType backendType) throws Exception {
- super(backendType);
- addAllWidgets();
- getBackend().setTitle("Jexer Demo Application");
+ private void addAllWidgets() {
+ new DemoMainWindow(this);
+
+ // Add the menus
+ addFileMenu();
+ addEditMenu();
+
+ TMenu demoMenu = addMenu("&Demo");
+ TMenuItem item = demoMenu.addItem(2000, "&Checkable");
+ item.setCheckable(true);
+ item = demoMenu.addItem(2001, "Disabled");
+ item.setEnabled(false);
+ item = demoMenu.addItem(2002, "&Normal");
+ TSubMenu subMenu = demoMenu.addSubMenu("Sub-&Menu");
+ item = demoMenu.addItem(2010, "N&ormal A&&D");
+ item = demoMenu.addItem(2050, "Co&lors...");
+
+ item = subMenu.addItem(2000, "&Checkable (sub)");
+ item.setCheckable(true);
+ item = subMenu.addItem(2001, "Disabled (sub)");
+ item.setEnabled(false);
+ item = subMenu.addItem(2002, "&Normal (sub)");
+
+ subMenu = subMenu.addSubMenu("Sub-&Menu");
+ item = subMenu.addItem(2000, "&Checkable (sub)");
+ item.setCheckable(true);
+ item = subMenu.addItem(2001, "Disabled (sub)");
+ item.setEnabled(false);
+ item = subMenu.addItem(2002, "&Normal (sub)");
+
+ if (getScreen() instanceof SwingTerminal) {
+ TMenu swingMenu = addMenu("Swin&g");
+ item = swingMenu.addItem(3000, "&Bigger +2");
+ item = swingMenu.addItem(3001, "&Smaller -2");
+ }
+
+ addWindowMenu();
+ addHelpMenu();
}
+
}
*/
public class DemoCheckboxWindow extends TWindow {
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Constructor.
*
*/
public class DemoEditorWindow extends TWindow {
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Hang onto my TEditor so I can resize it with the window.
*/
private TEditorWidget editField;
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Public constructor makes a text window out of any string.
*
}
+ // ------------------------------------------------------------------------
+ // TWindow ----------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Handle window/screen resize events.
*
*/
public class DemoMainWindow extends TWindow {
- // Timer that increments a number.
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Timer that increments a number.
+ */
private TTimer timer;
- // Timer label is updated with timer ticks.
+ /**
+ * Timer label is updated with timer ticks.
+ */
TLabel timerLabel;
/**
- * We need to override onClose so that the timer will no longer be called
- * after we close the window. TTimers currently are completely unaware
- * of the rest of the UI classes.
+ * Timer increment used by the timer loop. Has to be at class scope so
+ * that it can be accessed by the anonymous TAction class.
*/
- @Override
- public void onClose() {
- getApplication().removeTimer(timer);
- }
+ int timerI = 0;
+
+ /**
+ * Progress bar used by the timer loop. Has to be at class scope so that
+ * it can be accessed by the anonymous TAction class.
+ */
+ TProgressBar progressBar;
+
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
* Construct demo window. It will be centered on screen.
this(parent, CENTERED | RESIZABLE);
}
- // These are used by the timer loop. They have to be at class scope so
- // that they can be accessed by the anonymous TAction class.
- int timerI = 0;
- TProgressBar progressBar;
-
/**
* Constructor.
*
statusBar.addShortcutKeypress(kbF10, cmExit, "Exit");
}
+ // ------------------------------------------------------------------------
+ // TWindow ----------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * We need to override onClose so that the timer will no longer be called
+ * after we close the window. TTimers currently are completely unaware
+ * of the rest of the UI classes.
+ */
+ @Override
+ public void onClose() {
+ getApplication().removeTimer(timer);
+ }
+
/**
* Method that subclasses can override to handle posted command events.
*
*/
public class DemoMsgBoxWindow extends TWindow {
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Constructor.
*
*/
public class DemoTextFieldWindow extends TWindow {
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Constructor.
*
statusBar.addShortcutKeypress(kbF3, cmOpen, "Open");
statusBar.addShortcutKeypress(kbF10, cmExit, "Exit");
}
+
}
*/
public class DemoTextWindow extends TWindow {
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Hang onto my TText so I can resize it with the window.
*/
private TText textField;
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Public constructor makes a text window out of any string.
*
}
+ // ------------------------------------------------------------------------
+ // TWindow ----------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Handle window/screen resize events.
*
*/
public class DemoTreeViewWindow extends TWindow {
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Hang onto my TTreeView so I can resize it with the window.
*/
private TTreeViewWidget treeView;
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Public constructor.
*
statusBar.addShortcutKeypress(kbF10, cmExit, "Exit");
}
+ // ------------------------------------------------------------------------
+ // TWindow ----------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Handle window/screen resize events.
*
*/
public class DesktopDemo extends TDesktop {
+ // ------------------------------------------------------------------------
+ // Variables --------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* If true, draw the hatch. Note package private access.
*/
boolean drawHatch = true;
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Public constructor.
+ *
+ * @param parent parent application
+ */
+ public DesktopDemo(final TApplication parent) {
+ super(parent);
+ }
+
+ // ------------------------------------------------------------------------
+ // TDesktop ---------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* The default TDesktop draws a hatch character across everything. This
* version is selectable.
}
}
- /**
- * Public constructor.
- *
- * @param parent parent application
- */
- public DesktopDemo(final TApplication parent) {
- super(parent);
- }
-
}
*/
public class DesktopDemoApplication extends TApplication {
+ // ------------------------------------------------------------------------
+ // Constructors -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Public constructor.
+ *
+ * @param backendType one of the TApplication.BackendType values
+ * @throws Exception if TApplication can't instantiate the Backend.
+ */
+ public DesktopDemoApplication(final BackendType backendType) throws Exception {
+ super(backendType);
+ addAllWidgets();
+ getBackend().setTitle("Jexer Demo Application");
+ }
+
+ // ------------------------------------------------------------------------
+ // TApplication -----------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Handle menu events.
+ *
+ * @param menu menu event
+ * @return if true, the event was processed and should not be passed onto
+ * a window
+ */
+ @Override
+ public boolean onMenu(final TMenuEvent menu) {
+
+ if (menu.getId() == TMenu.MID_OPEN_FILE) {
+ try {
+ String filename = fileOpenBox(".");
+ if (filename != null) {
+ try {
+ File file = new File(filename);
+ StringBuilder fileContents = new StringBuilder();
+ Scanner scanner = new Scanner(file);
+ String EOL = System.getProperty("line.separator");
+
+ try {
+ while (scanner.hasNextLine()) {
+ fileContents.append(scanner.nextLine() + EOL);
+ }
+ new DemoTextWindow(this, filename,
+ fileContents.toString());
+ } finally {
+ scanner.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+ return super.onMenu(menu);
+ }
+
+ // ------------------------------------------------------------------------
+ // DesktopDemoApplication -------------------------------------------------
+ // ------------------------------------------------------------------------
+
/**
* Add all the widgets of the demo.
*/
}
- /**
- * Handle menu events.
- *
- * @param menu menu event
- * @return if true, the event was processed and should not be passed onto
- * a window
- */
- @Override
- public boolean onMenu(final TMenuEvent menu) {
-
- if (menu.getId() == TMenu.MID_OPEN_FILE) {
- try {
- String filename = fileOpenBox(".");
- if (filename != null) {
- try {
- File file = new File(filename);
- StringBuilder fileContents = new StringBuilder();
- Scanner scanner = new Scanner(file);
- String EOL = System.getProperty("line.separator");
-
- try {
- while (scanner.hasNextLine()) {
- fileContents.append(scanner.nextLine() + EOL);
- }
- new DemoTextWindow(this, filename,
- fileContents.toString());
- } finally {
- scanner.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return true;
- }
- return super.onMenu(menu);
- }
-
- /**
- * Public constructor.
- *
- * @param backendType one of the TApplication.BackendType values
- * @throws Exception if TApplication can't instantiate the Backend.
- */
- public DesktopDemoApplication(final BackendType backendType) throws Exception {
- super(backendType);
- addAllWidgets();
- getBackend().setTitle("Jexer Demo Application");
- }
}
* @param x column relative to parent
* @param y row relative to parent
* @param label mnemonic menu title. Label must contain a keyboard
- * shortcut (mnemonic), denoted by prefixing a letter with "&",
- * e.g. "&File"
+ * shortcut (mnemonic), denoted by prefixing a letter with "&",
+ * e.g. "&File"
*/
public TMenu(final TApplication parent, final int x, final int y,
final String label) {
* Convenience function to add a sub-menu.
*
* @param title menu title. Title must contain a keyboard shortcut,
- * denoted by prefixing a letter with "&", e.g. "&File"
+ * denoted by prefixing a letter with "&", e.g. "&File"
* @return the new sub-menu
*/
public TSubMenu addSubMenu(final String title) {
*
* @param parent parent widget
* @param title menu title. Title must contain a keyboard shortcut,
- * denoted by prefixing a letter with "&", e.g. "&File"
+ * denoted by prefixing a letter with "&", e.g. "&File"
* @param x column relative to parent
* @param y row relative to parent
*/
* Convenience function to add a sub-menu.
*
* @param title menu title. Title must contain a keyboard shortcut,
- * denoted by prefixing a letter with "&", e.g. "&File"
+ * denoted by prefixing a letter with "&", e.g. "&File"
* @return the new sub-menu
*/
public TSubMenu addSubMenu(final String title) {
* still being worked on. Generally the goal will be to build applications
* somewhat as follows:
*
- * <p>
* <pre>
* {@code
* import jexer.*;