/*
 * Copyright (c) 2016, Adam <Adam@sigterm.info>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    This product includes software developed by Adam <Adam@sigterm.info>
 * 4. Neither the name of the Adam <Adam@sigterm.info> nor the
 *    names of its contributors may be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Adam <Adam@sigterm.info> ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Adam <Adam@sigterm.info> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package net.runelite.client.ui;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import javax.swing.JPanel;
import net.runelite.api.Client;
import net.runelite.client.ClientLoader;
import net.runelite.client.RuneLite;

final class ClientPanel extends JPanel implements ComponentListener
{
	public static final int PANEL_WIDTH = 765, PANEL_HEIGHT = 503;
	
	private Applet rs;

	public ClientPanel() throws Exception
	{
		setSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
		setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
		setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
		setBackground(Color.black);
		this.addComponentListener(this);

		ClientLoader loader = new ClientLoader();

		rs = loader.load();
		rs.setSize(this.getSize());
		rs.init();
		rs.start();
		this.add(rs);

		RuneLite.setClient(new Client((net.runelite.rs.api.Client) rs));
	}

	@Override
	public void componentResized(ComponentEvent e)
	{
		rs.setSize(this.getSize());
		this.setPreferredSize(this.getSize());
		rs.setPreferredSize(this.getPreferredSize());
	}

	@Override
	public void componentMoved(ComponentEvent e)
	{
	}

	@Override
	public void componentShown(ComponentEvent e)
	{
	}

	@Override
	public void componentHidden(ComponentEvent e)
	{
	}
}
@@ -2088,16 +2088,73 @@
 uneLite;
+%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;
 %0A%0Afinal 
@@ -2217,16 +2217,100 @@
 tener%0A%7B%0A
+%09private static final Logger logger = LoggerFactory.getLogger(ClientPanel.class);%0A%09%0A
 %09public 
@@ -2818,27 +2818,52 @@
 %0A%0A%09%09
-RuneLite.setC
+Client client = null;%0A%09%09try%0A%09%09%7B%0A%09%09%09c
 lient
-(
+ = 
 new 
@@ -2901,16 +2901,148 @@
 ent) rs)
+;%0A%09%09%7D%0A%09%09catch (Exception ex)%0A%09%09%7B%0A%09%09%09logger.warn(%22Unable to create client%22, ex);%0A%09%09%09System.exit(-1);%0A%09%09%7D%0A%0A%09%09RuneLite.setClient(client
 );%0A%09%7D%0A%0A%09

Exit if client creation fails