📄 e979. creating a jtextfield component.txt
字号:
When the user hits RETURN, the text field fires an action event.
// Create a text field with some initial text
JTextField textfield = new JTextField("Initial Text");
// Create a text field with some initial text and a default number of columns.
// The number of columns controls the preferred width of the component;
// each column is rougly the size of an M in the current font.
int cols = 30;
textfield = new JTextField("Initial Text", cols);
// Listen for action events, which are fired when the user hits RETURN
textfield.addActionListener(new MyActionListener());
class MyActionListener implements ActionListener {
public void actionPerformed(ActionEvent evt) {
JTextField textfield = (JTextField)evt.getSource();
process(textfield.getText());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -