本文整理了Java中javax.swing.JTextArea.getActionMap()
方法的一些代码示例,展示了JTextArea.getActionMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextArea.getActionMap()
方法的具体详情如下:
包路径:javax.swing.JTextArea
类名称:JTextArea
方法名:getActionMap
暂无
代码示例来源:origin: runelite/runelite
notesEditor.getInputMap().put(KeyStroke.getKeyStroke("control Y"), "Redo");
notesEditor.getActionMap().put("Undo", new AbstractAction("Undo")
notesEditor.getActionMap().put("Redo", new AbstractAction("Redo")
代码示例来源:origin: stackoverflow.com
JTextArea ta = new JTextArea(10, 10);
Action action = ta.getActionMap().get("paste-from-clipboard");
ta.getActionMap().put("paste-from-clipboard", new ProxyAction(action));
代码示例来源: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
textArea1.getActionMap ().put ( "transferFocus", transferFocus );
frame.add ( new JScrollPane ( textArea1 ) );
textArea2.getActionMap ().put ( "transferFocus", transferFocus );
frame.add ( new JScrollPane ( textArea2 ) );
代码示例来源: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: stackoverflow.com
JTextArea ta = new JTextArea();
ActionMap am = ta.getActionMap();
Action paste = am.get("paste-from-clipboard");
Action copy = am.get("copy-to-clipboard");
Action cut = am.get("cut-to-clipboard");
代码示例来源: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: 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: 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: 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");
final KeyStroke close = KeyStroke.getKeyStroke(enterConfirms ? "ENTER" : "alt ENTER");
代码示例来源:origin: stackoverflow.com
editor.getActionMap().put("stopEditing", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
textArea.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
editorPane.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
textArea.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
textArea.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
editorPane.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
textArea.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
代码示例来源:origin: org.apache.uima/uimaj-tools
/**
* Inits the.
*
* @param file the file
* @param d the d
*/
public void init(File file, Dimension d) {
createMenus();
this.logFile = file;
this.textArea = new JTextArea();
// Copy
Action copyAction = this.textArea.getActionMap().get(DefaultEditorKit.copyAction);
copyAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C,
InputEvent.CTRL_MASK));
copyAction.setEnabled(true);
this.scrollPane = new JScrollPane(this.textArea);
this.setContentPane(this.scrollPane);
this.scrollPane.setPreferredSize(d);
boolean doneLoadingFile = loadFile();
if (!doneLoadingFile) {
this.dispose();
return;
}
this.pack();
this.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
ActionMap am = _resultArea.getActionMap();
代码示例来源:origin: Multibit-Legacy/multibit-hd
textArea.getActionMap().put("transferFocus", transferFocus);
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!