Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.pathCreator;
- import java.awt.Dimension;
- import java.awt.event.ActionEvent;
- import java.util.ArrayList;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JTextArea;
- import org.tribot.api2007.Player;
- import org.tribot.script.Script;
- public class PathGenerator extends Script {
- @Override
- public void run() {
- GUI gui = new GUI();
- while(gui.isVisible()){
- sleep(10000);
- }
- }
- class GUI extends JFrame{
- private static final long
- serialVersionUID = 1L;
- private ArrayList<String> path = new ArrayList<String>();
- private Dimension size = new Dimension(200, 700);
- public GUI(){
- setSize(size);
- setResizable(false);
- addComponents();
- setVisible(true);
- }
- private void addComponents() {
- final JTextArea dataSheet = new JTextArea();
- dataSheet.setSize(200, 475);
- dataSheet.setColumns(20);
- dataSheet.setRows(5);
- dataSheet.setAutoscrolls(true);
- dataSheet.setLocation(0, 200);
- add(dataSheet);
- JButton clear = new JButton("Clear");
- clear.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- clearActionPerformed(evt);
- }
- private void clearActionPerformed(ActionEvent evt) {
- dataSheet.setText("");
- path.clear();
- }
- });
- clear.setSize(100, 200);
- clear.setLocation(100, 0);
- add(clear);
- JButton tileAdder = new JButton("Add tile");
- tileAdder.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- tileAdderActionPerformed(evt);
- }
- private void tileAdderActionPerformed(ActionEvent evt) {
- path.add(Player.getRSPlayer().getPosition().toString());
- }
- });
- tileAdder.setSize(100, 100);
- tileAdder.setLocation(0, 0);
- add(tileAdder);
- JButton getPath = new JButton("Get Path");
- getPath.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- getPathActionPerformed(evt);
- }
- private void getPathActionPerformed(ActionEvent evt) {
- String output = "RSTile[] TO_AREA = {\n";
- for(int x = 0; x < path.size(); x++){
- String temp;
- if(x < path.size() - 1){
- temp = "new RSTile" + path.get(x) + ", \n";
- } else {
- temp = "new RSTile" + path.get(x);
- }
- output += temp;
- }
- dataSheet.setText(output + ")};" );
- path.clear();
- }
- });
- getPath.setSize(100, 100);
- getPath.setLocation(0, 100);
- add(getPath);
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment