📄 textdemo.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TextDemo {
static JFrame jframe = new JFrame("Example");
public static void setupjframe() {
jframe.setSize(400,100);
jframe.setVisible(true);
jframe.getContentPane().setLayout( new FlowLayout() );
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
};
jframe.addWindowListener(l);
}
public static void main(String[] args) {
JTextField jtf = new JTextField(25);
JLabel jl = new JLabel("Enter your name:");
jtf.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e)
{ System.out.println(" you entered: " + e.getActionCommand() ); }
} );
Container c = jframe.getContentPane();
c.add( jl );
c.add( jtf );
setupjframe();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -