Java Code Examples for java.awt.event.KeyEvent#VK_QUOTE

The following examples show how to use java.awt.event.KeyEvent#VK_QUOTE . 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: NewEntryFrameUtil.java    From Zettelkasten with GNU General Public License v3.0 6 votes vote down vote up
public static void checkSpelling(int key, javax.swing.JTextArea ta, Settings settingsObj, AutoKorrektur spellObj) {
    if (KeyEvent.VK_SPACE == key || KeyEvent.VK_PERIOD == key || KeyEvent.VK_COMMA == key || KeyEvent.VK_BRACELEFT == key || KeyEvent.VK_ENTER == key || KeyEvent.VK_OPEN_BRACKET == key || KeyEvent.VK_COLON == key || KeyEvent.VK_QUOTE == key) {
        if (ta != null) {
            try {
                int caret = ta.getCaretPosition();
                String text = ta.getText();
                if (settingsObj.getSpellCorrect()) {
                    if (caret > 2) {
                        int start = text.lastIndexOf(" ", caret - 2);
                        int start2 = text.lastIndexOf(System.lineSeparator(), caret - 2);
                        if (start2 > start) {
                            start = start2;
                        }
                        String wrong = text.substring(start + 1, caret - 1);
                        String correct = spellObj.getCorrectSpelling(wrong);
                        if (correct != null) {
                            StringBuilder sb = new StringBuilder(text);
                            sb.replace(start + 1, caret - 1, correct);
                            ta.setText(sb.toString());
                            caret = caret - wrong.length() + correct.length();
                            ta.setCaretPosition(caret);
                        }
                    }
                }
                if (KeyEvent.VK_QUOTE == key) {
                    // TODO Anfrührungszeichen ersetzen
                    // <ALT>+0132 bzw.
                    // <ALT>+0147 typographische Anführungszeichen oben / unten hin.
                }
            } catch (IndexOutOfBoundsException | IllegalArgumentException ex) {
            }
        }
    }
}
 
Example 2
Source File: ToggleStateCommand.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
private ToggleStateCommand() {
    super(I18n.Text("Toggle State"), CMD_TOGGLE_STATE, KeyEvent.VK_QUOTE);
}
 
Example 3
Source File: KeyCodeToChar.java    From Repeat with Apache License 2.0 4 votes vote down vote up
private static String getNonAlphaCharWithoutShift(int code) {
	switch (code) {
	case KeyEvent.VK_BACK_QUOTE:
		return "`";
	case KeyEvent.VK_1:
		return "1";
	case KeyEvent.VK_2:
		return "2";
	case KeyEvent.VK_3:
		return "3";
	case KeyEvent.VK_4:
		return "4";
	case KeyEvent.VK_5:
		return "5";
	case KeyEvent.VK_6:
		return "6";
	case KeyEvent.VK_7:
		return "7";
	case KeyEvent.VK_8:
		return "8";
	case KeyEvent.VK_9:
		return "9";
	case KeyEvent.VK_0:
		return "0";
	case KeyEvent.VK_MINUS:
		return "-";
	case KeyEvent.VK_EQUALS:
		return "=";
	case KeyEvent.VK_OPEN_BRACKET:
		return "[";
	case KeyEvent.VK_CLOSE_BRACKET:
		return "]";
	case KeyEvent.VK_SEMICOLON:
		return ";";
	case KeyEvent.VK_QUOTE:
		return "'";
	case KeyEvent.VK_BACK_SLASH:
		return "\\";
	case KeyEvent.VK_COMMA:
		return ",";
	case KeyEvent.VK_PERIOD:
		return ".";
	case KeyEvent.VK_SLASH:
		return "/";
	case KeyEvent.VK_TAB:
		return "\t";
	case KeyEvent.VK_ENTER:
		return "\n";
	case KeyEvent.VK_SPACE:
		return " ";
	default:
		return "";
	}
}
 
Example 4
Source File: KeyCodeToChar.java    From Repeat with Apache License 2.0 4 votes vote down vote up
private static String getNonAlphaCharWithShift(int code) {
	switch (code) {
	case KeyEvent.VK_BACK_QUOTE:
		return "~";
	case KeyEvent.VK_1:
		return "!";
	case KeyEvent.VK_2:
		return "@";
	case KeyEvent.VK_3:
		return "#";
	case KeyEvent.VK_4:
		return "$";
	case KeyEvent.VK_5:
		return "%";
	case KeyEvent.VK_6:
		return "^";
	case KeyEvent.VK_7:
		return "&";
	case KeyEvent.VK_8:
		return "*";
	case KeyEvent.VK_9:
		return "(";
	case KeyEvent.VK_0:
		return ")";
	case KeyEvent.VK_MINUS:
		return "_";
	case KeyEvent.VK_EQUALS:
		return "+";
	case KeyEvent.VK_OPEN_BRACKET:
		return "{";
	case KeyEvent.VK_CLOSE_BRACKET:
		return "}";
	case KeyEvent.VK_SEMICOLON:
		return ":";
	case KeyEvent.VK_QUOTE:
		return "\"";
	case KeyEvent.VK_BACK_SLASH:
		return "|";
	case KeyEvent.VK_COMMA:
		return "<";
	case KeyEvent.VK_PERIOD:
		return ">";
	case KeyEvent.VK_SLASH:
		return "?";
	case KeyEvent.VK_TAB:
		return "\t";
	case KeyEvent.VK_ENTER:
		return "\n";
	case KeyEvent.VK_SPACE:
		return " ";
	default:
		return "";
	}
}