JOptionPane

Hi,Does anyone know how to disable/turn off resize for the dialogs created by JOptionPane? Thanks.-JH
[137 byte] By [slowmox] at [2007-9-26 4:13:16]
# 1

I have not tried this, but

if you want a message dialog that is not resizable:

Make a class that extends JOptionPane.

In that class, make your own createDialog method

with the same signature as the one in JOptionPane.

In that method, call super.createDialog,

and on the return value

call setResizable, which JDialog

inherits from the Window class.

Then return the JDialog.

mgwmgw at 2007-6-29 13:19:51 > top of Java-index,Archived Forums,Swing...
# 2

I could get dialog to be non-resizable using createDialog() method. But how does this work when using static method such as showOptionDialog? This is what I'm currently using.

Thanks.

> I have not tried this, but

> if you want a message dialog that is not resizable:

> Make a class that extends JOptionPane.

> In that class, make your own createDialog method

> with the same signature as the one in JOptionPane.

> In that method, call super.createDialog,

> and on the return value

> call setResizable, which JDialog

> inherits from the Window class.

> Then return the JDialog.

>

slowmox at 2007-6-29 13:19:51 > top of Java-index,Archived Forums,Swing...
# 3

just override this method of JOptionPane

public static Object showInputDialog(Component parentComponent, Object message,

String title, int messageType, Icon icon,

Object[] selectionValues, Object initialSelectionValue) {

JOptionPanepane = new JOptionPane(message, messageType,

OK_CANCEL_OPTION, icon,

null, null);

pane.setWantsInput(true);

pane.setSelectionValues(selectionValues);

pane.setInitialSelectionValue(initialSelectionValue);

JDialogdialog = pane.createDialog(parentComponent, title);

pane.selectInitialValue();

dialog.show();

dialog.setResizable(true);

Object value = pane.getInputValue();

if(value == UNINITIALIZED_VALUE)

return null;

return value;

}

hope this helps

raj_rash36 at 2007-6-29 13:19:51 > top of Java-index,Archived Forums,Swing...
# 4

I was able to override static showOptionDialog method and create a non-resizable dialog from it.

Thanks.

> just override this method of JOptionPane

>

> public static Object showInputDialog(Component

> parentComponent, Object message,

> String title, int messageType,

> tle, int messageType, Icon icon,

> Object[] selectionValues, Object

> lectionValues, Object initialSelectionValue) {

> JOptionPanepane = new JOptionPane(message,

> essage, messageType,

>

>

>

>

>

>

>

>

>

> OK_CANCEL_OPTION,

> OK_CANCEL_OPTION, icon,

> null,

> null, null);

>

> pane.setWantsInput(true);

> pane.setSelectionValues(selectionValues);

>

>

>

>

>

>

>

> pane.setInitialSelectionValue(initialSelectionValue);

>

> JDialogdialog =

> ialog = pane.createDialog(parentComponent, title);

>

> pane.selectInitialValue();

> dialog.show();

> dialog.setResizable(true);

>

> Object value = pane.getInputValue();

>

> if(value == UNINITIALIZED_VALUE)

> return null;

> return value;

> }

>

> hope this helps

slowmox at 2007-6-29 13:19:51 > top of Java-index,Archived Forums,Swing...
# 5
if u dont mind then .. duke Dollars :)Raj
raj_rash36 at 2007-6-29 13:19:51 > top of Java-index,Archived Forums,Swing...
# 6
Sure.> if u dont mind then .. duke Dollars :)> > Raj
slowmox at 2007-6-29 13:19:51 > top of Java-index,Archived Forums,Swing...