List of usage examples for javafx.scene.input KeyCode Q
KeyCode Q
To view the source code for javafx.scene.input KeyCode Q.
Click Source Link
From source file:io.bitsquare.app.gui.BitsquareApp.java
@Override public void start(Stage primaryStage) throws IOException { bitsquareAppModule = new BitsquareAppModule(env, primaryStage); injector = Guice.createInjector(bitsquareAppModule); injector.getInstance(GuiceControllerFactory.class).setInjector(injector); // route uncaught exceptions to a user-facing dialog Thread.currentThread().setUncaughtExceptionHandler( (thread, throwable) -> Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable))); // initialize the application data directory (if necessary) initAppDir(env.getRequiredProperty(APP_DATA_DIR_KEY)); // load and apply any stored settings User user = injector.getInstance(User.class); AccountSettings accountSettings = injector.getInstance(AccountSettings.class); Persistence persistence = injector.getInstance(Persistence.class); persistence.init();//from w ww . j a v a 2 s . c o m User persistedUser = (User) persistence.read(user); user.applyPersistedUser(persistedUser); accountSettings.applyPersistedAccountSettings( (AccountSettings) persistence.read(accountSettings.getClass().getName())); // load the main view and create the main scene ViewLoader viewLoader = injector.getInstance(ViewLoader.class); ViewLoader.Item loaded = viewLoader.load(Navigation.Item.MAIN.getFxmlUrl(), false); Scene scene = new Scene((Parent) loaded.view, 1000, 600); scene.getStylesheets().setAll("/io/bitsquare/gui/bitsquare.css", "/io/bitsquare/gui/images.css"); // configure the system tray SystemTray systemTray = new SystemTray(primaryStage, this::stop); primaryStage.setOnCloseRequest(e -> stop()); scene.setOnKeyReleased(keyEvent -> { // For now we exit when closing/quit the app. // Later we will only hide the window (systemTray.hideStage()) and use the exit item in the system tray for // shut down. if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent) || new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) stop(); }); // configure the primary stage primaryStage.setTitle(env.getRequiredProperty(APP_NAME_KEY)); primaryStage.setScene(scene); primaryStage.setMinWidth(75); primaryStage.setMinHeight(50); // on windows the title icon is also used as task bar icon in a larger size // on Linux no title icon is supported but also a large task bar icon is derived form that title icon String iconPath; if (Utilities.isOSX()) iconPath = ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png"; else if (Utilities.isWindows()) iconPath = "/images/task_bar_icon_windows.png"; else iconPath = "/images/task_bar_icon_linux.png"; if (iconPath != null) primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath))); // make the UI visible primaryStage.show(); }
From source file:io.bitsquare.app.BitsquareApp.java
@Override public void start(Stage stage) throws IOException { BitsquareApp.primaryStage = stage;/*from w w w . j a v a2 s .c om*/ String logPath = Paths.get(env.getProperty(AppOptionKeys.APP_DATA_DIR_KEY), "bitsquare").toString(); Log.setup(logPath); log.info("Log files under: " + logPath); Version.printVersion(); Utilities.printSysInfo(); Log.setLevel(Level.toLevel(env.getRequiredProperty(CommonOptionKeys.LOG_LEVEL_KEY))); UserThread.setExecutor(Platform::runLater); UserThread.setTimerClass(UITimer.class); shutDownHandler = this::stop; // setup UncaughtExceptionHandler Thread.UncaughtExceptionHandler handler = (thread, throwable) -> { // Might come from another thread if (throwable.getCause() != null && throwable.getCause().getCause() != null && throwable.getCause().getCause() instanceof BlockStoreException) { log.error(throwable.getMessage()); } else if (throwable instanceof ClassCastException && "sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData" .equals(throwable.getMessage())) { log.warn(throwable.getMessage()); } else { log.error("Uncaught Exception from thread " + Thread.currentThread().getName()); log.error("throwableMessage= " + throwable.getMessage()); log.error("throwableClass= " + throwable.getClass()); log.error("Stack trace:\n" + ExceptionUtils.getStackTrace(throwable)); throwable.printStackTrace(); UserThread.execute(() -> showErrorPopup(throwable, false)); } }; Thread.setDefaultUncaughtExceptionHandler(handler); Thread.currentThread().setUncaughtExceptionHandler(handler); try { Utilities.checkCryptoPolicySetup(); } catch (NoSuchAlgorithmException | LimitedKeyStrengthException e) { e.printStackTrace(); UserThread.execute(() -> showErrorPopup(e, true)); } Security.addProvider(new BouncyCastleProvider()); try { // Guice bitsquareAppModule = new BitsquareAppModule(env, primaryStage); injector = Guice.createInjector(bitsquareAppModule); injector.getInstance(InjectorViewFactory.class).setInjector(injector); Version.setBtcNetworkId(injector.getInstance(BitsquareEnvironment.class).getBitcoinNetwork().ordinal()); if (Utilities.isLinux()) System.setProperty("prism.lcdtext", "false"); Storage.setDatabaseCorruptionHandler((String fileName) -> { corruptedDatabaseFiles.add(fileName); if (mainView != null) mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles); }); // load the main view and create the main scene CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class); mainView = (MainView) viewLoader.load(MainView.class); mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles); /* Storage.setDatabaseCorruptionHandler((String fileName) -> { corruptedDatabaseFiles.add(fileName); if (mainView != null) mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles); });*/ scene = new Scene(mainView.getRoot(), 1200, 700); //740 Font.loadFont(getClass().getResource("/fonts/Verdana.ttf").toExternalForm(), 13); Font.loadFont(getClass().getResource("/fonts/VerdanaBold.ttf").toExternalForm(), 13); Font.loadFont(getClass().getResource("/fonts/VerdanaItalic.ttf").toExternalForm(), 13); Font.loadFont(getClass().getResource("/fonts/VerdanaBoldItalic.ttf").toExternalForm(), 13); scene.getStylesheets().setAll("/io/bitsquare/gui/bitsquare.css", "/io/bitsquare/gui/images.css", "/io/bitsquare/gui/CandleStickChart.css"); // configure the system tray SystemTray.create(primaryStage, shutDownHandler); primaryStage.setOnCloseRequest(event -> { event.consume(); stop(); }); scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEvent -> { if (new KeyCodeCombination(KeyCode.W, KeyCombination.SHORTCUT_DOWN).match(keyEvent) || new KeyCodeCombination(KeyCode.W, KeyCombination.CONTROL_DOWN).match(keyEvent)) { stop(); } else if (new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN).match(keyEvent) || new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN).match(keyEvent)) { stop(); } else if (new KeyCodeCombination(KeyCode.E, KeyCombination.SHORTCUT_DOWN).match(keyEvent) || new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN).match(keyEvent)) { showEmptyWalletPopup(); } else if (new KeyCodeCombination(KeyCode.M, KeyCombination.ALT_DOWN).match(keyEvent)) { showSendAlertMessagePopup(); } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.ALT_DOWN).match(keyEvent)) { showFilterPopup(); } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.ALT_DOWN).match(keyEvent)) { showFPSWindow(); } else if (new KeyCodeCombination(KeyCode.J, KeyCombination.ALT_DOWN).match(keyEvent)) { WalletService walletService = injector.getInstance(WalletService.class); if (walletService.getWallet() != null) new ShowWalletDataWindow(walletService).information("Wallet raw data").show(); else new Popup<>().warning("The wallet is not initialized yet").show(); } else if (new KeyCodeCombination(KeyCode.G, KeyCombination.ALT_DOWN).match(keyEvent)) { TradeWalletService tradeWalletService = injector.getInstance(TradeWalletService.class); WalletService walletService = injector.getInstance(WalletService.class); if (walletService.getWallet() != null) new SpendFromDepositTxWindow(tradeWalletService).information("Emergency wallet tool") .show(); else new Popup<>().warning("The wallet is not initialized yet").show(); } else if (DevFlags.DEV_MODE && new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) { showDebugWindow(); } }); // configure the primary stage primaryStage.setTitle(env.getRequiredProperty(APP_NAME_KEY)); primaryStage.setScene(scene); primaryStage.setMinWidth(1000); // 1190 primaryStage.setMinHeight(620); // on windows the title icon is also used as task bar icon in a larger size // on Linux no title icon is supported but also a large task bar icon is derived from that title icon String iconPath; if (Utilities.isOSX()) iconPath = ImageUtil.isRetina() ? "/images/window_icon@2x.png" : "/images/window_icon.png"; else if (Utilities.isWindows()) iconPath = "/images/task_bar_icon_windows.png"; else iconPath = "/images/task_bar_icon_linux.png"; primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath))); // make the UI visible primaryStage.show(); if (!Utilities.isCorrectOSArchitecture()) { String osArchitecture = Utilities.getOSArchitecture(); // We don't force a shutdown as the osArchitecture might in strange cases return a wrong value. // Needs at least more testing on different machines... new Popup<>() .warning("You probably have the wrong Bitsquare version for this computer.\n" + "Your computer's architecture is: " + osArchitecture + ".\n" + "The Bitsquare binary you installed is: " + Utilities.getJVMArchitecture() + ".\n" + "Please shut down and re-install the correct version (" + osArchitecture + ").") .show(); } UserThread.runPeriodically(() -> Profiler.printSystemLoad(log), LOG_MEMORY_PERIOD_MIN, TimeUnit.MINUTES); } catch (Throwable throwable) { showErrorPopup(throwable, false); } }
From source file:se.trixon.filebydate.ui.MainApp.java
private void initAccelerators() { final ObservableMap<KeyCombination, Runnable> accelerators = mStage.getScene().getAccelerators(); accelerators.put(new KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> { mStage.fireEvent(new WindowEvent(mStage, WindowEvent.WINDOW_CLOSE_REQUEST)); });//www .ja v a2s. co m accelerators.put(new KeyCodeCombination(KeyCode.N, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> { profileEdit(null); }); if (!IS_MAC) { accelerators.put(new KeyCodeCombination(KeyCode.COMMA, KeyCombination.SHORTCUT_DOWN), (Runnable) () -> { displayOptions(); }); } }