本文整理匯總了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();
}