当前位置: 首页>>代码示例>>Java>>正文


Java KeyCodeCombination类代码示例

本文整理汇总了Java中javafx.scene.input.KeyCodeCombination的典型用法代码示例。如果您正苦于以下问题:Java KeyCodeCombination类的具体用法?Java KeyCodeCombination怎么用?Java KeyCodeCombination使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


KeyCodeCombination类属于javafx.scene.input包,在下文中一共展示了KeyCodeCombination类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildKeyCombination

import javafx.scene.input.KeyCodeCombination; //导入依赖的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

示例2: requestScene

import javafx.scene.input.KeyCodeCombination; //导入依赖的package包/类
@Subscribe
public void requestScene( final SceneEvent sceneType ) {
    final Scene scene = _injector.getInstance( sceneType.getType( ) );
    scene.getAccelerators( ).put( new KeyCodeCombination( KeyCode.F11 ),
            ( ) -> {
                _primaryStage.setFullScreen( !_primaryStage.isFullScreen( ) );
            } );
    scene.getAccelerators( ).put( new KeyCodeCombination( KeyCode.ESCAPE ),
            ( ) -> {
                _eventBus.post( new SceneEvent( ConfigurationScene.class ) );
            } );
    LOGGER.info( "Change scene to " + sceneType.getType( ).getSimpleName( ) );
    _primaryStage.setScene( scene );

    if ( scene instanceof WallScene )
        _apiMonitoringService.activate( );
    else
        _apiMonitoringService.pause( );
}
 
开发者ID:u2032,项目名称:wall-t,代码行数:20,代码来源:WallApplication.java

示例3: createViewMenu

import javafx.scene.input.KeyCodeCombination; //导入依赖的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

示例4: convert

import javafx.scene.input.KeyCodeCombination; //导入依赖的package包/类
private String convert(KeyEvent e) {
  return TaskUtil.firstSuccess(
      () -> new KeyCodeCombination(e.getCode(),
          e.isShiftDown() ? ModifierValue.DOWN : ModifierValue.UP,
          e.isControlDown() ? ModifierValue.DOWN : ModifierValue.UP,
          e.isAltDown() ? ModifierValue.DOWN : ModifierValue.UP,
          e.isMetaDown() ? ModifierValue.DOWN : ModifierValue.UP,
          ModifierValue.UP).toString(),
      () -> {
        KeyCodeCombination key = new KeyCodeCombination(KeyCode.A,
            e.isShiftDown() ? ModifierValue.DOWN : ModifierValue.UP,
            e.isControlDown() ? ModifierValue.DOWN : ModifierValue.UP,
            e.isAltDown() ? ModifierValue.DOWN : ModifierValue.UP,
            e.isMetaDown() ? ModifierValue.DOWN : ModifierValue.UP,
            ModifierValue.UP);
        String name = key.getName();
        return name.substring(0, name.length() - key.getCode().getName().length());
      });
}
 
开发者ID:XDean,项目名称:CSS-Editor-FX,代码行数:20,代码来源:OptionsController.java

示例5: installExtension

import javafx.scene.input.KeyCodeCombination; //导入依赖的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

示例6: handle

import javafx.scene.input.KeyCodeCombination; //导入依赖的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

示例7: popup

import javafx.scene.input.KeyCodeCombination; //导入依赖的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

示例8: start

import javafx.scene.input.KeyCodeCombination; //导入依赖的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

示例9: createMenus

import javafx.scene.input.KeyCodeCombination; //导入依赖的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

示例10: select

import javafx.scene.input.KeyCodeCombination; //导入依赖的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

示例11: translateAccelerator

import javafx.scene.input.KeyCodeCombination; //导入依赖的package包/类
/**
 * converts a swing accelerator key to a JavaFX key combination
 *
 * @param acceleratorKey
 * @return key combination
 */
