从Java中的另一个应用程序启动WindowApplication
我有一个名为Login的Java窗口应用程序,它有一个按钮,一旦用户输入了正确的数据,就可以进入菜单 我怎样才能让它启动另一个名为Prueba的WindowApplication 我是否还必须从要启动的新windows中删除main()方法 我当前尝试的按钮侦听器是从Java中的另一个应用程序启动WindowApplication,java,swing,Java,Swing,我有一个名为Login的Java窗口应用程序,它有一个按钮,一旦用户输入了正确的数据,就可以进入菜单 我怎样才能让它启动另一个名为Prueba的WindowApplication 我是否还必须从要启动的新windows中删除main()方法 我当前尝试的按钮侦听器是 btnLogin.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) {
btnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
frmAdministracinHospital.setVisible(false);
new Prueba();
}
});
但它不起作用
普鲁巴级:
package presentacion;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JComboBox;
public class Prueba {
private JFrame frame;
/**
* Create the application.
*/
public Prueba() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
frame.getContentPane().add(panel, BorderLayout.CENTER);
JComboBox comboBox = new JComboBox();
panel.add(comboBox);
}
}
有什么建议吗
提前谢谢 Prueba类的框架从不可见
您所要做的就是添加
frame.setVisible(true)
位于initialize()
方法的末尾,或Prueba()
构造函数的末尾。请提供Prueba
类的代码。或者将“Prueba”应用程序作为依赖项添加到“login”应用程序中,并手动调用其start(main
)方法。或者使用ProceBuilder通过命令启动它。但是请注意,命令必须根据操作系统的不同而有所不同才能工作!完成@Bergery您必须使Prueba
的框架可见:frame.setVisible(true)代码>。成功了,谢谢!如果您愿意@Berger,可以将其添加为答案