[英]Should be really simple, how do I make a jbutton show a jframe i have already created via the window builder in eclipse?
Not sure if I'm just using a visual basic approach, but I was under the impression i could use the window builder in eclipse to create my Jframes, then simply invoke them when the button/actionlistener is selected... 不知道我是否只是在使用可视化基本方法,但给我的印象是我可以在eclipse中使用窗口构建器来创建我的Jframe,然后在选择按钮/动作侦听器时简单地调用它们...
Like: 喜欢:
JButton btn_register = new JButton("Register");
btn_register.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
frm_register.setvisible(true);
}
frm_register is the class name for the register form... frm_register是注册表格的类名...
YourFrame frame=new YourFrame();
frame.setVisible(true);
frm_register is the class name for the register form...
frm_register是注册表格的类名...
I hope not. 我希望不是。 Class names should start with upper case character.
类名应以大写字母开头。 For example: RegistrationForm.
例如:RegistrationForm。
Then you need code like: 然后,您需要如下代码:
RegistrationForm register = new RegistrationForm();
register.setVisible( true );
This of course assumes that the constructor for the RegistrationForm adds components to the form and does a pack on the form. 当然,这假定RegistrationForm的构造函数将组件添加到表单并在表单上进行打包。
i could use the window builder in eclipse to create my Jframes,
我可以在Eclipse中使用窗口构建器来创建我的Jframe,
Also, you should not be using a JFrame. 另外,您不应该使用JFrame。 An application generally has a single JFrame.
一个应用程序通常只有一个JFrame。 A child window would typically be a JDialog.
子窗口通常是JDialog。 See: The Use of Multiple JFrames: Good or Bad Practice?
请参阅: 使用多个JFrame:良好还是不良做法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.