开发者

how to create multiple frames in java swing component

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