开发者

how to create multiple frames in java swing component

开发者 https://www.devze.com 2023-01-07 09:26 出处:网络
i am new to java s开发者_运维技巧wing component. please tell me how to create multiple frames.

i am new to java s开发者_运维技巧wing component. please tell me how to create multiple frames. My requirement is ,base frame should contain 2 radio buttons and if i click anyone radio button it should go to other frame and it should display 4 check boxes.

Please advice


Why don't you read the docs and tutorial? http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/components/frame.html


check out how CardLayout works

https://docs.oracle.com/javase/tutorial/uiswing/layout/card.html

if you only want to switch between the windows:

  1. Add jPanel to your jFrame which will contain all jPanels you want to switch between (let's call it jPanelMain)
  2. Set CardLayout in jPanelMain
  3. Create jPanels you want to switch between with the stuff you need there
  4. Add Action Listener to the radio button, example

    private void jButtonActionPerformed(java.awt.event.ActionEvent e) {                                          
        jPanelMain.removeAll();
        jPanelMain.repaint();
        jPanelMain.revalidate();
        jPanelMain.add(jPanel1);
        jPanelMain.repaint();
        jPanelMain.revalidate();
    }  
    
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号