Jump to content

Pop up window

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
ld_pvl

ld_pvl

    Learning Programmer

  • Members
  • PipPipPip
  • 46 posts
Hello,

I'm writing a GUI application in which the user is allowed to create a content for a table using a button. When the button is clicked, I want to have window popping up, where the user has to enter the number of steps and the step size, then either click OK or Cancel.

Should I make a new JFrame as the pop-up window or is there a better way?

In the programming perspective, how can I code my application so that the flow of the code stops and waits until the user has entered some values and pressed the OK button.

I mean like this:

    

private void GenerateTables(JTable Table) {


        //StepAndSize is the pop-up window frame


        StepsAndSize SandS = new StepsAndSize();

        SandS.setVisible(true);


        //...other codes

        

    }


When I call the GenerateTables method, it will create a pop-up window, but as soon as the window is created it will continue to the next lines (other codes) but not waiting for the user to enter their values first.

Please help,
Thank you

#2
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts

ld_pvl said:

Hello,

I'm writing a GUI application in which the user is allowed to create a content for a table using a button. When the button is clicked, I want to have window popping up, where the user has to enter the number of steps and the step size, then either click OK or Cancel.

Should I make a new JFrame as the pop-up window or is there a better way?

In the programming perspective, how can I code my application so that the flow of the code stops and waits until the user has entered some values and pressed the OK button.

I mean like this:

    

private void GenerateTables(JTable Table) {


        //StepAndSize is the pop-up window frame


        StepsAndSize SandS = new StepsAndSize();

        SandS.setVisible(true);


        //...other codes

        

    }


When I call the GenerateTables method, it will create a pop-up window, but as soon as the window is created it will continue to the next lines (other codes) but not waiting for the user to enter their values first.

Please help,
Thank you

Would be good if you made the method with a pop-up window(Frame). So you can add items and etc :)
Plus would be easiest, since you could easily just make it visible(true) or(false), when button clicked !

Cheers !
Posted Image

#3
ld_pvl

ld_pvl

    Learning Programmer

  • Members
  • PipPipPip
  • 46 posts

Turk4n said:

Would be good if you made the method with a pop-up window(Frame). So you can add items and etc :)
Plus would be easiest, since you could easily just make it visible(true) or(false), when button clicked !

Cheers !

That sounds good. What about the flow of the code? I know there are some methods like .wait() and .notify() that might help but I don't know how to implement them.

Basically I want the program to pop up the window, wait for the user to enter values and hit OK, then go and do the rest of the code. Or shall I just split the tasks into different methods and then call them correspondingly.

Thanks. I really want to know how to do this properly.

#4
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts

ld_pvl said:

That sounds good. What about the flow of the code? I know there are some methods like .wait() and .notify() that might help but I don't know how to implement them.

Basically I want the program to pop up the window, wait for the user to enter values and hit OK, then go and do the rest of the code. Or shall I just split the tasks into different methods and then call them correspondingly.

Thanks. I really want to know how to do this properly.

Do you have a code ready to be implement or you want to have a demo?
Posted Image

#5
ld_pvl

ld_pvl

    Learning Programmer

  • Members
  • PipPipPip
  • 46 posts

Turk4n said:

Do you have a code ready to be implement or you want to have a demo?

I just want to know the rules of thumb of how to do it because I think it's very common in GUI development.

I got a reply from Sun's forum regarding the same topic, and a guy told me I should use JDialogs instead of creating a new JFrame. I think that I was looking for.

#6
Turk4n

Turk4n

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,847 posts

ld_pvl said:

I just want to know the rules of thumb of how to do it because I think it's very common in GUI development.

I got a reply from Sun's forum regarding the same topic, and a guy told me I should use JDialogs instead of creating a new JFrame. I think that I was looking for.

Kewl, 4 u.
Posted Image