其实我是java新手我想知道如何链接两个框架。我做了两个不同的java文件,看起来很简单。但直到现在我都无法解决它。它应该通过单击 Enter.java 中的 Next 按钮打开欢迎框架。有谁能够帮我?
这是我的代码:
Enter.java
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class Enter extends JFrame {
public Enter() {
// TODO Auto-generated constructor stub
setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
add(new JLabel("Name"));
add(new JTextField(8));
add(new JLabel("Address"));
add(new JTextField(15));
add(new JLabel("Surname"));
add(new JTextField(8));
add(new JLabel("Phone"));
add(new JTextField(8));
add(new JButton("Next"));
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Enter myProg = new Enter();
myProg.setTitle("Ceng 344 - Lab 7");
myProg.setSize(450, 400);
myProg.setLocationRelativeTo(null);
myProg.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myProg.setVisible(true);
}
}
Welcome.java
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class welcome extends JFrame {
public welcome() {
// TODO Auto-generated constructor stub
setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
add(new JLabel("Welcome"));
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
welcome myProg = new welcome();
myProg.setTitle("Ceng 344 - Lab 7");
myProg.setSize(450, 400);
myProg.setLocationRelativeTo(null);
myProg.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myProg.setVisible(true);
}
}