package org.csdn;import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;public class UserServerJFrame extends JFrame implements ActionListener
{
JButton check, aMend, KeyButton; UserServerJFrame()
{
check = new JButton("查看信息");
aMend = new JButton("修改信息");
KeyButton = new JButton("修改密码");
final JPanel pnlControl = new JPanel();
getContentPane().add(pnlControl, BorderLayout.SOUTH);
pnlControl.add(KeyButton);
pnlControl.add(aMend);
pnlControl.add(check);
setSize(800, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
KeyButton.addActionListener(this);
aMend.addActionListener(this);
check.addActionListener(this); } @Override
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == KeyButton)
new UserKey().setVisible(true); // 这报错
} public static void main(String[] args)
{
UserServerJFrame f = new UserServerJFrame();
f.setSize(600, 400);
f.setVisible(true);
}
}
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;public class UserServerJFrame extends JFrame implements ActionListener
{
JButton check, aMend, KeyButton; UserServerJFrame()
{
check = new JButton("查看信息");
aMend = new JButton("修改信息");
KeyButton = new JButton("修改密码");
final JPanel pnlControl = new JPanel();
getContentPane().add(pnlControl, BorderLayout.SOUTH);
pnlControl.add(KeyButton);
pnlControl.add(aMend);
pnlControl.add(check);
setSize(800, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
KeyButton.addActionListener(this);
aMend.addActionListener(this);
check.addActionListener(this); } @Override
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == KeyButton)
new UserKey().setVisible(true); // 这报错
} public static void main(String[] args)
{
UserServerJFrame f = new UserServerJFrame();
f.setSize(600, 400);
f.setVisible(true);
}
}
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;public class UserServerJFrame extends JFrame implements ActionListener {
JButton check, aMend, KeyButton; UserServerJFrame() {
JButton check = new JButton("查看信息");
JButton aMend = new JButton("修改信息");
JButton KeyButton = new JButton("修改密码");
aMend.setLayout(null);
KeyButton.setLayout(null);
check.setLayout(null);
aMend.setBounds(400, 300, 100, 50);
KeyButton.setBounds(600, 300, 100, 50);
check.setBounds(200, 300, 100, 50);
aMend.setVisible(true);
KeyButton.setVisible(true);
check.setVisible(true);
KeyButton.validate();
aMend.validate();
check.validate();
add(KeyButton);
add(aMend);
add(check);
setSize(800, 600);
setLayout(null);
// setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
validate();
KeyButton.addActionListener(this);
aMend.addActionListener(this);
check.addActionListener(this);
this.setVisible(true); } public void actionPerformed(ActionEvent e) {
if (e.getSource() == KeyButton) {
new UserKey().setVisible(true);
} // TODO Auto-generated method stub }
}
package cn.com.test;import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;public class UserKey extends JFrame implements ActionListener {
JLabel FormerKey, NewKey1, NewKey2; JPasswordField pass1, pass2, pass3; UserKey() {
setBounds(200, 200, 400, 300);
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
validate();
setVisible(true);
JLabel FormerKey = new JLabel("原始密码");
JLabel NewKey1 = new JLabel("新密码");
JLabel NewKey2 = new JLabel("确认新密码");
FormerKey.setLayout(null);
NewKey1.setLayout(null);
NewKey2.setLayout(null);
FormerKey.setBounds(50, 20, 97, 40);
NewKey1.setBounds(50, 70, 97, 40);
NewKey2.setBounds(50, 120, 97, 40);
setLayout(null);
FormerKey.setVisible(true);
NewKey1.setVisible(true);
NewKey2.setVisible(true);
NewKey1.validate();
NewKey2.validate();
FormerKey.validate();
add(NewKey1);
add(FormerKey);
add(NewKey2);
pass1 = new JPasswordField(100);
pass2 = new JPasswordField(100);
pass3 = new JPasswordField(100);
pass3.setLayout(null);
pass1.setLayout(null);
pass2.setLayout(null);
pass3.setBounds(125, 20, 222, 40);
pass1.setBounds(125, 70, 222, 40);
pass2.setBounds(125, 120, 222, 40);
pass3.setVisible(true);
pass1.setVisible(true);
pass2.setVisible(true);
pass1.validate();
pass2.validate();
pass3.validate();
add(pass1);
add(pass3);
add(pass2);
JButton Sure1 = new JButton("确定");
Sure1.setVisible(true);
Sure1.validate();
Sure1.setBounds(125, 200, 222, 40);
Sure1.setLayout(null);
add(Sure1); } public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub }
}
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;public class UserServerJFrame extends JFrame implements ActionListener {
JButton check, aMend, KeyButton; UserServerJFrame() {
JButton check = new JButton("查看信息");
JButton aMend = new JButton("修改信息");
JButton KeyButton = new JButton("修改密码");
aMend.setLayout(null);
KeyButton.setLayout(null);
check.setLayout(null);
aMend.setBounds(400, 300, 100, 50);
KeyButton.setBounds(600, 300, 100, 50);
check.setBounds(200, 300, 100, 50);
aMend.setVisible(true);
KeyButton.setVisible(true);
check.setVisible(true);
KeyButton.validate();
aMend.validate();
check.validate();
add(KeyButton);
add(aMend);
add(check);
setSize(800, 600);
setLayout(null);
// setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
validate();
KeyButton.addActionListener(this);
aMend.addActionListener(this);
check.addActionListener(this);
this.setVisible(true); } public void actionPerformed(ActionEvent e) {
if (e.getSource() == KeyButton) {
new UserKey().setVisible(true);
} // TODO Auto-generated method stub }
}
package cn.com.test;import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;public class UserKey extends JFrame implements ActionListener {
JLabel FormerKey, NewKey1, NewKey2; JPasswordField pass1, pass2, pass3; UserKey() {
setBounds(200, 200, 400, 300);
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
validate();
setVisible(true);
JLabel FormerKey = new JLabel("原始密码");
JLabel NewKey1 = new JLabel("新密码");
JLabel NewKey2 = new JLabel("确认新密码");
FormerKey.setLayout(null);
NewKey1.setLayout(null);
NewKey2.setLayout(null);
FormerKey.setBounds(50, 20, 97, 40);
NewKey1.setBounds(50, 70, 97, 40);
NewKey2.setBounds(50, 120, 97, 40);
setLayout(null);
FormerKey.setVisible(true);
NewKey1.setVisible(true);
NewKey2.setVisible(true);
NewKey1.validate();
NewKey2.validate();
FormerKey.validate();
add(NewKey1);
add(FormerKey);
add(NewKey2);
pass1 = new JPasswordField(100);
pass2 = new JPasswordField(100);
pass3 = new JPasswordField(100);
pass3.setLayout(null);
pass1.setLayout(null);
pass2.setLayout(null);
pass3.setBounds(125, 20, 222, 40);
pass1.setBounds(125, 70, 222, 40);
pass2.setBounds(125, 120, 222, 40);
pass3.setVisible(true);
pass1.setVisible(true);
pass2.setVisible(true);
pass1.validate();
pass2.validate();
pass3.validate();
add(pass1);
add(pass3);
add(pass2);
JButton Sure1 = new JButton("确定");
Sure1.setVisible(true);
Sure1.validate();
Sure1.setBounds(125, 200, 222, 40);
Sure1.setLayout(null);
add(Sure1); } public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub }
}