runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java
/**
	 * Show client UI after everything else is done.
	 *
	 * @throws Exception exception that can occur during modification of the UI
	 */
Show client UI after everything else is done.
@throws Exception exception that can occur during modification of the UI
Show client UI after everything else is done . @throws Exception exception that can occur during modification of the UI
public void show() throws Exception
	{
		final boolean withTitleBar = config.enableCustomChrome();
		SwingUtilities.invokeAndWait(() ->
		{
			frame.setUndecorated(withTitleBar);
			if (withTitleBar)
			{
				frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
				final JComponent titleBar = SubstanceCoreUtilities.getTitlePaneComponent(frame);
				titleToolbar.putClientProperty(SubstanceTitlePaneUtilities.EXTRA_COMPONENT_KIND, SubstanceTitlePaneUtilities.ExtraComponentKind.TRAILING);
				titleBar.add(titleToolbar);
				LayoutManager delegate = titleBar.getLayout();
				titleBar.setLayout(new LayoutManager()
				{
					@Override
					public void addLayoutComponent(String name, Component comp)
					{
						delegate.addLayoutComponent(name, comp);
					}
					@Override
					public void removeLayoutComponent(Component comp)
					{
						delegate.removeLayoutComponent(comp);
					}
					@Override
					public Dimension preferredLayoutSize(Container parent)
					{
						return delegate.preferredLayoutSize(parent);
					}
					@Override
					public Dimension minimumLayoutSize(Container parent)
					{
						return delegate.minimumLayoutSize(parent);
					}
					@Override
					public void layoutContainer(Container parent)
					{
						delegate.layoutContainer(parent);
						final int width = titleToolbar.getPreferredSize().width;
						titleToolbar.setBounds(titleBar.getWidth() - 75 - width, 0, width, titleBar.getHeight());
					}
				});
			}
			frame.pack();
			frame.revalidateMinimumSize();
			if (config.rememberScreenBounds())
			{
				try
				{
					Rectangle clientBounds = configManager.getConfiguration(
						CONFIG_GROUP, CONFIG_CLIENT_BOUNDS, Rectangle.class);
					if (clientBounds != null)
					{
						frame.setBounds(clientBounds);
					}
					else
					{
						frame.setLocationRelativeTo(frame.getOwner());
					}
					if (configManager.getConfiguration(CONFIG_GROUP, CONFIG_CLIENT_MAXIMIZED) != null)
					{
						frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
					}
				}
				catch (Exception ex)
				{
					log.warn("Failed to set window bounds", ex);
					frame.setLocationRelativeTo(frame.getOwner());
				}
			}
			else
			{
				frame.setLocationRelativeTo(frame.getOwner());
			}
			trayIcon = SwingUtil.createTrayIcon(ICON, properties.getTitle(), frame);
			frame.setVisible(true);
			frame.toFront();
			requestFocus();
			giveClientFocus();
			Rectangle clientBounds = frame.getBounds();
			Rectangle screenBounds = frame.getGraphicsConfiguration().getBounds();
			if (clientBounds.x + clientBounds.width - CLIENT_WELL_HIDDEN_MARGIN < screenBounds.getX() ||
				clientBounds.x + CLIENT_WELL_HIDDEN_MARGIN > screenBounds.getX() + screenBounds.getWidth() ||
				clientBounds.y + CLIENT_WELL_HIDDEN_MARGIN_TOP < screenBounds.getY() ||
				clientBounds.y + CLIENT_WELL_HIDDEN_MARGIN > screenBounds.getY() + screenBounds.getHeight())
			{
				frame.setLocationRelativeTo(frame.getOwner());
			}
			sidebarNavigationButton = NavigationButton
				.builder()
				.icon(SIDEBAR_CLOSE)
				.onClick(this::toggleSidebar)
				.build();
			sidebarNavigationJButton = SwingUtil.createSwingButton(
				sidebarNavigationButton,
				0,
				null);
			titleToolbar.addComponent(sidebarNavigationButton, sidebarNavigationJButton);
			toggleSidebar();
		});
		eventBus.post(new ClientUILoaded());
	}
