ld nametf=new JTextField(30);
JTextField pwdtf=new JTextField(30);
JTextField surepwdtf=new JTextField(30);
JTextField mailtf=new JTextField(30);
String name=null;
String pwd=null;
String mail=null;
//定义一个容器存放各种组件
JPanel enterPanel=new JPanel();
//定义一个背景图片
ImageIcon imageI=new ImageIcon("E:/图片/贴图/002.jpg");
//定义一个标签,把背景图片加入标签中
JLabel imgaeL=new JLabel(imageI);
public RegistWindow(){
this.setTitle("小静子个人音乐共享平台");
this.setLayout(null);
//设置图片位置和大小
imgaeL.setBounds(0, 0, 1300, 700);
//设置容器的位置
enterPanel.setBounds(680, 170,450, 350);
enterPanel.setLayout(null);
//设置标签的位置
nameJL.setBounds(75, 25, 90,70);
pwdJL.setBounds(75, 85,90, 70);
surepwdJL.setBounds(75, 145,90, 70);
mailJL.setBounds(75, 205, 90, 70);
//设置文本框的位置
nametf.setBounds(155, 35,205,34);
pwdtf.setBounds(155,95,205,34);
surepwdtf.setBounds(155, 155, 205, 34);
mailtf.setBounds(155, 215, 205, 34);
//设置按钮的位置
registBtn.setBounds(75, 265,85,40);
resetBtn.setBounds(175,265,85,40);
backBtn.setBounds(275, 265, 85, 40);
//将标签加入容器中
enterPanel.add(nameJL);
enterPanel.add(pwdJL);
enterPanel.add(surepwdJL);
enterPanel.add(mailJL);
//将文本框加入容器中
enterPanel.add(nametf);
enterPanel.add(pwdtf);
enterPanel.add(surepwdtf);
enterPanel.add(mailtf);
//将按钮加入容器中
enterPanel.add(resetBtn);
enterPanel.add(registBtn);
enterPanel.add(backBtn);
//设置容器的背景
enterPanel.setBackground(Color.red);
//将容器面板和标签图片加入界面中
this.add(enterPanel);
this.add(imgaeL);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//设置窗口的大小
this.setSize(1300,700);
//设置注册界面的位置位于中央
this.setLocationRelativeTo(null);
//窗体设置可见
this.setVisible(true);
//给三个按钮加上监听器
resetBtn.addActionListener(this);
registBtn.addActionListener(this);
backBtn.addActionListener(this);
}
public RegistWindow(String name,String pwd,String mail){
this.name=name;
this.pwd=pwd;
this.mail=mail;
}
public void actionPerformed(ActionEvent e){
//判断是哪个按键发出的
if(e.getSource()==resetBtn){
//如果点击重置按键,将文本框中的内容清空
nametf.setText("");
pwdtf.setText("");
surepwdtf.setText("");
mailtf.setText("");
}else if(e
相关热词:javajava 个人 音乐 共享 平台