如何为JButton增加Enter事件,用ActionListener为何不行?如何将JFrame窗口最小化?谢谢!(50分)

H

hailang

Unregistered / Unconfirmed
GUEST, unregistred user!
如何为JButton增加Enter事件,用ActionListener为何不行?如何将JFrame窗口最小化?谢谢!
 
问题已经解决了:
一:为JButton增加Enter事件:
要先extends KeyAdapter
.....
JButton button1=new JButton("test");
button1.addKeyListener(this);
.....
public void keyPressed(KeyEvent ke)
{
if(ke.getKeyCode()==KeyEvent.VK_ENTER)
{
...........事件处理
}
}
二:JFrame最小化
JFrame aWindow=new JFrame("test");
aWindow.setState(1);
1是最小化。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
892
DelphiTeacher的专栏
D
I
回复
0
查看
531
import
I
顶部