本文整理了Java中javax.swing.JTextArea.getInputMap()
方法的一些代码示例,展示了JTextArea.getInputMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextArea.getInputMap()
方法的具体详情如下:
包路径:javax.swing.JTextArea
类名称:JTextArea
方法名:getInputMap
暂无
代码示例来源:origin: runelite/runelite
notesEditor.getDocument().addUndoableEditListener(e -> undoRedo.addEdit(e.getEdit()));
notesEditor.getInputMap().put(KeyStroke.getKeyStroke("control Z"), "Undo");
notesEditor.getInputMap().put(KeyStroke.getKeyStroke("control Y"), "Redo");
代码示例来源:origin: com.synaptix/SynaptixSwing
private static JTextArea addEnterActionByTextArea(JTextArea textArea, boolean activeEnterKey, boolean activeCtrlEnterKey) {
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
Action enterAction = new EnterAction(textArea);
if (activeEnterKey) {
textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK), "enterAction");
}
if (activeCtrlEnterKey) {
textArea.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enterAction");
}
if (activeEnterKey || activeCtrlEnterKey) {
textArea.getActionMap().put("enterAction", enterAction);
}
return textArea;
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JTextArea jta = new JTextArea(20, 20);
//remove enter pressed
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
InputMap inputMap = jta.getInputMap();
inputMap.put(enter, "none");
//add shift+enter keybinding can be on pressed or released i.e false or true
jta.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK, true), "Shift+Enter released");
jta.getActionMap().put("Shift+Enter released", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent ae) {
System.out.println("Shift+Enter released");
}
});
frame.add(jta);
frame.pack();
frame.setVisible(true);
}
});
}
代码示例来源:origin: org.netbeans.api/org-netbeans-spi-quicksearch
@Override
protected JTextComponent createCommandField() {
JTextArea res = new DynamicWidthTA();
res.setRows(1);
res.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 1));
// disable default Swing's Ctrl+Shift+O binding to enable our global action
InputMap curIm = res.getInputMap(JComponent.WHEN_FOCUSED);
while (curIm != null) {
curIm.remove(KeyStroke.getKeyStroke(
KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
curIm = curIm.getParent();
}
return res;
}
代码示例来源:origin: stackoverflow.com
textArea1.getInputMap ().put ( KeyStroke.getKeyStroke ( "TAB" ), "transferFocus" );
textArea1.getActionMap ().put ( "transferFocus", transferFocus );
frame.add ( new JScrollPane ( textArea1 ) );
textArea2.getInputMap ().put ( KeyStroke.getKeyStroke ( "TAB" ), "transferFocus" );
textArea2.getActionMap ().put ( "transferFocus", transferFocus );
frame.add ( new JScrollPane ( textArea2 ) );
代码示例来源:origin: wildfly/wildfly-core
public CommandLine(DoOperationActionListener opListener) {
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets(0,0,0,5);
add(new JLabel("cmd>"), gbc);
cmdText.setBorder(new LineBorder(Color.BLACK));
cmdText.setText("/");
cmdText.setLineWrap(true);
cmdText.setRows(1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100.0;
add(cmdText, gbc);
KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
cmdText.getInputMap().put(enterKey, SUBMIT_ACTION);
cmdText.getActionMap().put(SUBMIT_ACTION, opListener);
JPanel submitPanel = new JPanel(new GridLayout(2,1));
submitButton.addActionListener(opListener);
submitButton.setToolTipText("Submit the command to the server.");
submitPanel.add(submitButton);
isVerbose.setToolTipText("Show the command's DMR request.");
submitPanel.add(isVerbose);
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.SOUTHEAST;
gbc.weightx = 1.0;
add(submitPanel, gbc);
}
代码示例来源:origin: org.wildfly.core/wildfly-cli
public CommandLine(DoOperationActionListener opListener) {
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = 1;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = new Insets(0,0,0,5);
add(new JLabel("cmd>"), gbc);
cmdText.setBorder(new LineBorder(Color.BLACK));
cmdText.setText("/");
cmdText.setLineWrap(true);
cmdText.setRows(1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 100.0;
add(cmdText, gbc);
KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
cmdText.getInputMap().put(enterKey, SUBMIT_ACTION);
cmdText.getActionMap().put(SUBMIT_ACTION, opListener);
JPanel submitPanel = new JPanel(new GridLayout(2,1));
submitButton.addActionListener(opListener);
submitButton.setToolTipText("Submit the command to the server.");
submitPanel.add(submitButton);
isVerbose.setToolTipText("Show the command's DMR request.");
submitPanel.add(isVerbose);
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.SOUTHEAST;
gbc.weightx = 1.0;
add(submitPanel, gbc);
}
代码示例来源:origin: Multibit-Legacy/multibit-hd
/**
* @param rows The number of rows (normally 6)
* @param columns The number of columns (normally 60)
*
* @return A new read only text field with default theme
*/
public static JTextArea newReadOnlyTextArea(int rows, int columns) {
JTextArea textArea = new JTextArea(rows, columns);
// Users should not be able to change the data
textArea.setEditable(false);
// Set the theme
textArea.setBorder(new TextBubbleBorder(Themes.currentTheme.readOnlyBorder()));
textArea.setBackground(Themes.currentTheme.readOnlyBackground());
textArea.setOpaque(false);
// Ensure line wrapping occurs correctly
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
// Ensure TAB transfers focus
AbstractAction transferFocus = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
((Component) e.getSource()).transferFocus();
}
};
textArea.getInputMap().put(KeyStroke.getKeyStroke("TAB"), "transferFocus");
textArea.getActionMap().put("transferFocus", transferFocus);
return textArea;
}
代码示例来源:origin: Multibit-Legacy/multibit-hd
/**
* @param rows The number of rows (normally 6)
* @param columns The number of columns (normally 60)
*
* @return A new read only text field with default theme
*/
public static JTextArea newTextArea(int rows, int columns) {
JTextArea textArea = new JTextArea(rows, columns);
// Set the theme
textArea.setBorder(new TextBubbleBorder(Themes.currentTheme.dataEntryBorder()));
textArea.setBackground(Themes.currentTheme.dataEntryBackground());
textArea.setOpaque(false);
// Ensure line wrapping occurs correctly
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
// Ensure TAB transfers focus
AbstractAction transferFocus = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
((Component) e.getSource()).transferFocus();
}
};
textArea.getInputMap().put(KeyStroke.getKeyStroke("TAB"), "transferFocus");
textArea.getActionMap().put("transferFocus", transferFocus);
return textArea;
}
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
InputMap textInputMap = textArea.getInputMap();
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui
protected JTextComponent createCommandField() {
JTextArea res = new JTextArea();
res.getAccessibleContext().setAccessibleName(NbBundle.getMessage(KenaiSearchPanel.class, "KenaiSearchPanel.searchLabel.text"));
res.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(KenaiSearchPanel.class, "KenaiSearchPanel.searchLabel.AccessibleContext.accessibleDescription"));
res.setRows(1);
res.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
// disable default Swing's Ctrl+Shift+O binding to enable our global action
InputMap curIm = res.getInputMap(JComponent.WHEN_FOCUSED);
while (curIm != null) {
curIm.remove(KeyStroke.getKeyStroke(
KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
curIm = curIm.getParent();
}
res.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
SearchField.this.actionPerformed(new ActionEvent(e.getSource(), e.getID(), SEARCH, e.getWhen(), e.getModifiers()));
e.consume();
}
}
});
return res;
}
代码示例来源:origin: Multibit-Legacy/multibit-hd
/**
* @return A new "message" text area (usually for signing for verifying)
*/
public static JTextArea newEnterMessage() {
JTextArea textArea = new JTextArea(4, MultiBitUI.PASSWORD_LENGTH);
// Ensure it is accessible
AccessibilityDecorator.apply(textArea, MessageKey.MESSAGE, MessageKey.MESSAGE_TOOLTIP);
textArea.setOpaque(false);
// Ensure line wrapping occurs correctly
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
// Ensure TAB transfers focus
AbstractAction transferFocus = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
((Component) e.getSource()).transferFocus();
}
};
textArea.getInputMap().put(KeyStroke.getKeyStroke("TAB"), "transferFocus");
textArea.getActionMap().put("transferFocus", transferFocus);
// Set the theme
textArea.setBorder(new TextBubbleBorder(Themes.currentTheme.dataEntryBorder()));
textArea.setBackground(Themes.currentTheme.dataEntryBackground());
return textArea;
}
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
InputMap textInputMap = textArea.getInputMap();
代码示例来源:origin: Multibit-Legacy/multibit-hd
/**
* @return A new "seed phrase" text area for entry
*/
public static JTextArea newEnterSeedPhrase() {
// Limit the length of the underlying document
DefaultStyledDocument doc = new DefaultStyledDocument();
doc.setDocumentFilter(new DocumentMaxLengthFilter(MultiBitUI.SEED_PHRASE_LENGTH));
// Wider than password to prevent push down on 24 word hidden text
JTextArea textArea = new JTextArea(doc, "", 6, MultiBitUI.SEED_PHRASE_WIDTH);
// Ensure it is accessible
AccessibilityDecorator.apply(textArea, MessageKey.SEED_PHRASE, MessageKey.SEED_PHRASE_TOOLTIP);
// Ensure TAB transfers focus
AbstractAction transferFocus = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
((Component) e.getSource()).transferFocus();
}
};
textArea.getInputMap().put(KeyStroke.getKeyStroke("TAB"), "transferFocus");
textArea.getActionMap().put("transferFocus", transferFocus);
// Ensure line and word wrapping occur as required
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
// Set the theme
textArea.setBorder(new TextBubbleBorder(Themes.currentTheme.dataEntryBorder()));
textArea.setBackground(Themes.currentTheme.dataEntryBackground());
textArea.setFont(new Font("Courier New", Font.PLAIN, 14));
return textArea;
}
代码示例来源:origin: stackoverflow.com
editor.setInheritsPopupMenu(true);
editor.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.CTRL_DOWN_MASK), "stopEditing");
editor.getActionMap().put("stopEditing", new AbstractAction() {
@Override
代码示例来源:origin: freeplane/freeplane
private void addTextEditor(final JComponent popup, final String label, final JTextArea editor) {
final InputMap inputMap = editor.getInputMap();
final ActionMap actionMap = editor.getActionMap();
final boolean enterConfirms = ResourceController.getResourceController().getBooleanProperty("el__enter_confirms_by_default");
代码示例来源:origin: Multibit-Legacy/multibit-hd
textArea.getInputMap().put(KeyStroke.getKeyStroke("TAB"), "transferFocus");
textArea.getActionMap().put("transferFocus", transferFocus);
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
});
im.setParent(findField.getInputMap(JComponent.WHEN_FOCUSED));
findField.setInputMap(JComponent.WHEN_FOCUSED, im);
im = new InputMap();
"ENTER", JTextField.notifyAction,
});
im.setParent(replaceField.getInputMap(JComponent.WHEN_FOCUSED));
replaceField.setInputMap(JComponent.WHEN_FOCUSED, im);
pack();
代码示例来源:origin: org.apache.uima/uimaj-tools
/**
* Inits the key map.
*/
private void initKeyMap() {
// Create a key map for focussing the index repository tree panel.
Action focusIRAction = new FocusIRAction(this);
String focusIRActionName = "focusIRAction";
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK), focusIRActionName);
getRootPane().getActionMap().put(focusIRActionName, focusIRAction);
// Create a key map for focussing the FS tree panel.
Action focusFSAction = new FocusFSAction(this);
String focusFSActionName = "focusFSAction";
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK), focusFSActionName);
getRootPane().getActionMap().put(focusFSActionName, focusFSAction);
// Create a key map for focussing the text area.
Action focusTextAction = new FocusTextAction(this);
String focusTextActionName = "focusTextAction";
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_MASK), focusTextActionName);
getRootPane().getActionMap().put(focusTextActionName, focusTextAction);
// Create a key map for bringing up the text area context menu.
Action textContextAction = new TextContextMenuAction(this);
String textContextActionName = "textContextAction";
this.textArea.getInputMap(JComponent.WHEN_FOCUSED).put(
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_MASK), textContextActionName);
this.textArea.getActionMap().put(textContextActionName, textContextAction);
}
代码示例来源:origin: stackoverflow.com
InputMap im = _resultArea.getInputMap(JComponent.WHEN_FOCUSED);
ActionMap am = _resultArea.getActionMap();
内容来源于网络,如有侵权,请联系作者删除!