This discussion is archived
4 Replies Latest reply: Mar 22, 2013 4:54 AM by gimbal2 RSS

Multiple Checkbox Selection

905538 Newbie
Currently Being Moderated
Hi,


i have to make a frame using swing in which frame will contain multiple checkboxes(Eg.4),now suppose some one select one or two or three etc or all check box so depending upon selected checkbox the coresponding frame should come and after the clicking the save button the next frame should open for second checkbox(eg.A,B,C are the checkboxes and add,sub,mul are the coresponding frame and now if we select B,C checkbox so th first add sub frame should come after completing first frame work mul should come automatically similarly for all combination) please give any idea which could help me.





thanks
  • 1. Re: Multiple Checkbox Selection
    PhHein Guru Moderator
    Currently Being Moderated
    Moderator: Moved from JP
  • 2. Re: Multiple Checkbox Selection
    morgalr Explorer
    Currently Being Moderated
    Reading the basic Java Tutorial should help you a lot.
  • 3. Re: Multiple Checkbox Selection
    jduprez Pro
    Currently Being Moderated
    902535 wrote:
    Hi,
    i have to make a frame using swing in which frame will contain multiple checkboxes(Eg.4),now suppose some one select one or two or three etc or all check box so depending upon selected checkbox the coresponding frame should come and after the clicking the save button the next frame should open for second checkbox(eg.A,B,C are the checkboxes and add,sub,mul are the coresponding frame and now if we select B,C checkbox so th first add sub frame should come after completing first frame work mul should come automatically similarly for all combination) please give any idea which could help me.
    thanks
    Hello,
    if you don't have other unstated requirements (such as, the user should be able to jump to this or that other widget in the main frame while editing info in the new frames), each of your "frames" look like a widget that the user must finish dealing with before doing the next task.
    then it looks like a modal dialog (http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html).

    In particular, a handy way to display modal dialogs is to use JOPtionPane;showXxxDialog(...) , also described in this page of the Swing tutorial.

    That could look something like:
    /** Called after user clicks "OK" */
    public void actionPerformed(...) {
        if (checkboxAdd.isSelected()) {
            JOptionPane.showMessageDialog(new AdditionPanel(...),...);
        }
        if (checkboxSub.isSelected()) {
            JOptionPane.showMessageDialog(new SubstractionPanel(...),...);
        }
        if (checkboxMul.isSelected()) {
            JOptionPane.showMessageDialog(new MultiplicationPanel(),...);
        }
    }
    Best regards,

    J.
  • 4. Re: Multiple Checkbox Selection
    gimbal2 Guru
    Currently Being Moderated
    morgalr wrote:
    Reading the basic Java Tutorial should help you a lot.
    That is step 1. Step 2 would be to read the Swing tutorial.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points