public void show ( ) throws Exception { final boolean withTitleBar = config . enableCustomChrome ( ) ; SwingUtilities . invokeAndWait ( ( ) -> { frame . setUndecorated ( withTitleBar ) ; if ( withTitleBar ) { frame . getRootPane ( ) . setWindowDecorationStyle ( JRootPane . FRAME ) ; final JComponent titleBar = SubstanceCoreUtilities . getTitlePaneComponent ( frame ) ; titleToolbar . putClientProperty ( SubstanceTitlePaneUtilities . EXTRA_COMPONENT_KIND , SubstanceTitlePaneUtilities . ExtraComponentKind . TRAILING ) ; titleBar . add ( titleToolbar ) ; LayoutManager delegate = titleBar . getLayout ( ) ; titleBar . setLayout ( new LayoutManager ( ) { @ Override public void addLayoutComponent ( String name , Component comp ) { delegate . addLayoutComponent ( name , comp ) ; } @ Override public void removeLayoutComponent ( Component comp ) { delegate . removeLayoutComponent ( comp ) ; } @ Override public Dimension preferredLayoutSize ( Container parent ) { return delegate . preferredLayoutSize ( parent ) ; } @ Override public Dimension minimumLayoutSize ( Container parent ) { return delegate . minimumLayoutSize ( parent ) ; } @ Override public void layoutContainer ( Container parent ) { delegate . layoutContainer ( parent ) ; final int width = titleToolbar . getPreferredSize ( ) . width ; titleToolbar . setBounds ( titleBar . getWidth ( ) - 75 - width , 0 , width , titleBar . getHeight ( ) ) ; } } ) ; } frame . pack ( ) ; frame . revalidateMinimumSize ( ) ; if ( config . rememberScreenBounds ( ) ) { try { Rectangle clientBounds = configManager . getConfiguration ( CONFIG_GROUP , CONFIG_CLIENT_BOUNDS , Rectangle . class ) ; if ( clientBounds != null ) { frame . setBounds ( clientBounds ) ; } else { frame . setLocationRelativeTo ( frame . getOwner ( ) ) ; } if ( configManager . getConfiguration ( CONFIG_GROUP , CONFIG_CLIENT_MAXIMIZED ) != null ) { frame . setExtendedState ( JFrame . MAXIMIZED_BOTH ) ; } } catch ( Exception ex ) { log . warn ( "Failed to set window bounds" , ex ) ; frame . setLocationRelativeTo ( frame . getOwner ( ) ) ; } } else { frame . setLocationRelativeTo ( frame . getOwner ( ) ) ; } trayIcon = SwingUtil . createTrayIcon ( ICON , properties . getTitle ( ) , frame ) ; frame . setVisible ( true ) ; frame . toFront ( ) ; requestFocus ( ) ; giveClientFocus ( ) ; Rectangle clientBounds = frame . getBounds ( ) ; Rectangle screenBounds = frame . getGraphicsConfiguration ( ) . getBounds ( ) ; if ( clientBounds . x + clientBounds . width - CLIENT_WELL_HIDDEN_MARGIN < screenBounds . getX ( ) || clientBounds . x + CLIENT_WELL_HIDDEN_MARGIN > screenBounds . getX ( ) + screenBounds . getWidth ( ) || clientBounds . y + CLIENT_WELL_HIDDEN_MARGIN_TOP < screenBounds . getY ( ) || clientBounds . y + CLIENT_WELL_HIDDEN_MARGIN > screenBounds . getY ( ) + screenBounds . getHeight ( ) ) { frame . setLocationRelativeTo ( frame . getOwner ( ) ) ; } sidebarNavigationButton = NavigationButton . builder ( ) . icon ( SIDEBAR_CLOSE ) . onClick ( this :: toggleSidebar ) . build ( ) ; sidebarNavigationJButton = SwingUtil . createSwingButton ( sidebarNavigationButton , 0 , null ) ; titleToolbar . addComponent ( sidebarNavigationButton , sidebarNavigationJButton ) ; toggleSidebar ( ) ; } ) ; eventBus . post ( new ClientUILoaded ( ) ) ; }
Show client UI after everything else is done.
Show client UI after everything else is done .
// Substance's default layout manager for the title bar only lays out substance's components // This wraps the default manager and lays out the TitleToolbar as well. // Show frame // If the frame is well hidden (e.g. unplugged 2nd screen), // we want to move it back to default position as it can be // hard for the user to reposition it themselves otherwise. // Create hide sidebar button