Need to add text to JOptionPane.showConfirmDialog

Posted 09 October 2012 - 06:21 AM

Like many of the posts I've read through, I'm also new to Java. All the code I've written works with one exception. I have the JoptionPane set-up to display multiple input fields. I am able to get all the fields I require and I can use the data entered as I need. What I am having problems with is putting a label on the field in the dialog box. I am able to put either the fields or text but not both.

Replies To: Need to add text to JOptionPane.showConfirmDialog

Re: Need to add text to JOptionPane.showConfirmDialog

Posted 09 October 2012 - 06:46 AM

Uhm so you want to do some gui stuff? Not the easiest thing for a beginner!

You might be better off using multiple showInputDialog s, it will be much easier for you

If I understand you correctly, then you want to show a label and an input box to the right of it?
The example blow does just that. It uses GridBagLayout which is one of the hardest layout managers to understand (I think), and I guess you haven't dealt with GUI components before
Oh well.. At least you can see what it looks like. You might be able to do some copy pasting without understanding the code 100%

Re: Need to add text to JOptionPane.showConfirmDialog

Posted 09 October 2012 - 07:57 AM

Thanks, that works well, and your right that is above my level. Initially I was using showInputDialog and had everything working correctly until I decided to many dialog boxes were appearing and I tried to streamline things by placing 4 input user fields onto the same dialog box. I was able to get that working as well, just couldn't label the fields.