*/
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.
*/
desktop.addButton("&Create Window C", 25, 15,
new TAction() {
public void DO() {
- desktop.getApplication().addWindow("Window C",
- 30, 20);
+ final TWindow windowC = desktop.getApplication().addWindow(
+ "Window C", 30, 20, TWindow.NOCLOSEBOX);
+ windowC.addButton("&Close Me", 5, 5,
+ new TAction() {
+ public void DO() {
+ windowC.close();
+ }
+ }
+ );
}
}
);
-
- }
-
- /**
- * 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();
+ desktop.addButton("Enable focusFollowsMouse", 25, 18,
+ new TAction() {
+ public void DO() {
+ DesktopDemoApplication.this.setFocusFollowsMouse(true);
+ }
}
- return true;
- }
- return super.onMenu(menu);
- }
+ );
+ desktop.addButton("Disable focusFollowsMouse", 25, 21,
+ new TAction() {
+ public void DO() {
+ DesktopDemoApplication.this.setFocusFollowsMouse(false);
+ }
+ }
+ );
- /**
- * 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");
}
+
}