當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyCombination類代碼示例

本文整理匯總了Java中javafx.scene.input.KeyCombination的典型用法代碼示例。如果您正苦於以下問題:Java KeyCombination類的具體用法?Java KeyCombination怎麽用?Java KeyCombination使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


KeyCombination類屬於javafx.scene.input包,在下文中一共展示了KeyCombination類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createStage

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
/**
 * Creates stage by calling createScene and with almost every properties of object.
 *
 * @see GenericView#createScene()
 * @see javafx.stage.Stage
 * @return
 * @throws IOException
 */
public Stage createStage() throws IOException {
    Stage stage = new Stage();

    if (this.getTitle() != null) stage.setTitle(this.getTitle());

    stage.setScene(this.createScene());

    stage.setResizable(this.isResizable());
    stage.setMaximized(this.isMaximized());
    stage.setFullScreen(this.isFullscreen());
    stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);

    if (!this.isDecorated()) stage.initStyle(StageStyle.UNDECORATED);
    if (this.isModal()) stage.initModality(Modality.APPLICATION_MODAL);

    if (this.getIcon() != null)
        stage.getIcons().add(this.getIcon());

    if (this.getIcon() == null && GenericView.getGlobalIcon() != null)
        stage.getIcons().add(GenericView.getGlobalIcon());

    return stage;
}
 
開發者ID:erayerdin,項目名稱:primitivefxmvc,代碼行數:32,代碼來源:GenericView.java

示例2: getDownModifierMask

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
private static String getDownModifierMask(KeyCombination kc) {
    StringBuilder contextMenuKeyModifiers = new StringBuilder();
    if (kc.getControl() == ModifierValue.DOWN) {
        contextMenuKeyModifiers.append("Ctrl+");
    }
    if (kc.getAlt() == ModifierValue.DOWN) {
        contextMenuKeyModifiers.append("Alt+");
    }
    if (kc.getMeta() == ModifierValue.DOWN) {
        contextMenuKeyModifiers.append("Meta+");
    }
    if (kc.getShift() == ModifierValue.DOWN) {
        contextMenuKeyModifiers.append("Shift+");
    }
    return contextMenuKeyModifiers.toString();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:17,代碼來源:FXContextMenuTriggers.java

示例3: buildKeyCombination

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
/**
 * Convenience method for building {@link KeyCombination} objects from a string descriptor.
 * Supports any combination of Ctrl (or Mac Command), Alt, Shift plus one of the following:
 * <ul>
 * <li>letter [A-Z], case insensitive</li>
 * <li>digit [0-9]</li>
 * <li>backspace, space</li>
 * <li>&amp;, ^, *, \, !, +</li>
 * </ul>
 * 
 * @param keyCombination A string representing a key combination
 * @return A JavaFX <code>KeyCombination</code> object
 */
public static KeyCombination buildKeyCombination(String keyCombination) {
	keyCombination = keyCombination.toLowerCase();
	List<String> keys = Arrays.asList(keyCombination.split("\\+"));
	if(keys.size() < 1)
		throw new IllegalArgumentException("Key combination is empty");
	
	String stringCode = keys.get(keys.size() - 1);
	KeyCode keyCode = asKeyCombinationMain(stringCode);
	
	List<Modifier> modifiers = keys.stream()
			.limit(keys.size() - 1)
			.distinct()
			.map(FXKeyboard::asKeyCombinationModifier)
			.collect(Collectors.toList());	
	
	return new KeyCodeCombination(keyCode, modifiers.toArray(new Modifier[modifiers.size()]));
}
 
開發者ID:vibridi,項目名稱:fxutils,代碼行數:31,代碼來源:FXKeyboard.java

示例4: createViewMenu

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
private Menu createViewMenu() {
	final Menu view = new Menu("View");
	final CheckMenuItem darkMode = new CheckMenuItem("Dark Mode");
	darkMode.setSelected(rootModel.darkModeProperty().get());
	rootModel.darkModeProperty().addListener((obs, old, val) -> darkMode.setSelected(val));
	darkMode.setOnAction(e -> {
		rootController.toggleDarkMode(getStylesheets());
		invertImages();
	});

	final MenuItem lyrics = new MenuItem("Show Lyrics");
	lyrics.setOnAction(e -> rootController.lyricsPressed());
	lyrics.setAccelerator(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN));

	view.getItems().addAll(darkMode, lyrics);
	return view;
}
 
開發者ID:jakemanning,項目名稱:boomer-tuner,代碼行數:18,代碼來源:RootView.java

