Java Code Examples for javafx.scene.input.KeyCombination#keyCombination()
The following examples show how to use
javafx.scene.input.KeyCombination#keyCombination() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Preferences_Controller.java From Path-of-Leveling with MIT License | 6 votes |
private KeyCombination loadKeybinds(Properties prop, String propertyName, TextField kc_field){ String loadProp = prop.getProperty(propertyName); KeyCombination keyCombination = null; //this should load the keybind on the controller but not overwrite if(loadProp == null){ //loadProp = hotkeyDefaults.get(propertyName); <- load default or return KeyCombination.NO_MATCH; } try{ keyCombination = KeyCombination.keyCombination(loadProp); System.out.println("-Preferences- Loaded keybind : " + keyCombination.getName() + " for "+ propertyName); }catch(Exception e){ System.out.println("-Preferences- Loading keybind for "+ propertyName+" failed."); keyCombination = KeyCombination.NO_MATCH; } kc_field.setText(loadProp); return keyCombination; }
Example 2
Source File: POELevelFx.java From Path-of-Leveling with MIT License | 6 votes |
private KeyCombination loadKeybinds(Properties prop, String propertyName, String defaultValue){ //check if hotkey is null, on older versions String loadProp = prop.getProperty(propertyName); KeyCombination keyCombination = null; //this should load the keybind on the controller but not overwrite if(loadProp == null){ //loadProp = defaultValue; <- load default or return KeyCombination.NO_MATCH; } try{ keyCombination = KeyCombination.keyCombination(loadProp); System.out.println("-POELevelFx- Loading keybind " + keyCombination.getName() +" for " + propertyName); }catch(Exception e){ System.out.println("-POELevelFx- Loading keybind for " + propertyName+ " failed."); keyCombination = KeyCombination.NO_MATCH; } return keyCombination; }
Example 3
Source File: Preferences_Controller.java From Path-of-Leveling with MIT License | 5 votes |
private KeyCombination saveKeybinds(Properties prop, String propertyName, String kc_field_text){ prop.setProperty(propertyName, kc_field_text); KeyCombination keyCombination = null; try{ keyCombination = KeyCombination.keyCombination(kc_field_text); System.out.println("-Preferences- Saved keybind : " + keyCombination.getName()+ " for "+propertyName); }catch(Exception e){ System.out.println("-Preferences- Saving keybind : for "+propertyName + " failed."); keyCombination = KeyCombination.NO_MATCH; } return keyCombination; }
Example 4
Source File: POELevelFx.java From Path-of-Leveling with MIT License | 5 votes |
private KeyCombination setKeybinds(Properties prop, String propertyName, String defaultValue){ prop.setProperty(propertyName, defaultValue); KeyCombination keyCombination = null; try{ keyCombination = KeyCombination.keyCombination(defaultValue); System.out.println("-POELevelFx- Setting keybind for : " + keyCombination.getName() +" for " + propertyName); }catch(Exception e){ System.out.println("-POELevelFx- Setting keybind for :" + propertyName + " failed."); keyCombination = KeyCombination.NO_MATCH; } return keyCombination; }
Example 5
Source File: JFXMenuItem.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public void setKeyCombination(UIKeyCombination keyCombination) { if( this.keyCombination == null || !this.keyCombination.equals(keyCombination)) { this.keyCombination = keyCombination; KeyCombination jfxKeyConvination = null; if( this.keyCombination != null ) { try { StringBuilder sb = new StringBuilder(); for(UIKey uiKey : this.keyCombination.getKeys()) { if( sb.length() > 0 ) { sb.append("+"); } if( UIKey.ALT.equals(uiKey) ) { sb.append(KeyCode.ALT.getName()); } else if( UIKey.SHIFT.equals(uiKey) ) { sb.append(KeyCode.SHIFT.getName()); } else if( UIKey.CONTROL.equals(uiKey) ) { sb.append(KeyCode.CONTROL.getName()); } else if( UIKey.COMMAND.equals(uiKey) ) { sb.append(KeyCode.META.getName()); } else { sb.append(uiKey.toString()); } } jfxKeyConvination = KeyCombination.keyCombination(sb.toString()); }catch (RuntimeException e) { e.printStackTrace(); } } this.getControl().setAccelerator(jfxKeyConvination); } }
Example 6
Source File: Preferences_Controller.java From Path-of-Leveling with MIT License | 4 votes |
private KeyCombination handleKeybindEdit(KeyEvent event, TextField kc_field, int nodeID){ if(event.isAltDown()){ key_bind = "Alt+"; if(event.getCode().getName().equals("Alt")){ key_bind = "Alt"; }else{ key_bind += event.getCode().getName(); } }else if(event.isControlDown()){ key_bind = "Ctrl+"; if(event.getCode().getName().equals("Ctrl")){ key_bind = "Ctrl"; }else{ key_bind += event.getCode().getName(); } }else if(event.isShiftDown()){ key_bind = "Shift+"; if(event.getCode().getName().equals("Shift")){ key_bind = "Shift"; }else{ key_bind += event.getCode().getName(); } }else{ key_bind += event.getCode().getName(); } KeyCombination kc_temp; try{ kc_temp = KeyCombination.keyCombination(key_bind); isBeingUsed(kc_temp,nodeID); kc_field.setText(key_bind); //System.out.println("key code : " + kc_temp.getName()); //zones_hotkey_show_hide_key = keyCombination; }catch(IllegalArgumentException e){ kc_field.setText(""); //System.out.println(":incorect:"); kc_temp = KeyCombination.NO_MATCH; }finally{ key_bind = ""; } return kc_temp; }