Problems with resizeble JOptionPane/JDialog

R

RC

I created a popup with JOptionPane, it works fine except I can NOT
resize the popup window.

Here are the codes:

JPanel myPanel = new JPanel();

JOptionPane.showConfirmDialog(null, myPanel,
"Dialog",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE, null));

Again this works fine except I can NOT resize the popup window
I need to resize the popup dialog window!

I changed in different way
Here are the codes:

JPanel myPanel = new JPanel();

JOptionPane optionPane = new JOptionPane(myPanel, // Object message
JOptionPane.PLAIN_MESSAGE, // messageType
JOptionPane.OK_CANCEL_OPTION); // optionType

JDialog dialog = new JDialog(new JFrame("Chart Manager"),
"Set Chart Properties",
false);

dialog.setContentPane(optionPane);

Now I can resize the popup dialog window
But the new problem come up. When I changed (resize) the
popup dialog window to SMALLER, those OK, Cancel buttons
are gone (disappear)! Order for me see those OK, Cancel
buttons, I need to resize the popup dialog window back to
ORIGAINL size or BIGGER.

Can anyone out there help me make a popup dialog window
resizeble AND keep the OK, Cancel buttons visible in ALL
time?

Thank Q very much in advance!
 
T

Thomas Weidenfeller

RC said:
I created a popup with JOptionPane, it works fine except I can NOT
resize the popup window.

There is no need to post this question to three newsgroups.
Again this works fine except I can NOT resize the popup window
I need to resize the popup dialog window!

There is no need to shout. Your problem is not earth shakening.
Can anyone out there help me make a popup dialog window
resizeble AND keep the OK, Cancel buttons visible in ALL
time?

Layout your own JDialog.

/Thomas
 
R

RedGrittyBrick

RC said:
I created a popup with JOptionPane, it works fine except I can NOT
resize the popup window.

Here are the codes:

JPanel myPanel = new JPanel();

JOptionPane.showConfirmDialog(null, myPanel,
"Dialog",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE, null));

Again this works fine except I can NOT resize the popup window
I need to resize the popup dialog window!

I asked *exactly* the same question just a few days ago and got a good
answer. You can use Google Groups to look it up.
I changed in different way
Here are the codes:

JPanel myPanel = new JPanel();

JOptionPane optionPane = new JOptionPane(myPanel, // Object message
JOptionPane.PLAIN_MESSAGE, // messageType
JOptionPane.OK_CANCEL_OPTION); // optionType

JDialog dialog = new JDialog(new JFrame("Chart Manager"),
"Set Chart Properties",
false);

dialog.setContentPane(optionPane);

Now I can resize the popup dialog window
But the new problem come up. When I changed (resize) the
popup dialog window to SMALLER, those OK, Cancel buttons
are gone (disappear)! Order for me see those OK, Cancel
buttons, I need to resize the popup dialog window back to
ORIGAINL size or BIGGER.

I'm no expert but it seems to me that putting a non-resizable component
inside a resizable one (and without a scrollpane) is a sure recipe for
the symptoms you report.

You need to create a JOptionDialog without using the static showXXX
methods. Then you can apply an instance method to make the dialog resizable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top