示例5: updateItem

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
@Override
protected void updateItem(KeyCombination item, boolean empty) {
  super.updateItem(item, empty);
  if (empty) {
    setText(null);
    setGraphic(null);
  } else {
    if (isEditing()) {
      setText(null);
      setGraphic(field);
    } else {
      setText(getString());
      setGraphic(null);
    }
  }
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:17,代碼來源:OptionsController.java

示例6: createField

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
private void createField() {
  field = new TextField(getString());
  field.setEditable(false);
  field.addEventFilter(KeyEvent.KEY_PRESSED, e -> {
    if (e.getCode() == KeyCode.ENTER) {
      try {
        commitEdit(KeyCombination.valueOf(field.getText()));
      } catch (Exception ee) {
        cancelEdit();
      }
    } else if (e.getCode() == KeyCode.ESCAPE) {
      cancelEdit();
    } else {
      field.setText(convert(e).toString());
    }
    e.consume();
  });
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:19,代碼來源:OptionsController.java

示例7: installExtension

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
public void installExtension(QuPathGUI qupath) {
	initDefaultViewTrackerFactory(qupath.getViewer());

	if (System.getProperty("os.name").toLowerCase().contains("linux")) {
		DisplayHelpers.showInfoNotification("Tracking extension issue reporting",
				"Bug reports and feature requests can be logged at:\n" +
				"http://github.com/Alanocallaghan/qupath-tracking-extension");
	} else {
		QuPathGUI.addMenuItems(
				qupath.getMenu("Extensions>Tracking", true),
				QuPathGUI.createCommandAction(
						new OpenWebpageCommand(qupath,
								"http://github.com/Alanocallaghan/qupath-tracking-extension/issues"),
						"Bug reports/issues")
		);
	}

	QuPathGUI.addMenuItems(
			qupath.getMenu("Extensions>Tracking", true),
			QuPathGUI.createCommandAction(new TrackingQuPathLoadCommand(), "Tracking extension"),
			new KeyCodeCombination(KeyCode.T, KeyCombination.CONTROL_DOWN)
			);

       // TODO: Use md5 sum to tie tracking instance to image (using MessageDigest) http://stackoverflow.com/questions/4187111/how-to-get-the-md5sum-of-a-file-in-java

}
 
開發者ID:Alanocallaghan,項目名稱:qupath-tracking-extension,代碼行數:27,代碼來源:QuPathTrackingExtension.java

示例8: handle

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
/**
 * Action to be taken on the selection of this menuItem
 */
@Override
public void handle() {
	/*
	 * Shuts the stage and sets fullscreen directives and defines
	 * a KeyCombination and shows the stage
	 * 
	 */
	this.myGameRunner.getGameDisplay().getStage().close();
	this.myGameRunner.getGameDisplay().getStage().setFullScreen(true);
	this.myGameRunner.getGameDisplay().getStage().setFullScreenExitHint(EXIT_MESSAGE);
	this.myGameRunner.getGameDisplay().getStage()
				.setFullScreenExitKeyCombination
				(new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN));
	this.myGameRunner.getGameDisplay().getStage().show();
}
 
開發者ID:sjain28,項目名稱:Game-Engine-Vooga,代碼行數:19,代碼來源:FullScreenWindowItem.java

示例9: popup

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
/**
 * Takes the user to the customized help page
 * 
 * @param link
 */
private void popup(String link){
	myBrowser = new WebView();
	myWebEngine = myBrowser.getEngine();
	myWebEngine.load(link);
	VBox vbox = new VBox();
	Scene scene = new Scene(vbox);
	Stage stage = new Stage();        
	vbox.getChildren().addAll(myBrowser);
	VBox.setVgrow(myBrowser, Priority.ALWAYS);
	stage.setScene(scene);
	stage.setFullScreen(true);
	stage.setFullScreenExitHint(EXIT_MESSAGE);
	stage.setFullScreenExitKeyCombination
	(new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN));
	stage.show();
}
 
開發者ID:sjain28,項目名稱:Game-Engine-Vooga,代碼行數:22,代碼來源:GetPlayerHelpHelpItem.java

示例10: start

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
    final ApplicationView applicationView = new ApplicationView();
    final ApplicationPresenter applicationPresenter = applicationView.getRealPresenter();
    
    final Scene scene = new Scene(applicationView.getView(), 1920, 1080);
    scene.setOnKeyReleased((KeyEvent event) -> {
        this.onKeyReleased(event);
    });
    primaryStage.setScene(scene);
    
    primaryStage.setFullScreen(true);
    primaryStage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
    primaryStage.setTitle(this.getProperty(KEY__APPLICATION__TITLE) + this.getProperty(KEY__APPLICATION__VERSION));
    primaryStage.setOnCloseRequest((WindowEvent we) -> {
       we.consume();
       
       this.onCloseRequest();
    });
    
    primaryStage.show();
    applicationPresenter.initializeAfterWindowIsShowing();
}
 
開發者ID:Naoghuman,項目名稱:Incubator,代碼行數:24,代碼來源:StartApplication.java

