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.
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.
>
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
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