簡體   English   中英

應該真的很簡單,我如何讓一個jbutton顯示我已經通過Eclipse中的窗口構建器創建的jframe?

[英]Should be really simple, how do I make a jbutton show a jframe i have already created via the window builder in eclipse?

不知道我是否只是在使用可視化基本方法,但給我的印象是我可以在eclipse中使用窗口構建器來創建我的Jframe,然后在選擇按鈕/動作偵聽器時簡單地調用它們...

喜歡:

JButton btn_register = new JButton("Register");
        btn_register.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                frm_register.setvisible(true);

            }

frm_register是注冊表格的類名...

YourFrame frame=new YourFrame();
frame.setVisible(true);

frm_register是注冊表格的類名...

我希望不是。 類名應以大寫字母開頭。 例如:RegistrationForm。

然后,您需要如下代碼:

RegistrationForm  register = new RegistrationForm();
register.setVisible( true );

當然,這假定RegistrationForm的構造函數將組件添加到表單並在表單上進行打包。

我可以在Eclipse中使用窗口構建器來創建我的Jframe,

另外,您不應該使用JFrame。 一個應用程序通常只有一個JFrame。 子窗口通常是JDialog。 請參閱: 使用多個JFrame:良好還是不良做法?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM