当前位置: 首页>>代码示例>>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;未经允许,请勿转载。