📄 enabletest.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class EnableTest extends JFrame {
private JButton button1;
private JButton button2;
private JButton button3;
private JTextField text;
public EnableTest()
{
super( "Testing Enable" );
Container c = getContentPane();
c.setLayout( new FlowLayout() );
button1 = new JButton("Enable" );
button2 = new JButton("Visible" );
button3 = new JButton("Focus" );
button1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
text.setEnabled(!text.isEnabled());
}
});
button2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
text.setVisible(!text.isVisible());
}
});
button3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
text.requestFocus();
}
});
c.add( button1 );
c.add( button2 );
c.add( button3 );
text = new JTextField( "标签是否可用,可见",30);
c.add( text );
setSize( 350, 200 );
show();
}
public static void main( String args[] )
{
EnableTest app = new EnableTest();
app.addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent e )
{
System.exit( 0 );
}
}
);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -