Is it possible to create a JDialog in swing that would return an object when OK button is clicked?
For example the Dialog box has text fields that have components that make up an adress ( street name, country etc.)
When the OK button is clicked an Address object is returned.
Why I thought this to be possible was because of this. But what I want is something like I mentioned above.
Any pointers on how to get this done would be very helpful.
Like the previous people suggested: JOptionPane can help you do what you want. But if you’re determined to implement this from scratch, here is an SSCCE that does exactly what you want (well, it returns a String, but it can be easily modified to suit your needs):
What you enter in that text-area is displayed on the main window when you press OK, just to prove it works 🙂 .