Merge pull request #4479 from deathbeam/remove-revalidate-move-frame
Pack and show frame only after properties update
This commit is contained in:
@@ -313,9 +313,6 @@ public class ClientUI
|
|||||||
frame.addKeyListener(uiKeyListener);
|
frame.addKeyListener(uiKeyListener);
|
||||||
keyManager.registerKeyListener(uiKeyListener);
|
keyManager.registerKeyListener(uiKeyListener);
|
||||||
|
|
||||||
// Update config
|
|
||||||
updateFrameConfig(true);
|
|
||||||
|
|
||||||
// Decorate window with custom chrome and titlebar if needed
|
// Decorate window with custom chrome and titlebar if needed
|
||||||
final boolean withTitleBar = config.enableCustomChrome();
|
final boolean withTitleBar = config.enableCustomChrome();
|
||||||
frame.setUndecorated(withTitleBar);
|
frame.setUndecorated(withTitleBar);
|
||||||
@@ -367,10 +364,33 @@ public class ClientUI
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show frame
|
// Update config
|
||||||
|
updateFrameConfig(true);
|
||||||
|
|
||||||
|
// Create hide sidebar button
|
||||||
|
sidebarNavigationButton = NavigationButton
|
||||||
|
.builder()
|
||||||
|
.priority(100)
|
||||||
|
.icon(SIDEBAR_CLOSE)
|
||||||
|
.onClick(this::toggleSidebar)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
sidebarNavigationJButton = SwingUtil.createSwingButton(
|
||||||
|
sidebarNavigationButton,
|
||||||
|
0,
|
||||||
|
null);
|
||||||
|
|
||||||
|
titleToolbar.addComponent(sidebarNavigationButton, sidebarNavigationJButton);
|
||||||
|
toggleSidebar();
|
||||||
|
|
||||||
|
// Layout frame
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.revalidateMinimumSize();
|
frame.revalidateMinimumSize();
|
||||||
|
|
||||||
|
// Create tray icon (needs to be created after frame is packed)
|
||||||
|
trayIcon = SwingUtil.createTrayIcon(ICON, properties.getTitle(), frame);
|
||||||
|
|
||||||
|
// Move frame around (needs to be done after frame is packed)
|
||||||
if (config.rememberScreenBounds())
|
if (config.rememberScreenBounds())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -380,6 +400,7 @@ public class ClientUI
|
|||||||
if (clientBounds != null)
|
if (clientBounds != null)
|
||||||
{
|
{
|
||||||
frame.setBounds(clientBounds);
|
frame.setBounds(clientBounds);
|
||||||
|
frame.revalidateMinimumSize();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -402,13 +423,6 @@ public class ClientUI
|
|||||||
frame.setLocationRelativeTo(frame.getOwner());
|
frame.setLocationRelativeTo(frame.getOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
trayIcon = SwingUtil.createTrayIcon(ICON, properties.getTitle(), frame);
|
|
||||||
|
|
||||||
frame.setVisible(true);
|
|
||||||
frame.toFront();
|
|
||||||
requestFocus();
|
|
||||||
giveClientFocus();
|
|
||||||
|
|
||||||
// If the frame is well hidden (e.g. unplugged 2nd screen),
|
// If the frame is well hidden (e.g. unplugged 2nd screen),
|
||||||
// we want to move it back to default position as it can be
|
// we want to move it back to default position as it can be
|
||||||
// hard for the user to reposition it themselves otherwise.
|
// hard for the user to reposition it themselves otherwise.
|
||||||
@@ -422,21 +436,11 @@ public class ClientUI
|
|||||||
frame.setLocationRelativeTo(frame.getOwner());
|
frame.setLocationRelativeTo(frame.getOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create hide sidebar button
|
// Show frame
|
||||||
sidebarNavigationButton = NavigationButton
|
frame.setVisible(true);
|
||||||
.builder()
|
frame.toFront();
|
||||||
.priority(100)
|
requestFocus();
|
||||||
.icon(SIDEBAR_CLOSE)
|
giveClientFocus();
|
||||||
.onClick(this::toggleSidebar)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
sidebarNavigationJButton = SwingUtil.createSwingButton(
|
|
||||||
sidebarNavigationButton,
|
|
||||||
0,
|
|
||||||
null);
|
|
||||||
|
|
||||||
titleToolbar.addComponent(sidebarNavigationButton, sidebarNavigationJButton);
|
|
||||||
toggleSidebar();
|
|
||||||
log.info("Showing frame {}", frame);
|
log.info("Showing frame {}", frame);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user