Advertisement
Guest User

Untitled

a guest
Nov 20th, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.34 KB | None | 0 0
  1. import javax.swing.event.*;
  2. import org.dreambot.api.wrappers.interactive.GameObject;
  3. import java.awt.*;
  4. import java.awt.event.ActionEvent;
  5. import java.util.ArrayList;
  6. import javax.swing.*;
  7. /*
  8.  * Created by JFormDesigner on Thu Nov 19 19:05:37 PST 2015
  9.  */
  10.  
  11.  
  12.  
  13. /**
  14.  * @author Zack Townsend
  15.  */
  16. public class stateminerGUI extends JFrame {
  17.     private DefaultListModel<GameObject> mineListModel;
  18.     private DefaultListModel<GameObject> rockListModel;
  19.     private ArrayList<GameObject> ourRocks;
  20.     private stateminer ctx;
  21.  
  22.  
  23.     public stateminerGUI (stateminer main) {
  24.         this.ctx = main;
  25.         initComponents();
  26.         mineList = new JList<GameObject>(mineListModel);
  27.         rockList = new JList<GameObject>(rockListModel);
  28.         rockListModel = new DefaultListModel<GameObject>();
  29.         mineListModel = new DefaultListModel<GameObject>();
  30.     }
  31.         //---Starts script after GUI selection ---\\
  32.         private void button1ActionPerformed (ActionEvent e){
  33.             ctx.setStartScript(true);
  34.             ctx.setOreName(oreBox.getSelectedItem().toString());
  35.             ArrayList<GameObject> ourRocks = new ArrayList<GameObject>();
  36.             for (int i = 0; i < mineListModel.getSize(); i++){
  37.                 ourRocks.add(mineListModel.get(i));
  38.             }
  39.                 ctx.setOurRocks(ourRocks);
  40.         }
  41.  
  42.         //---List of ores in area around the player---\\
  43.     private void rockListValueChanged(ListSelectionEvent e) {
  44.         ctx.setRockWireFrame((GameObject)rockList.getSelectedValue());
  45.     }
  46.  
  47.     //---Creates the refreshed ore list---\\
  48.     public void RefreshOreButtonActionPerformed(ActionEvent e) {
  49.         for (GameObject nearbyrocks : ctx.getNearbyRocks()) {
  50.             rockListModel.addElement(nearbyrocks);
  51.         }
  52.     }
  53.  
  54.     public void AddOreButtonActionPerformed(ActionEvent e) {
  55.         rockListModel.addElement((GameObject)mineList.getSelectedValue());
  56.     }
  57.  
  58.     private void RemoveOreButtonActionPerformed(ActionEvent e) {
  59.         mineListModel.removeElement(mineList.getSelectedValue());
  60.     }
  61.  
  62.     private void initComponents() {
  63.         tabbedPane1 = new JTabbedPane();
  64.         Panel1 = new JPanel();
  65.         oreBox = new JComboBox<>();
  66.         label1 = new JLabel();
  67.         button1 = new JButton();
  68.         checkBox1 = new JCheckBox();
  69.         Rocks = new JPanel();
  70.         scrollPane1 = new JScrollPane();
  71.         rockList = new JList();
  72.         scrollPane2 = new JScrollPane();
  73.         mineList = new JList();
  74.         AddOreButton = new JButton();
  75.         RemoveOreButton = new JButton();
  76.         RefreshOreButton = new JButton();
  77.  
  78.         //======== this ========
  79.         Container contentPane = getContentPane();
  80.         contentPane.setLayout(null);
  81.  
  82.         //======== tabbedPane1 ========
  83.         {
  84.  
  85.             //======== Panel1 ========
  86.             {
  87.  
  88.                 Panel1.setBorder(new javax.swing.border.CompoundBorder(
  89.                         new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
  90.                                 "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
  91.                                 javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
  92.                                 java.awt.Color.red), Panel1.getBorder()));
  93.                 Panel1.addPropertyChangeListener(e -> {
  94.                     if ("border".equals(e.getPropertyName())) throw new RuntimeException();
  95.                 });
  96.  
  97.                 Panel1.setLayout(null);
  98.  
  99.                 //---- oreBox ----
  100.                 oreBox.setModel(new DefaultComboBoxModel<>(new String[]{
  101.                         "Tin",
  102.                         "Copper",
  103.                         "Iron ore",
  104.                         "Coal",
  105.                         "Silver ore",
  106.                         "Gold ore",
  107.                         "Mithril ore",
  108.                         "Adamantite ore",
  109.                         "Runite ore"
  110.                 }));
  111.                 Panel1.add(oreBox);
  112.                 oreBox.setBounds(70, 45, 130, 50);
  113.  
  114.                 //---- label1 ----
  115.                 label1.setText("Select your ore type");
  116.                 Panel1.add(label1);
  117.                 label1.setBounds(new Rectangle(new Point(210, 60), label1.getPreferredSize()));
  118.  
  119.                 //---- button1 ----
  120.                 button1.setText("Start");
  121.                 button1.addActionListener(e -> button1ActionPerformed(e));
  122.                 Panel1.add(button1);
  123.                 button1.setBounds(30, 165, 310, 65);
  124.  
  125.  
  126.                 //---- checkBox1 ---- Add to drop functionality if not checked. Or bank if checked etc. --\\
  127.                 ctx.setDrop(!checkBox1.isSelected());
  128.                 checkBox1.setText("Bank?");
  129.                 Panel1.add(checkBox1);
  130.                 checkBox1.setBounds(145, 105, 75, 35);
  131.             }
  132.             tabbedPane1.addTab("Settings", Panel1);
  133.  
  134.             //======== Rocks ========
  135.             {
  136.  
  137.                 //======== scrollPane1 ========
  138.                 {
  139.  
  140.                     //---- rockList ----
  141.                     rockList.addListSelectionListener(e -> rockListValueChanged(e));
  142.                     scrollPane1.setViewportView(rockList);
  143.                 }
  144.  
  145.                 //======== scrollPane2 ========
  146.                 {
  147.                     scrollPane2.setViewportView(mineList);
  148.                 }
  149.  
  150.                 //---- AddOreButton ----
  151.                 AddOreButton.setText("Add ore");
  152.                 AddOreButton.addActionListener(e -> AddOreButtonActionPerformed(e));
  153.  
  154.                 //---- RemoveOreButton ----
  155.                 RemoveOreButton.setText("Remove ore");
  156.                 RemoveOreButton.addActionListener(e -> RemoveOreButtonActionPerformed(e));
  157.  
  158.                 //---- RefreshOreButton ----
  159.                 RefreshOreButton.setText("Refresh ore list");
  160.                 RefreshOreButton.addActionListener(e -> RefreshOreButtonActionPerformed(e));
  161.  
  162.                 GroupLayout RocksLayout = new GroupLayout(Rocks);
  163.                 Rocks.setLayout(RocksLayout);
  164.                 RocksLayout.setHorizontalGroup(
  165.                         RocksLayout.createParallelGroup()
  166.                                 .addGroup(RocksLayout.createSequentialGroup()
  167.                                         .addGap(14, 14, 14)
  168.                                         .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, 105, GroupLayout.PREFERRED_SIZE)
  169.                                         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  170.                                         .addGroup(RocksLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
  171.                                                 .addComponent(RemoveOreButton, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  172.                                                 .addComponent(RefreshOreButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  173.                                                 .addComponent(AddOreButton, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  174.                                         .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
  175.                                         .addComponent(scrollPane2, GroupLayout.PREFERRED_SIZE, 106, GroupLayout.PREFERRED_SIZE)
  176.                                         .addGap(40, 40, 40))
  177.                 );
  178.                 RocksLayout.setVerticalGroup(
  179.                         RocksLayout.createParallelGroup()
  180.                                 .addGroup(RocksLayout.createSequentialGroup()
  181.                                         .addContainerGap()
  182.                                         .addGroup(RocksLayout.createParallelGroup()
  183.                                                 .addComponent(scrollPane2, GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)
  184.                                                 .addComponent(scrollPane1, GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)))
  185.                                 .addGroup(RocksLayout.createSequentialGroup()
  186.                                         .addGap(20, 20, 20)
  187.                                         .addComponent(AddOreButton)
  188.                                         .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
  189.                                         .addComponent(RemoveOreButton)
  190.                                         .addGap(42, 42, 42)
  191.                                         .addComponent(RefreshOreButton)
  192.                                         .addGap(0, 70, Short.MAX_VALUE))
  193.                 );
  194.             }
  195.             tabbedPane1.addTab("Rocks", Rocks);
  196.         }
  197.  
  198.         contentPane.add(tabbedPane1);
  199.         tabbedPane1.setBounds(0, 0, 385, 260);
  200.         contentPane.setPreferredSize(new Dimension(370, 260));
  201.         pack();
  202.         setLocationRelativeTo(getOwner());
  203.     }
  204.  
  205.     private JTabbedPane tabbedPane1;
  206.     private JPanel Panel1;
  207.     private JComboBox<String> oreBox;
  208.     private JLabel label1;
  209.     private JButton button1;
  210.     private JCheckBox checkBox1;
  211.     private JPanel Rocks;
  212.     private JScrollPane scrollPane1;
  213.     private JList rockList;
  214.     private JScrollPane scrollPane2;
  215.     private JList mineList;
  216.     private JButton AddOreButton;
  217.     private JButton RemoveOreButton;
  218.     private JButton RefreshOreButton;
  219. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement