Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Insets;
- import java.awt.Rectangle;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.FileWriter;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.JPasswordField;
- import javax.swing.JTabbedPane;
- import javax.swing.JTextField;
- import javax.swing.WindowConstants;
- import com.rsbuddy.script.ActiveScript;
- import com.rsbuddy.script.Manifest;
- import com.rsbuddy.script.methods.Game;
- import com.rsbuddy.script.methods.Players;
- import com.rsbuddy.script.methods.Skills;
- import com.rsbuddy.script.util.Random;
- @Manifest(authors = {"Jake"},
- keywords = {""},
- name = "testgui",
- version = 1.0,
- description = "")
- public class testgui extends ActiveScript {
- private JTabbedPane tabbedPane1;
- public JTextField textField1, textField2, textField3, usernamefield, potionamount;
- private JComboBox foodbox, logoutbox, loginbox;
- private JPasswordField passwordfield;
- private JButton button1;
- private JButton button2;
- private JButton button3;
- private JButton hpresetbutton;
- private JCheckBox
- botwarningcheck, guionstartcheck, equipmentcheck, cluescrollcheck, dragonbonescheck, dragonhidecheck,
- bluecharmcheck, greencharmcheck, goldcharmcheck, crimsoncharmcheck, runedaggercheck, runwhentbedcheck;
- int dragonbonesprice, dragonhideprice;
- private File filepath;
- private String displayname;
- long totalhours, totalminutes;
- private String totalmoneystring = "0";
- String[] opts = new String[27];
- private int totalmoneygained = 0;
- DragonGUI gui;
- public boolean onStart() {
- if (!Game.isLoggedIn()){
- log("Waiting for you to log in...");
- }
- while (!Game.isLoggedIn() || displayname == null){
- displayname = Players.getLocal().getName();
- sleep(500);
- }
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- gui = new DragonGUI();
- gui.setVisible(true);
- }
- });
- while (gui.isVisible()) {
- sleep(1000);
- }
- return true;
- }
- public int loop() {
- return 300;
- }
- @SuppressWarnings("serial")
- public class DragonGUI extends JFrame {
- public DragonGUI() {
- initComponents();
- }
- private void button1ActionPerformed(ActionEvent e) {
- if (usernamefield.getText().isEmpty()
- || passwordfield.getPassword().toString().isEmpty()) {
- JOptionPane.showMessageDialog(this,"Username or password textbox is blank.",
- "Warning",
- JOptionPane.ERROR_MESSAGE);
- return;
- }
- setVisible(false);
- }
- private void button2ActionPerformed(ActionEvent e) {
- //Thread thread = new BasicThread1();
- //thread.start();
- }
- private void button3ActionPerformed(ActionEvent e) {
- totalhours = 0;
- totalminutes = 0;
- totalmoneystring = "0";
- label11.setText("Total Money Gained: " + totalmoneygained);
- label9.setText("Total Login Time: " + totalhours + ":" + totalminutes);
- log("Total time and money cleared.");
- }
- private void hpresetbuttonActionPerformed(ActionEvent e) {
- final int totalhp = Skills.getRealLevel(Skills.CONSTITUTION) * 10;
- if (totalhp >= 500) {
- textField2.setText("350");
- textField3.setText("400");
- }
- if (totalhp >= 700) {
- textField2.setText("400");
- textField3.setText("550");
- }
- if (totalhp >= 800) {
- textField2.setText("550");
- textField3.setText("650");
- }
- }
- private void initComponents() {
- runedaggercheck = new JCheckBox();
- botwarningcheck = new JCheckBox();
- runwhentbedcheck = new JCheckBox();
- guionstartcheck = new JCheckBox();
- equipmentcheck = new JCheckBox();
- dragonbonescheck = new JCheckBox();
- dragonhidecheck = new JCheckBox();
- cluescrollcheck = new JCheckBox();
- bluecharmcheck = new JCheckBox();
- goldcharmcheck = new JCheckBox();
- greencharmcheck = new JCheckBox();
- crimsoncharmcheck = new JCheckBox();
- foodbox = new JComboBox();
- logoutbox = new JComboBox();
- loginbox = new JComboBox();
- tabbedPane1 = new JTabbedPane();
- panel1 = new JPanel();
- label1 = new JLabel();
- label2 = new JLabel();
- label3 = new JLabel();
- textField1 = new JTextField();
- potionamount = new JTextField();
- textField2 = new JTextField();
- label4 = new JLabel();
- textField3 = new JTextField();
- usernamefield = new JTextField();
- passwordfield = new JPasswordField();
- panel2 = new JPanel();
- label5 = new JLabel();
- label6 = new JLabel();
- panel3 = new JPanel();
- panel4 = new JPanel();
- label7 = new JLabel();
- label8 = new JLabel();
- label9 = new JLabel();
- label10 = new JLabel();
- label11 = new JLabel();
- energylabel = new JLabel();
- button1 = new JButton();
- button2 = new JButton();
- button3 = new JButton();
- hpresetbutton = new JButton();
- if (filepath.exists()){
- //readsettings();
- }
- //======== this ========
- setTitle(displayname + " - Jake's Green Dragon Killer");
- setAlwaysOnTop(true);
- setResizable(false);
- setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
- Container contentPane = getContentPane();
- contentPane.setLayout(null);
- //======== tabbedPane1 ========
- {
- //======== panel1 ========
- {
- panel1.setLayout(null);
- //foodbox
- foodbox.setModel(new DefaultComboBoxModel(new String[] {
- "Tuna", "Lobster", "Swordfish", "Monkfish" }));
- panel1.add(foodbox);
- foodbox.setBounds(10, 30, 130, foodbox.getPreferredSize().height);
- foodbox.setSelectedItem("Lobster");
- if (filepath.exists()) {
- foodbox.setSelectedItem(opts[11]);
- }
- //---- label1 ----
- label1.setText("Select food type:");
- panel1.add(label1);
- label1.setBounds(10, 10, 85, label1.getPreferredSize().height);
- //---- label2 ----
- label2.setText("Ammount of food to withdraw:");
- panel1.add(label2);
- label2.setBounds(10, 85, label2.getPreferredSize().width, label2.getPreferredSize().height);
- //---- textField1 ----
- textField1.setText("28");
- panel1.add(textField1);
- textField1.setBounds(160, 81, 20, textField1.getPreferredSize().height);
- if (filepath.exists()){
- textField1.setText(opts[16]);
- }
- //---- energylabel ----
- energylabel.setText("Ammount of energy potions to withdraw:");
- panel1.add(energylabel);
- energylabel.setBounds(10, 115, energylabel.getPreferredSize().width, energylabel.getPreferredSize().height);
- //---- potionamount ----
- potionamount.setText("0");
- panel1.add(potionamount);
- potionamount.setBounds(210, 111, 20, potionamount.getPreferredSize().height);
- if (filepath.exists()){
- potionamount.setText(opts[25]);
- }
- //---- label3 ----
- label3.setText("Eat when HP is");
- panel1.add(label3);
- label3.setBounds(10, 160, 75, label3.getPreferredSize().height);
- //---- textField2 ----
- textField2.setText("350");
- panel1.add(textField2);
- textField2.setBounds(89, 156, 30, textField2.getPreferredSize().height);
- //---- label4 ----
- label4.setText("-");
- panel1.add(label4);
- label4.setBounds(124, 159, 15, label4.getPreferredSize().height);
- //---- textField3 ----
- textField3.setText("450");
- panel1.add(textField3);
- textField3.setBounds(135, 156, 30, 20);
- //---- hpresetbutton ----
- hpresetbutton.setText("Reset");
- hpresetbutton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- hpresetbuttonActionPerformed(e);
- }
- });
- panel1.add(hpresetbutton);
- hpresetbutton.setBounds(175, 154, hpresetbutton.getPreferredSize().width,
- hpresetbutton.getPreferredSize().height);
- //equipmentcheck
- equipmentcheck.setText("Check Equipment");
- panel1.add(equipmentcheck);
- equipmentcheck.setBounds(5, 195, 125, equipmentcheck.getPreferredSize().height);
- if (!filepath.exists()) {
- equipmentcheck.setSelected(true);
- }
- //guionstartcheck
- guionstartcheck.setText("Show GUI on startup");
- panel1.add(guionstartcheck);
- guionstartcheck.setBounds(5, 215, guionstartcheck.getPreferredSize().width,
- guionstartcheck.getPreferredSize().height);
- if (!filepath.exists()) {
- guionstartcheck.setSelected(true);
- }
- //botwarningcheck
- botwarningcheck.setText("Notify me when called a bot");
- panel1.add(botwarningcheck);
- botwarningcheck.setBounds(5, 235, botwarningcheck.getPreferredSize().width,
- botwarningcheck.getPreferredSize().height);
- if (!filepath.exists()) {
- botwarningcheck.setSelected(true);
- }
- //runwhentbedcheck
- runwhentbedcheck.setText("Run when tbed.");
- panel1.add(runwhentbedcheck);
- runwhentbedcheck.setBounds(5, 255, runwhentbedcheck.getPreferredSize().width,
- runwhentbedcheck.getPreferredSize().height);
- final int totalhp = Skills.getRealLevel(Skills.CONSTITUTION) * 10;
- if (totalhp >= 500) {
- textField2.setText("350");
- textField3.setText("400");
- }
- if (totalhp >= 700) {
- textField2.setText("400");
- textField3.setText("550");
- }
- if (totalhp >= 800) {
- textField2.setText("500");
- textField3.setText("650");
- }
- if (filepath.exists()){
- textField2.setText(opts[14]);
- textField3.setText(opts[15]);
- }
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < panel1.getComponentCount(); i++) {
- Rectangle bounds = panel1.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- //preferredSize.width = 165;
- //preferredSize.height = 176;
- preferredSize.width = 198;
- preferredSize.height = 211;
- }
- Insets insets = panel1.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- panel1.setMinimumSize(preferredSize);
- panel1.setPreferredSize(preferredSize);
- }
- }
- //======== panel2 ========
- {
- panel2.setLayout(null);
- //---- label5 ----
- label5.setText("Checked Items will be picked up and kept, unchecked items will be left or dropped.");
- panel2.add(label5);
- label5.setBounds(10, 10, 245, 40);
- //---- dragonbones ----
- dragonbonescheck.setText("Dragon bones " + "(" + dragonbonesprice + ")");
- panel2.add(dragonbonescheck);
- dragonbonescheck.setBounds(10, 50, 128, dragonbonescheck.getPreferredSize().height);
- if (!filepath.exists()) {
- dragonbonescheck.setSelected(true);
- }
- //---- dragonhide ----
- dragonhidecheck.setText("Dragonhide " + "(" + dragonhideprice + ")");
- panel2.add(dragonhidecheck);
- dragonhidecheck.setBounds(10, 70, 130, 23);
- if (!filepath.exists()) {
- dragonhidecheck.setSelected(true);
- }
- //---- cluescroll ----
- cluescrollcheck.setText("Clue Scroll");
- panel2.add(cluescrollcheck);
- cluescrollcheck.setBounds(10, 90, 130, 23);
- if (!filepath.exists()) {
- cluescrollcheck.setSelected(true);
- }
- //---- bluecharm ----
- bluecharmcheck.setText("Blue Charm");
- panel2.add(bluecharmcheck);
- bluecharmcheck.setBounds(10, 110, 130, 23);
- //---- greencharm ----
- greencharmcheck.setText("Green Charm");
- panel2.add(greencharmcheck);
- greencharmcheck.setBounds(10, 130, 130, 23);
- //---- goldcharm ----
- goldcharmcheck.setText("Gold Charm");
- panel2.add(goldcharmcheck);
- goldcharmcheck.setBounds(10, 150, 130, 23);
- //---- crimsoncharm ----
- crimsoncharmcheck.setText("Crimson Charm");
- panel2.add(crimsoncharmcheck);
- crimsoncharmcheck.setBounds(10, 170, 130, 23);
- //---- runedagger ----
- runedaggercheck.setText("Rune dagger");
- panel2.add(runedaggercheck);
- runedaggercheck.setBounds(10, 190, 130, 23);
- if (!filepath.exists()) {
- runedaggercheck.setSelected(true);
- }
- {
- // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < panel2.getComponentCount(); i++) {
- Rectangle bounds = panel2.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = panel2.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- panel2.setMinimumSize(preferredSize);
- panel2.setPreferredSize(preferredSize);
- }
- }
- //======== panel3 ========
- {
- panel3.setLayout(null);
- //---- label7 ----
- label7.setText("Logout After:");
- panel3.add(label7);
- label7.setBounds(10, 10, 100, label7.getPreferredSize().height);
- //logoutbox
- logoutbox.setModel(new DefaultComboBoxModel(new String[] {
- "Never", "1 Hour", "2 Hours", "3 Hours", "4 Hours"}));
- panel3.add(logoutbox);
- logoutbox.setBounds(10, 25, 130, logoutbox.getPreferredSize().height);
- if (filepath.exists()) {
- logoutbox.setSelectedItem(opts[12]);
- }
- //---- label8 ----
- label8.setText("Log back in After:");
- panel3.add(label8);
- label8.setBounds(10, 50, 100, label8.getPreferredSize().height);
- //loginbox
- loginbox.setModel(new DefaultComboBoxModel(new String[] {
- "Never", }));//"1 Hour", "2 Hours", "3 Hours", "4 Hours"}));
- panel3.add(loginbox);
- loginbox.setBounds(10, 65, 130, loginbox.getPreferredSize().height);
- if (filepath.exists()) {
- loginbox.setSelectedItem(opts[13]);
- }
- //---- label10 ----
- label10.setText("<html>Username: " +
- "<br>" +
- "<br>" +
- "<br>Password:" +
- "</html>");
- panel3.add(label10);
- label10.setBounds(10, 115, label10.getPreferredSize().width,
- label10.getPreferredSize().height);
- //---- usernamefield ----
- usernamefield.setText("");
- panel3.add(usernamefield);
- usernamefield.setBounds(10, 134, 100, usernamefield.getPreferredSize().height);
- if (filepath.exists()){
- usernamefield.setText(opts[0]);
- }
- //password
- passwordfield.setText("");
- panel3.add(passwordfield);
- passwordfield.setBounds(10, 173, 100, passwordfield.getPreferredSize().height);
- if (filepath.exists()){
- passwordfield.setText(opts[1]);
- }
- //---- label10 ----
- label11.setText("Total Money Gained: " + totalmoneystring);
- panel3.add(label11);
- label11.setBounds(10, 229, label11.getPreferredSize().width,
- label11.getPreferredSize().height);
- //---- label9 ----
- label9.setText("Total Login Time: " + totalhours + ":" + totalminutes);
- panel3.add(label9);
- label9.setBounds(10, 249, label9.getPreferredSize().width,
- label9.getPreferredSize().height);
- //---- button3 ----
- button3.setText("Reset");
- button3.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- button3ActionPerformed(e);
- }
- });
- panel3.add(button3);
- button3.setBounds(130, 244, button3.getPreferredSize().width,
- button3.getPreferredSize().height);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < panel3.getComponentCount(); i++) {
- Rectangle bounds = panel3.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height,
- preferredSize.height);
- }
- Insets insets = panel3.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- panel3.setMinimumSize(preferredSize);
- panel3.setPreferredSize(preferredSize);
- }
- }
- //======== panel4 ========
- {
- panel4.setLayout(null);
- //---- label6 ----
- label6.setText("<html>Script suggestions: " +
- "<br>You should start the script wearing Ring of kinship." +
- "<br>You should start the script wielding antidragonshield." +
- "<br>You should start script wearing a charged Amulet of glory" +
- "<br>" +
- "<br>Suggested items in Bank:" +
- "<br>5k+ Lobster" +
- "<br>100+ anti-dragon shields" +
- "<br>Charged Amulets of Glory" +
- "<br>anti-poison potions" +
- "<br>" +
- "<br>Supported weapons:----------Supported Armour:" +
- "<br>Brackish blade------------------Granite body" +
- "<br>Abyssal whip--------------------Dragon plate" +
- "<br>Dragon scimitar-----------------Rune platelegs" +
- "<br>Dragon Longsword-------------Black dragonhide chaps" +
- "</html>"
- );
- panel4.add(label6);
- label6.setBounds(10, 10, label6.getPreferredSize().width,
- label6.getPreferredSize().height);
- {
- // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < panel4.getComponentCount(); i++) {
- Rectangle bounds = panel4.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height,
- preferredSize.height);
- }
- Insets insets = panel4.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- panel4.setMinimumSize(preferredSize);
- panel4.setPreferredSize(preferredSize);
- }
- }
- }
- contentPane.add(tabbedPane1);
- tabbedPane1.setBounds(5, 5, 307, 306);
- //panel order
- tabbedPane1.addTab("Combat", panel1);
- tabbedPane1.addTab("Item Pickup", panel2);
- tabbedPane1.addTab("Logout", panel3);
- tabbedPane1.addTab("Info", panel4);
- if (filepath.exists()) {
- tabbedPane1.setSelectedIndex(Integer.parseInt(opts[17]));
- }
- //---- button1 ----
- button1.setText("Start");
- button1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- button1ActionPerformed(e);
- }
- });
- contentPane.add(button1);
- button1.setBounds(4, 318, 150, button1.getPreferredSize().height);
- //---- button2 ----
- button2.setText("Price Lookup");
- button2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- button2ActionPerformed(e);
- }
- });
- contentPane.add(button2);
- button2.setBounds(155, 318, 150, button2.getPreferredSize().height);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < contentPane.getComponentCount(); i++) {
- Rectangle bounds = contentPane.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = contentPane.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- contentPane.setMinimumSize(preferredSize);
- contentPane.setPreferredSize(preferredSize);
- }
- setSize(325, 384);
- setLocationRelativeTo(getOwner());
- if (dragonbonesprice == 0) {
- //Thread thread = new BasicThread1();
- //thread.start();
- }
- }
- private JPanel panel1;
- private JLabel label1;
- private JLabel label2;
- private JLabel label3;
- private JLabel label4;
- private JPanel panel2;
- private JLabel label5;
- private JLabel label6;
- private JPanel panel3;
- private JPanel panel4;
- private JLabel label7;
- private JLabel label8;
- private JLabel label9;
- private JLabel label10;
- private JLabel label11;
- private JLabel energylabel;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement