Hey everyone,

I am writing a Java program and I want to present the user with a settings window when they run a function in the main GUI so they can set the parameters which are used in the function.

Ideally what I would like to do in the main function (part of the main GUI JFrame) is;

  • Create an instance of the settings window (JFrame or maybe JDialog?)
  • Display the settings window
  • WAIT for the user to input some values and press the OK button in the settings window
  • Retrieve the values from the settings window
  • Run the rest of the function

My problem is 'pausing' the main function until the OK button has been pressed. I can't figure out how this should be done? I suppose it is very similar to the operation of a message box or a JFileChooser.

Sorry if this is a bit basic/obvious, but I'm more of a scientist than a programmer. If anyone could point me in the right direction I'd be very grateful.

Thanks,
Dan

Recommended Answers

All 3 Replies

What you are trying to do is very simple and explained in all basic GUI tutorials. Try to search some at the site of SUN

I have been the whole way through a couple of GUI tutorials and searched lots of others, but without having any idea what the function/operation might be called I'm struggling.

If someone could just tell me the name I'd be happy to look up how to use it.

I got the answer to this from someone else, so If anyone ever has the same problem the way to do it is with a JObjectPane. This can hold an object such as a JPanel and contains its own OK/cancel buttons which pauses the main program until one is selected.

There's a nice example here:
http://forums.sun.com/thread.jspa?forumID=54&threadID=5335602

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.