这是我的代码问题是我找不到为什么要创建一个额外的表单
public void actionPerformed(ActionEvent ae){
submitBtn.setForeground(Color.red);
//getting value form the textFields
String name = nameTxt.getText();
String userName = userNameTxt.getText();
char[] pass = password.getPassword();
Object monthValue = month.getSelectedItem();
String yearValue = yearTxt.getText();
String dateValue = dateTxt.getText();
Object genderValue = gender.getSelectedItem();
String mobileValue = mobileTxt.getText();
Object locationValue = country.getSelectedItem();
showDetails page = new showDetails();
page.setVisible(true);
JPanel contentPane = new JPanel();
contentPane.setLayout(null);
contentPane.setBorder(BorderFactory.createTitledBorder("user Details"));
JLabel nameVL = new JLabel("Name : " + name );
nameVL.setBounds(80, 30, 200, 200);
contentPane.add(nameVL);
page.getContentPane().add(contentPane);
}
上面的代码在 signuppage.java 类中
我创建了一个表单来将标签的结果显示到 showDetails 类中
public class showDetails extends JFrame {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
public showDetails() {
JFrame showFrame = new JFrame("user details");
showFrame.setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
showFrame.setSize(300, 400);
showFrame.setVisible(true);
showFrame.setLocation((screen.width - 500)/2,((screen.height-350)/2));
}
}
但我的问题是结果没有显示在 showFram 中,而是创建了这种形式不知道如何....