示例11: start

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
@Override
public void start(Stage primaryStage) throws NotYetSupportException, GargoyleConnectionFailException, InstantiationException, IllegalAccessException, ClassNotFoundException {
	primaryStage.setTitle("Database Exam");

	CommonsSqllPan sqlPane = CommonsSqllPan.getSqlPane();
	sqlPane.getStylesheets().add(SkinManager.getInstance().getSkin());
	BorderPane root = new BorderPane(sqlPane);
	Menu menu = new Menu("Exam");
	MenuItem e = new MenuItem("exam");
	e.setOnAction(System.out::println);
	e.setAccelerator(new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN));
	menu.getItems().add(e);
	root.setTop(new MenuBar(menu));

	primaryStage.setScene(new Scene(root, 1100, 700));

	primaryStage.show();

	// Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);

	// DockPane.initializeDefaultUserAgentStylesheet();

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:24,代碼來源:SqlTabPanExample.java

示例12: createMenus

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
/**
 *
 * 2016-10-27 키 이벤트를 setAccelerator를 사용하지않고 이벤트 방식으로 변경 이유 : 도킹기능을 적용하하면
 * setAccelerator에 등록된 이벤트가 호출안됨
 *
 * @작성자 : KYJ
 * @작성일 : 2016. 10. 27.
 */
public void createMenus() {

	Menu menuSearch = findAndReplaceHelper.createMenus();

	menuMoveToLine = new MenuItem("Move to line");
	miToUppercase = new MenuItem("To Uppercase");
	miToLowercase = new MenuItem("To Lowercase");

	menuMoveToLine.setAccelerator(new KeyCodeCombination(KeyCode.L, KeyCombination.CONTROL_DOWN));
	menuMoveToLine.setOnAction(this::moveToLineEvent);
	miToUppercase.setAccelerator(new KeyCodeCombination(KeyCode.U, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN));
	miToUppercase.setOnAction(this::toUppercaseEvent);
	miToLowercase.setAccelerator(new KeyCodeCombination(KeyCode.L, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN));
	miToLowercase.setOnAction(this::toLowercaseEvent);

	codeArea.getContextMenu().getItems().addAll(menuSearch, menuMoveToLine, miToUppercase, miToLowercase);

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:27,代碼來源:CodeAreaHelper.java

示例13: removeAcceleratorsFromScene

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
public static void removeAcceleratorsFromScene(List<? extends MenuItem> items, Scene scene) {
	if (scene == null) {
		return;
	}

	for (final MenuItem menuitem : items) {
		if (menuitem instanceof Menu) {
			// TODO remove the menu listener from the menu.items list

			// remove the accelerators of items contained within the menu
			removeAcceleratorsFromScene(((Menu) menuitem).getItems(), scene);
		} else {
			// remove the removed MenuItem accelerator KeyCombination from
			// the scene accelerators map
			final Map<KeyCombination, Runnable> accelerators = scene.getAccelerators();
			accelerators.remove(menuitem.getAccelerator());
		}
	}
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:20,代碼來源:DockTab.java

示例14: select

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
public void select (boolean activate)
{
  if (activate)
    plugin.activate ();
  else
    plugin.deactivate ();

  if (requestMenuItem == null && plugin.doesRequest ())
  {
    requestMenuItem = new MenuItem (name.getText ());
    requestMenuItem.setOnAction (e -> processPluginRequest (plugin));
    requestMenuItem.setAccelerator (new KeyCodeCombination (keyCodes[requestMenus++],
        KeyCombination.SHORTCUT_DOWN));
  }

  isActivated = activate;
}
 
開發者ID:xframium,項目名稱:xframium-java,代碼行數:18,代碼來源:PluginsStage.java

示例15: initializeKeyCombinations

import javafx.scene.input.KeyCombination; //導入依賴的package包/類
private void initializeKeyCombinations() {
    Map<KeyCombination, Runnable> keyCombinations = new HashMap<>();
    keyCombinations.put(keyCombination("F1"), this::showHelp);
    keyCombinations.put(keyCombination("CTRL+O"), this::chooseL2Folder);
    keyCombinations.put(keyCombination("CTRL+M"), this::modify);
    keyCombinations.put(keyCombination("CTRL+E"), this::exportSM);
    keyCombinations.put(keyCombination("CTRL+I"), this::importSM);
    keyCombinations.put(keyCombination("CTRL+T"), this::exportSMT3d);

    getStage().getScene().addEventFilter(KeyEvent.KEY_PRESSED, event -> keyCombinations.entrySet()
            .stream()
            .filter(e -> e.getKey().match(event))
            .findAny()
            .ifPresent(e -> {
                e.getValue().run();
                event.consume();
            }));
}
 
開發者ID:acmi,項目名稱:L2smr,代碼行數:19,代碼來源:Controller.java


注:本文中的javafx.scene.input.KeyCombination類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。