Fix the frame is displayable exception

Fix java.awt.IllegalComponentStateException: The frame is displayable
that is caused by window being packed before showWithChrome method is
called.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-01-26 09:33:55 +01:00
parent e1f84a87ae
commit a8f364c005

View File

@@ -154,13 +154,16 @@ public class ClientUI extends JFrame
public void showWithChrome(boolean customChrome) public void showWithChrome(boolean customChrome)
{ {
setUndecorated(customChrome); setUndecorated(customChrome);
if (customChrome) if (customChrome)
{ {
getRootPane().setWindowDecorationStyle(JRootPane.FRAME); getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
} }
pack(); pack();
revalidateMinimumSize(); revalidateMinimumSize();
setLocationRelativeTo(getOwner()); setLocationRelativeTo(getOwner());
if (customChrome) if (customChrome)
{ {
try try
@@ -295,7 +298,10 @@ public class ClientUI extends JFrame
client.getParent().setPreferredSize(size); client.getParent().setPreferredSize(size);
client.getParent().setSize(size); client.getParent().setSize(size);
pack(); if (isVisible())
{
pack();
}
} }
private static void setUIFont(FontUIResource f) private static void setUIFont(FontUIResource f)