Brandon
2012-12-10 00:54:33
I'm willing to write a tutorial on how to theme Smart if anyone is interested. Theming is obviously done in Java so you'll need a background in that.
The Source:
[ATTACH]18048[/ATTACH]
The DLLs for the lazy:
[ATTACH]18049[/ATTACH]
An example theme I came up with today looks like:

I used the nimbus look and feel and just moved around the components.. I didn't finish it as you can see with the buttons because I don't know what images to put lol..
So anyone interested in making me 4 buttons? Graphics button, Enable Button, Debug Button, Console Button.
Yeah.. I added a console button. When you click it, it'll display a console at the bottom like in RSBot/Tribot. When clicked again, it hides it :l.
If anyone is interested in a tutorial, just leave a post below.
For the curious, the code looks like(Works with both Java 6 and 7):
XGUI.java:
XFrame.java:
XComponents.Java:
The Source:
[ATTACH]18048[/ATTACH]
The DLLs for the lazy:
[ATTACH]18049[/ATTACH]
An example theme I came up with today looks like:

I used the nimbus look and feel and just moved around the components.. I didn't finish it as you can see with the buttons because I don't know what images to put lol..
So anyone interested in making me 4 buttons? Graphics button, Enable Button, Debug Button, Console Button.
Yeah.. I added a console button. When you click it, it'll display a console at the bottom like in RSBot/Tribot. When clicked again, it hides it :l.
If anyone is interested in a tutorial, just leave a post below.
For the curious, the code looks like(Works with both Java 6 and 7):
XGUI.java:
package smart;
public class XGUI extends javax.swing.JPanel {
private javax.swing.JFrame Parent = null;
private java.awt.Image Background = null;
private java.awt.Point Offset = new java.awt.Point();
public XGUI(javax.swing.JFrame Parent) {
this.Parent = Parent;
SetCustomTheme();
LoadBackground();
Layout();
AddListeners();
this.setSize(Parent.getSize());
this.setVisible(true);
}
private void Layout() {
javax.swing.GroupLayout LayoutInfo = new javax.swing.GroupLayout(this);
this.setLayout(LayoutInfo);
javax.swing.JLabel Exit = new javax.swing.JLabel("<html><b>X</b>");
Exit.setForeground(java.awt.Color.red);
LayoutInfo.setHorizontalGroup(
LayoutInfo.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, LayoutInfo.createSequentialGroup()
.addGap(0, 390, Short.MAX_VALUE)
.addComponent(Exit, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
);
LayoutInfo.setVerticalGroup(
LayoutInfo.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(LayoutInfo.createSequentialGroup()
.addComponent(Exit)
.addGap(0, 397, Short.MAX_VALUE))
);
}
private void SetCustomTheme() {
try {
javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception Ex) {
Ex.toString();
}
}
private void LoadBackground() {
try {
Background = javax.imageio.ImageIO.read(getClass().getResource("src/Theme/ThemeImages/Background.png"));
} catch (Exception Ex) {
Ex.toString();
}
}
@Override public java.awt.Dimension getPreferredSize() {
return new java.awt.Dimension(300, 300);
}
@Override public void paintComponent(java.awt.Graphics g) {
super.paintComponent(g);
g.drawImage(Background, 0,0,this.getWidth(),this.getHeight(), null);
}
private void AddListeners() {
this.addMouseListener(new java.awt.event.MouseAdapter() {
@Override public void mousePressed(java.awt.event.MouseEvent e) {
Offset.x = e.getX();
Offset.y = e.getY();
}
});
this.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
@Override public void mouseDragged(java.awt.event.MouseEvent e) {
java.awt.Point p = Parent.getLocation();
Parent.setLocation(p.x + e.getX() - Offset.x, p.y + e.getY() - Offset.y);
}
});
this.addMouseListener(new java.awt.event.MouseAdapter() {
@Override public void mouseClicked(java.awt.event.MouseEvent e) {
java.awt.Rectangle Area = new java.awt.Rectangle(getSize().width - 20, 0, 20, 20);
if (Area.contains(e.getPoint())) {
Parent.dispatchEvent(new java.awt.event.WindowEvent(Parent, java.awt.event.WindowEvent.WINDOW_CLOSING));
}
}
});
}
}
XFrame.java:
package smart;
import javax.swing.JFrame;
public class XFrame extends JFrame {
private XComponents Components;
private static java.awt.Point Offset = new java.awt.Point();
public XFrame(String Title, int CanvasWidth, int CanvasHeight, java.util.EventListener Listener) {
this.setTitle(Title);
this.setUndecorated(true);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.AddListeners();
XGUI CustomGUI = new XGUI(this);
Components = new XComponents(Title, CustomGUI, CanvasWidth, CanvasHeight);
CustomGUI.add(Components);
Components.AddListeners(Listener);
this.getContentPane().add(CustomGUI);
this.pack();
this.setSize(CanvasWidth + 26, CanvasHeight + 76);
this.setLocationRelativeTo(null);
//this.setVisible(true);
}
public int GetFPSValue() {
return Components.GetFPSValue();
}
public void SetFPSValue(int Value) {
Components.SetFPSValue(Value);
}
public boolean IsFPSAdjusting() {
return Components.IsFPSAdjusting();
}
public Object GetDisplayMode() {
return Components.GetDisplayMode();
}
public void SetButtonTexts(String EnableText, String GraphicsText, String DebugText) {
Components.SetButtonTexts(EnableText, GraphicsText, DebugText);
}
public void SetDebugInfo(boolean Enabled, String Text) {
Components.SetDebugInfo(Enabled, Text);
}
public void SetEnableInfo(boolean Enabled, String Text) {
Components.SetEnableInfo(Enabled, Text);
}
public void SetGraphicsInfo(boolean Enabled, String Text) {
Components.SetGraphicsInfo(Enabled, Text);
}
public void AddAppletComponent(java.applet.Applet Applet) {
Components.AddAppletComponent(Applet);
}
private void AddListeners() {
final JFrame Self = this;
this.addMouseListener(new java.awt.event.MouseAdapter() {
@Override public void mousePressed(java.awt.event.MouseEvent e) {
Offset.x = e.getX();
Offset.y = e.getY();
}
@Override public void mouseClicked(java.awt.event.MouseEvent e) {
int Width = getWidth();
java.awt.Rectangle Area = new java.awt.Rectangle(Width - 10, 0, 20, 20);
if (Area.contains(e.getPoint())) {
Self.dispatchEvent(new java.awt.event.WindowEvent(Self, java.awt.event.WindowEvent.WINDOW_CLOSING));
}
}
});
this.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
@Override public void mouseDragged(java.awt.event.MouseEvent e) {
java.awt.Point p = getLocation();
setLocation(p.x + e.getX() - Offset.x, p.y + e.getY() - Offset.y);
}
});
}
}
XComponents.Java:
package smart;
import javax.swing.JLabel;
public class XComponents extends java.awt.Container {
private String LabelTitle;
private int ExitOffset;
private int AppletWidth, AppletHeight;
private javax.swing.JButton Debug;
private javax.swing.JComboBox DisplayMode;
private javax.swing.JButton Enable;
private javax.swing.JButton Graphics;
private javax.swing.JLabel Title;
private javax.swing.JPanel AppletPanel;
private javax.swing.JSlider FPSSlider;
private javax.swing.JLabel Exit;
private javax.swing.JButton Console;
public XComponents(String LabelTitle, java.awt.Container Panel, int AppletWidth, int AppletHeight) {
this.LabelTitle = LabelTitle;
this.AppletWidth = AppletWidth;
this.AppletHeight = AppletHeight;
SetupComponents();
SetLayout(Panel);
}
public int GetFPSValue() {
return FPSSlider.getValue();
}
public void SetFPSValue(int Value) {
FPSSlider.setValue(Value);
}
public boolean IsFPSAdjusting() {
return FPSSlider.getValueIsAdjusting();
}
public Object GetDisplayMode() {
return DisplayMode.getSelectedItem();
}
public void SetButtonTexts(String EnableText, String GraphicsText, String DebugText) {
if (Enable != null) {
Enable.setText(EnableText);
}
if (GraphicsText != null) {
Graphics.setText(GraphicsText);
}
if (DebugText != null) {
Debug.setText(DebugText);
}
}
public void SetDebugInfo(boolean Enabled, String Text) {
if (Text != null) {
Debug.setText(Text);
}
Debug.setEnabled(Enabled);
}
public void SetEnableInfo(boolean Enabled, String Text) {
if (Text != null) {
Enable.setText(Text);
}
Enable.setEnabled(Enabled);
}
public void SetGraphicsInfo(boolean Enabled, String Text) {
if (Text != null) {
Graphics.setText(Text);
}
Graphics.setEnabled(Enabled);
}
public void AddAppletComponent(java.applet.Applet Applet) {
AppletPanel.add(Applet);
}
public void AddListeners(java.util.EventListener e) {
Enable.addActionListener((java.awt.event.ActionListener) e);
Graphics.addActionListener((java.awt.event.ActionListener) e);
Debug.addActionListener((java.awt.event.ActionListener) e);
Console.addActionListener((java.awt.event.ActionListener) e);
DisplayMode.addActionListener((java.awt.event.ActionListener) e);
FPSSlider.addChangeListener((javax.swing.event.ChangeListener) e);
}
private void SetupComponents() {
AppletPanel = new javax.swing.JPanel();
Title = new javax.swing.JLabel();
Enable = new javax.swing.JButton();
Graphics = new javax.swing.JButton();
Debug = new javax.swing.JButton();
FPSSlider = new javax.swing.JSlider(javax.swing.JSlider.VERTICAL, 1, 100, 96);
DisplayMode = new javax.swing.JComboBox();
Console = new javax.swing.JButton();
Enable.setActionCommand("BlockingButton");
Graphics.setActionCommand("GraphicsButton");
Debug.setActionCommand("DebugButton");
DisplayMode.setActionCommand("DisplayMode");
Title.setText(LabelTitle);
Enable.setText("Enable SMART");
Graphics.setText("Disable Graphics");
Debug.setText("Enable Debug");
Console.setText("Display Console");
Exit = new JLabel("<html><b>X</b>");
java.awt.Font LabelFont = new java.awt.Font("Arial", java.awt.Font.BOLD, 11);
Exit.setForeground(java.awt.Color.red);
Title.setForeground(java.awt.Color.blue);
Exit.setFont(LabelFont);
Title.setFont(LabelFont);
FPSSlider.setPreferredSize(new java.awt.Dimension(19, 19));
ExitOffset = AppletWidth - Title.getText().length() - 505;
AppletPanel.setPreferredSize(new java.awt.Dimension(AppletWidth, AppletHeight));
DisplayMode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SafeMode", "Software", "DirectX", "OpenGL" }));
}
private void SetLayout(java.awt.Container Panel) {
AppletPanel.setLayout(new java.awt.BorderLayout());
/*javax.swing.GroupLayout Layout = new javax.swing.GroupLayout(AppletPanel);
AppletPanel.setLayout(Layout);
Layout.setHorizontalGroup(
Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 765, Short.MAX_VALUE)
);
Layout.setVerticalGroup(
Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 553, Short.MAX_VALUE)
);*/
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(Panel);
Panel.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(148, 148, 148)
.addComponent(Title)
.addGap(ExitOffset, ExitOffset, ExitOffset)
.addComponent(Exit))
.addGroup(layout.createSequentialGroup()
.addComponent(Enable, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Graphics, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Debug, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Console, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(DisplayMode, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addComponent(AppletPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
//.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
.addComponent(FPSSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {Debug, Enable, Graphics});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Title)
.addComponent(Exit))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Enable)
.addComponent(Graphics)
.addComponent(Debug)
.addComponent(Console)
.addComponent(DisplayMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(FPSSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(AppletPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {Debug, Enable, Graphics});
}
}