mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 00:38:16 +00:00
UI icon updates
This commit is contained in:
@@ -1,21 +1,28 @@
|
|||||||
package org.parabot.core.ui;
|
package org.parabot.core.ui;
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import java.awt.BorderLayout;
|
||||||
import org.parabot.core.ui.components.GamePanel;
|
import java.awt.Point;
|
||||||
import org.parabot.core.ui.images.Images;
|
|
||||||
import org.parabot.environment.scripts.Script;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
import java.awt.event.ComponentListener;
|
import java.awt.event.ComponentListener;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.event.WindowListener;
|
import java.awt.event.WindowListener;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JCheckBoxMenuItem;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.ui.components.GamePanel;
|
||||||
|
import org.parabot.core.ui.images.Images;
|
||||||
|
import org.parabot.core.ui.utils.SwingUtil;
|
||||||
|
import org.parabot.environment.scripts.Script;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -43,25 +50,23 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
setTitle("Parabot");
|
setTitle("Parabot");
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
setIconImage(Images.getResource("/org/parabot/core/ui/images/icon.png"));
|
createMenu();
|
||||||
|
|
||||||
/** Adds the dock icon to mac users */
|
|
||||||
try {
|
|
||||||
Class util = Class.forName("com.apple.eawt.Application");
|
|
||||||
Method getApplication = util.getMethod("getApplication", new Class[0]);
|
|
||||||
Object application = getApplication.invoke(util);
|
|
||||||
Class params[] = new Class[1];
|
|
||||||
params[0] = Image.class;
|
|
||||||
Method setDockIconImage = util.getMethod("setDockIconImage", params);
|
|
||||||
setDockIconImage.invoke(application, Images.getResource("/org/parabot/core/ui/images/icon.png"));
|
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
|
||||||
// Ignore for windows
|
|
||||||
}
|
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
addComponentListener(this);
|
addComponentListener(this);
|
||||||
addWindowListener(this);
|
addWindowListener(this);
|
||||||
|
|
||||||
|
add(GamePanel.getInstance());
|
||||||
|
GamePanel.getInstance().addLoader();
|
||||||
|
|
||||||
|
SwingUtil.setParabotIcons(this);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
BotDialog.getInstance(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createMenu() {
|
||||||
JMenuBar menuBar = new JMenuBar();
|
JMenuBar menuBar = new JMenuBar();
|
||||||
|
|
||||||
JMenu file = new JMenu("File");
|
JMenu file = new JMenu("File");
|
||||||
@@ -103,13 +108,6 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
menuBar.add(scripts);
|
menuBar.add(scripts);
|
||||||
|
|
||||||
setJMenuBar(menuBar);
|
setJMenuBar(menuBar);
|
||||||
|
|
||||||
add(GamePanel.getInstance());
|
|
||||||
GamePanel.getInstance().addLoader();
|
|
||||||
|
|
||||||
pack();
|
|
||||||
setLocationRelativeTo(null);
|
|
||||||
BotDialog.getInstance(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,21 +1,30 @@
|
|||||||
package org.parabot.core.ui;
|
package org.parabot.core.ui;
|
||||||
|
|
||||||
import org.parabot.core.Core;
|
import java.awt.BorderLayout;
|
||||||
import org.parabot.core.forum.AccountManager;
|
import java.awt.Desktop;
|
||||||
import org.parabot.core.forum.AccountManagerAccess;
|
import java.awt.Graphics;
|
||||||
import org.parabot.core.ui.images.Images;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPasswordField;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
import org.parabot.core.Core;
|
||||||
|
import org.parabot.core.forum.AccountManager;
|
||||||
|
import org.parabot.core.forum.AccountManagerAccess;
|
||||||
|
import org.parabot.core.ui.images.Images;
|
||||||
|
import org.parabot.core.ui.utils.SwingUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Users must login with their parabot account through this LoginUI class
|
* Users must login with their parabot account through this LoginUI class
|
||||||
@@ -80,21 +89,8 @@ public class LoginUI extends JFrame {
|
|||||||
this.setLocationByPlatform(true);
|
this.setLocationByPlatform(true);
|
||||||
this.setLayout(new BorderLayout());
|
this.setLayout(new BorderLayout());
|
||||||
this.setResizable(false);
|
this.setResizable(false);
|
||||||
this.setIconImage(Images
|
|
||||||
.getResource("/org/parabot/core/ui/images/icon.png"));
|
SwingUtil.setParabotIcons(this);
|
||||||
|
|
||||||
/** Adds the dock icon to mac users */
|
|
||||||
try {
|
|
||||||
Class util = Class.forName("com.apple.eawt.Application");
|
|
||||||
Method getApplication = util.getMethod("getApplication", new Class[0]);
|
|
||||||
Object application = getApplication.invoke(util);
|
|
||||||
Class params[] = new Class[1];
|
|
||||||
params[0] = Image.class;
|
|
||||||
Method setDockIconImage = util.getMethod("setDockIconImage", params);
|
|
||||||
setDockIconImage.invoke(application, Images.getResource("/org/parabot/core/ui/images/icon.png"));
|
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
|
||||||
// Ignore for windows
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = 250;
|
int w = 250;
|
||||||
int x = 8;
|
int x = 8;
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
package org.parabot.core.ui;
|
package org.parabot.core.ui;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Queue;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
import org.parabot.core.desc.ServerDescription;
|
import org.parabot.core.desc.ServerDescription;
|
||||||
import org.parabot.core.parsers.servers.ServerParser;
|
import org.parabot.core.parsers.servers.ServerParser;
|
||||||
import org.parabot.core.ui.components.ServerComponent;
|
import org.parabot.core.ui.components.ServerComponent;
|
||||||
import org.parabot.core.ui.images.Images;
|
|
||||||
import org.parabot.core.ui.utils.SwingUtil;
|
import org.parabot.core.ui.utils.SwingUtil;
|
||||||
import org.parabot.environment.Environment;
|
import org.parabot.environment.Environment;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Queue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Shows a list of every supported server which can be started
|
* Shows a list of every supported server which can be started
|
||||||
@@ -49,20 +50,8 @@ public class ServerSelector extends JFrame {
|
|||||||
this.setTitle("Servers");
|
this.setTitle("Servers");
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
this.setResizable(false);
|
this.setResizable(false);
|
||||||
this.setIconImage(Images.getResource("/org/parabot/core/ui/images/icon.png"));
|
|
||||||
|
SwingUtil.setParabotIcons(this);
|
||||||
/** Adds the dock icon to mac users */
|
|
||||||
try {
|
|
||||||
Class util = Class.forName("com.apple.eawt.Application");
|
|
||||||
Method getApplication = util.getMethod("getApplication", new Class[0]);
|
|
||||||
Object application = getApplication.invoke(util);
|
|
||||||
Class params[] = new Class[1];
|
|
||||||
params[0] = Image.class;
|
|
||||||
Method setDockIconImage = util.getMethod("setDockIconImage", params);
|
|
||||||
setDockIconImage.invoke(application, Images.getResource("/org/parabot/core/ui/images/icon.png"));
|
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
|
||||||
// Ignore for windows
|
|
||||||
}
|
|
||||||
|
|
||||||
this.panel = new JPanel(new BorderLayout());
|
this.panel = new JPanel(new BorderLayout());
|
||||||
this.panel.setPreferredSize(new Dimension(600, 400));
|
this.panel.setPreferredSize(new Dimension(600, 400));
|
||||||
@@ -103,7 +92,6 @@ public class ServerSelector extends JFrame {
|
|||||||
* @param widgets
|
* @param widgets
|
||||||
*/
|
*/
|
||||||
private boolean runServer(Queue<ServerComponent> widgets) {
|
private boolean runServer(Queue<ServerComponent> widgets) {
|
||||||
// TODO: test this method
|
|
||||||
if (widgets == null || widgets.isEmpty()) {
|
if (widgets == null || widgets.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
package org.parabot.core.ui.utils;
|
package org.parabot.core.ui.utils;
|
||||||
|
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
import org.parabot.core.ui.images.Images;
|
||||||
|
import org.parabot.environment.OperatingSystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Holds various swing util based methods
|
* Holds various swing util based methods
|
||||||
@@ -21,5 +28,22 @@ public class SwingUtil {
|
|||||||
f.setLocationRelativeTo(null);
|
f.setLocationRelativeTo(null);
|
||||||
f.setVisible(true);
|
f.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setParabotIcons(JFrame f) {
|
||||||
|
f.setIconImage(Images.getResource("/org/parabot/core/ui/images/icon.png"));
|
||||||
|
|
||||||
|
if(OperatingSystem.getOS() == OperatingSystem.MAC) {
|
||||||
|
/** Adds the dock icon to mac users */
|
||||||
|
try {
|
||||||
|
Class<?> util = Class.forName("com.apple.eawt.Application");
|
||||||
|
Object application = util.getMethod("getApplication", new Class[] { }).invoke(null);
|
||||||
|
Method setDockIconImage = util.getMethod("setDockIconImage", new Class[] { Image.class });
|
||||||
|
setDockIconImage.invoke(application, Images.getResource("/org/parabot/core/ui/images/icon.png"));
|
||||||
|
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) {
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user