本文整理汇总了Java中javax.swing.JTextArea.addKeyListener方法的典型用法代码示例。如果您正苦于以下问题:Java JTextArea.addKeyListener方法的具体用法?Java JTextArea.addKeyListener怎么用?Java JTextArea.addKeyListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.addKeyListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: install
import javax.swing.JTextArea; //导入方法依赖的package包/类
public void install(JTextArea textArea) {
textArea.addCaretListener(this);
textArea.addComponentListener(this);
textArea.addFocusListener(this);
textArea.addKeyListener(this);
textArea.addMouseListener(this);
textArea.addMouseMotionListener(this);
}
示例2: DFDSNamePanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Create the panel.
*/
public DFDSNamePanel(Engine engine, Element element) {
super(new BorderLayout());
this.engine = engine;
this.element = element;
dataPlugin = NDataPluginFactory.getExistingDataPlugin(engine);
textArea = new JTextArea();
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setComponentPopupMenu(createSelectLanguageMenu());
textArea.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (undoManager == null)
return;
if (e.isControlDown()) {
if (e.getKeyCode() == KeyEvent.VK_Z)
if (undoManager.canUndo())
undoManager.undo();
if (e.getKeyCode() == KeyEvent.VK_Y)
if (undoManager.canRedo())
undoManager.redo();
}
}
});
if (dataPlugin != null) {
Row row = dataPlugin.findRowByGlobalId(element.getId());
if (row instanceof Function) {
Function function = (Function) row;
panel = new ArrowLinksPanel(function);
JSplitPane splitPane = new JSplitPane();
add(splitPane, BorderLayout.CENTER);
splitPane.setLeftComponent(new JScrollPane(textArea));
splitPane.setRightComponent(panel);
createChecker();
return;
}
}
add(new JScrollPane(textArea), BorderLayout.CENTER);
createChecker();
}
示例3: initGUI
import javax.swing.JTextArea; //导入方法依赖的package包/类
private void initGUI() {
JPanel pCommand = new JPanel();
pResult = new JPanel();
nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand,
pResult);
pCommand.setLayout(new BorderLayout());
pResult.setLayout(new BorderLayout());
Font fFont = new Font("Dialog", Font.PLAIN, 12);
txtCommand = new JTextArea(5, 40);
txtCommand.setMargin(new Insets(5, 5, 5, 5));
txtCommand.addKeyListener(this);
txtCommandScroll = new JScrollPane(txtCommand);
txtResult = new JTextArea(20, 40);
txtResult.setMargin(new Insets(5, 5, 5, 5));
txtResultScroll = new JScrollPane(txtResult);
txtCommand.setFont(fFont);
txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
/*
// button replaced by toolbar
butExecute = new JButton("Execute");
butExecute.addActionListener(this);
pCommand.add(butExecute, BorderLayout.EAST);
*/
pCommand.add(txtCommandScroll, BorderLayout.CENTER);
gResult = new GridSwing();
TableSorter sorter = new TableSorter(gResult);
tableModel = sorter;
gResultTable = new JTable(sorter);
sorter.setTableHeader(gResultTable.getTableHeader());
gScrollPane = new JScrollPane(gResultTable);
gResultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
gResult.setJTable(gResultTable);
//getContentPane().setLayout(new BorderLayout());
pResult.add(gScrollPane, BorderLayout.CENTER);
// Set up the tree
rootNode = new DefaultMutableTreeNode("Connection");
treeModel = new DefaultTreeModel(rootNode);
tTree = new JTree(treeModel);
tScrollPane = new JScrollPane(tTree);
tScrollPane.setPreferredSize(new Dimension(120, 400));
tScrollPane.setMinimumSize(new Dimension(70, 100));
txtCommandScroll.setPreferredSize(new Dimension(360, 100));
txtCommandScroll.setMinimumSize(new Dimension(180, 100));
gScrollPane.setPreferredSize(new Dimension(460, 300));
ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
tScrollPane, nsSplitPane);
fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER);
doLayout();
fMain.pack();
}