Open iamchathu opened 9 years ago
Unfortunately there is no separate option for JOptionPane
or WebOptionPane
since Swing basically doesn't have one by default. But I might be able to add it later on.
Still, there is a simple workaround - you can set "decorate dialogs" option to true
before creating any JOptionPane
or WebOptionPane
and switch it back to false
after. That should do the trick.
Here is a small example:
public class DialogDecorationExample
{
public static void main ( String[] args )
{
WebLookAndFeel.install ();
final TestFrame frame = TestFrame.show ( new WebLabel ( "Test" ), 50 );
WebLookAndFeel.setDecorateDialogs ( true );
JOptionPane.showMessageDialog ( frame, "Sample message" );
WebLookAndFeel.setDecorateDialogs ( false );
}
}
Option "decorate dialogs" is queued each time some dialog instance is created. So you are free to change it in runtime if you want to.
Is the any way to change WebOptionpane
or JOptionPane
's Font and Font Size?
You can override those globally in Swing defaults:
public class Test
{
public static void main ( final String[] args )
{
WebLookAndFeel.install ();
UIManager.put ( "OptionPane.messageFont", new Font ( "Arial", Font.ITALIC, 10 ) );
UIManager.put ( "OptionPane.buttonFont", new Font ( "Arial", Font.BOLD, 20 ) );
JOptionPane.showMessageDialog ( null, "Info message here with a small font" );
}
}
Result:
Though these changes will be applied to all option panes.
Thank you. @mgarin :+1:
Custom decoration of specific frames and dialogs can now be enabled through the styling, but unfortunately JOptionPane
creates its own dialogs within private/static methods without any options to affect them in any way, so unfortunately main question of this issue is still not resolved.
I might be able to add specific states based on dialog types:
JRootPane.PLAIN_DIALOG
JRootPane.ERROR_DIALOG
JRootPane.QUESTION_DIALOG
JRootPane.WARNING_DIALOG
JRootPane.INFORMATION_DIALOG
But I will postpone that to v1.3.0 release.
When i set
It affects all my dilaogs.I only need that on Joptionpane dialogs.The Dialogs created by me has to be DecorateDialog setting to be false.
How to achieve this?