在myeclipse中OK.addActionListener(new ActionListener()总显示错误
这是源代码importjava.awt.*;importjavax.swing.*;publicclassloginextendsJFrame{staticfinalin...
这是源代码
import java.awt.*;
import javax.swing.*;
public class login extends JFrame {
static final int WIDTH=300;
static final int HEIGHT=200;
public login(){
setTitle("欢迎使用ZDNF电子商务系统");
setSize(WIDTH,HEIGHT);
Container con=getContentPane();
JLabel label1=new JLabel("姓名:");
JTextField textField1=new JTextField(10);
textField1.setMaximumSize(textField1.getPreferredSize());
Box hbox1=Box.createHorizontalBox();
hbox1.add(label1);
hbox1.add(Box.createHorizontalStrut(20));
hbox1.add(textField1);
JLabel label2=new JLabel("密码:");
JPasswordField textField2=new JPasswordField(10);
textField2.setMaximumSize(textField2.getPreferredSize());
Box hbox2=Box.createHorizontalBox();
hbox2.add(label2);
hbox2.add(Box.createHorizontalStrut(20));
hbox2.add(textField2);
JButton OK=new JButton("登录");
JButton Cancel=new JButton("忘记密码?");
JButton resistered=new JButton("新用户注册");
Box hbox3=Box.createHorizontalBox();
hbox3.add(OK);
hbox3.add(Cancel);
hbox3.add(resistered);
OK.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent Event){
userresisteredframe resisteredframe=new userresisteredframe();
}
});
Box vbox=Box.createVerticalBox();
vbox.add(hbox1);
vbox.add(hbox2);
vbox.add(Box.createVerticalGlue());
vbox.add(hbox3);
con.add(vbox,BorderLayout.CENTER);
}
public static void main(String[] args){
Toolkit kit=Toolkit.getDefaultToolkit();
Dimension screenSize=kit.getScreenSize();
int width=screenSize.width;
int height=screenSize.height;
int x=(width-WIDTH)/2;
int y=(height-HEIGHT)/2;
login framel=new login();
framel.setLocation(x,y);
framel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
framel.show();
}
} 展开
import java.awt.*;
import javax.swing.*;
public class login extends JFrame {
static final int WIDTH=300;
static final int HEIGHT=200;
public login(){
setTitle("欢迎使用ZDNF电子商务系统");
setSize(WIDTH,HEIGHT);
Container con=getContentPane();
JLabel label1=new JLabel("姓名:");
JTextField textField1=new JTextField(10);
textField1.setMaximumSize(textField1.getPreferredSize());
Box hbox1=Box.createHorizontalBox();
hbox1.add(label1);
hbox1.add(Box.createHorizontalStrut(20));
hbox1.add(textField1);
JLabel label2=new JLabel("密码:");
JPasswordField textField2=new JPasswordField(10);
textField2.setMaximumSize(textField2.getPreferredSize());
Box hbox2=Box.createHorizontalBox();
hbox2.add(label2);
hbox2.add(Box.createHorizontalStrut(20));
hbox2.add(textField2);
JButton OK=new JButton("登录");
JButton Cancel=new JButton("忘记密码?");
JButton resistered=new JButton("新用户注册");
Box hbox3=Box.createHorizontalBox();
hbox3.add(OK);
hbox3.add(Cancel);
hbox3.add(resistered);
OK.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent Event){
userresisteredframe resisteredframe=new userresisteredframe();
}
});
Box vbox=Box.createVerticalBox();
vbox.add(hbox1);
vbox.add(hbox2);
vbox.add(Box.createVerticalGlue());
vbox.add(hbox3);
con.add(vbox,BorderLayout.CENTER);
}
public static void main(String[] args){
Toolkit kit=Toolkit.getDefaultToolkit();
Dimension screenSize=kit.getScreenSize();
int width=screenSize.width;
int height=screenSize.height;
int x=(width-WIDTH)/2;
int y=(height-HEIGHT)/2;
login framel=new login();
framel.setLocation(x,y);
framel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
framel.show();
}
} 展开
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询