public static KeyCombination translateAccelerator(KeyStroke acceleratorKey) {
    final List<KeyCombination.Modifier> modifiers = new ArrayList<>();

    if ((acceleratorKey.getModifiers() & java.awt.event.InputEvent.SHIFT_DOWN_MASK) != 0)
        modifiers.add(KeyCombination.SHIFT_DOWN);
    if ((acceleratorKey.getModifiers() & java.awt.event.InputEvent.CTRL_DOWN_MASK) != 0)
        modifiers.add(KeyCombination.CONTROL_DOWN);
    if ((acceleratorKey.getModifiers() & java.awt.event.InputEvent.ALT_DOWN_MASK) != 0)
        modifiers.add(KeyCombination.ALT_DOWN);
    if ((acceleratorKey.getModifiers() & InputEvent.META_DOWN_MASK) != 0)
        modifiers.add(KeyCombination.META_DOWN);

    KeyCode keyCode = FXSwingUtilities.getKeyCodeFX(acceleratorKey.getKeyCode());
    return new KeyCodeCombination(keyCode, modifiers.toArray(new KeyCombination.Modifier[modifiers.size()]));
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:22,代码来源:CommandManagerFX.java

示例12: start

import javafx.scene.input.KeyCodeCombination; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
	this.stage = primaryStage;
	initMapScripts();
	MenuManager menuManager = new MenuManager(this.stage, this.mapScripts);
	menuManager.DisplayMenus();
	this.stage.show();

	//TODO: shortcut to go fullscreen?

	// shortcut to exit fullscreen
	this.stage.setFullScreenExitKeyCombination(new KeyCodeCombination(KeyCode.F, KeyCombination.SHIFT_DOWN));

	this.stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
		@Override
		public void handle(WindowEvent event) {
			TimeManager.getInstance().end();
			EventDispatcher.getInstance().fire(new GameExitEvent());
		}
	});
}
 
开发者ID:TiWinDeTea,项目名称:MagicMetro,代码行数:22,代码来源:Main.java

示例13: createOpenAction

import javafx.scene.input.KeyCodeCombination; //导入依赖的package包/类
Action createOpenAction(final String name) {
	Action action = new Action(name, e -> {
		
		String dirPath = PathPrefs.getScriptsPath();
		File dir = null;
		if (dirPath != null)
			dir = new File(dirPath);
		File file = QuPathGUI.getSharedDialogHelper().promptForFile("Choose script file", dir, "Known script files", SCRIPT_EXTENSIONS);
		if (file == null)
			return;
		try {
			addScript(file, true);
			PathPrefs.setScriptsPath(file.getParent());
		} catch (Exception ex) {
			logger.error("Unable to open script file: {}", ex);
			ex.printStackTrace();
		}
	});
	action.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN));
	return action;
}
 
开发者ID:qupath,项目名称:qupath,代码行数:22,代码来源:DefaultScriptEditor.java

示例14: JfxUndoRedoKeyEventToJme

import javafx.scene.input.KeyCodeCombination; //导入依赖的package包/类
private static void JfxUndoRedoKeyEventToJme() {
    Jfx.getJfxRoot().addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
        final KeyCombination undo = new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN);
        final KeyCombination redo = new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN);
        final KeyCombination save = new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN);
        final KeyCombination saveAll = new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN);
        @Override
        public void handle(KeyEvent ke) {
            if (save.match(ke)) {
                ((Editor) Jfx.getJmeApp()).save();
            } else if (saveAll.match(ke)) {
                ((Editor) Jfx.getJmeApp()).saveAll();
            } else if(redo.match(ke)) {
                ((Editor) Jfx.getJmeApp()).redo();
            } else if (undo.match(ke)) {
                ((Editor) Jfx.getJmeApp()).undo();
            }
        }
    });
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:21,代码来源:UIManager.java

示例15: handleKeyPressed

import javafx.scene.input.KeyCodeCombination; //导入依赖的package包/类
private void handleKeyPressed(KeyEvent e) {
  if (e.isConsumed()) {
    return;
  }
  if (new KeyCodeCombination(KeyCode.ESCAPE).match(e)) {
    close();
    e.consume();
    return;
  }
  if (new KeyCodeCombination(KeyCode.ENTER).match(e)) {
    Button defaultButton = (Button) container.lookup("#defaultButton");
    defaultButton.arm();
    e.consume();
    return;
  }
}
 
开发者ID:Adrodoc55,项目名称:MPL,代码行数:17,代码来源:MultiContentDialog.java


注:本文中的javafx.scene.input.KeyCodeCombination类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。