Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.89 KB | None | 0 0
  1. import java.awt.Container;
  2. import java.awt.Dimension;
  3. import java.awt.Insets;
  4. import java.awt.Rectangle;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.io.File;
  8. import javax.swing.DefaultComboBoxModel;
  9. import javax.swing.JButton;
  10. import javax.swing.JCheckBox;
  11. import javax.swing.JComboBox;
  12. import javax.swing.JFrame;
  13. import javax.swing.JLabel;
  14. import javax.swing.JPanel;
  15. import javax.swing.JPasswordField;
  16. import javax.swing.JTabbedPane;
  17. import javax.swing.JTextField;
  18. import javax.swing.SwingUtilities;
  19. import javax.swing.WindowConstants;
  20. import com.rsbuddy.script.ActiveScript;
  21. import com.rsbuddy.script.Manifest;
  22. import com.rsbuddy.script.methods.Skills;
  23.  
  24.  
  25. @Manifest(authors = {"Jake"},
  26. keywords = {""},
  27. name = "testgui",
  28. version = 1.0,
  29. description = "")
  30.  
  31. public class testgui extends ActiveScript {
  32.  
  33. private JTabbedPane tabbedPane1;
  34. public JTextField textField1, textField2, textField3, usernamefield, potionamount;
  35. private JComboBox foodbox, logoutbox, loginbox;
  36. private JPasswordField passwordfield;
  37. private JButton button1;
  38. private JButton button2;
  39. private JButton button3;
  40. private JButton hpresetbutton;
  41. private JCheckBox
  42. botwarningcheck, guionstartcheck, equipmentcheck, cluescrollcheck, dragonbonescheck, dragonhidecheck,
  43. bluecharmcheck, greencharmcheck, goldcharmcheck, crimsoncharmcheck, runedaggercheck, runwhentbedcheck;
  44.  
  45. int dragonbonesprice, dragonhideprice;
  46.  
  47. private File filepath;
  48.  
  49. private String displayname;
  50.  
  51. long totalhours, totalminutes;
  52.  
  53. private String totalmoneystring = "0";
  54.  
  55. String[] opts = new String[27];
  56.  
  57. private int totalmoneygained = 0;
  58.  
  59. public boolean startScript = false;
  60.  
  61. DragonGUI gui;
  62.  
  63. public boolean onStart() {
  64. try{
  65. SwingUtilities.invokeAndWait(new Runnable(){
  66. public void run(){
  67. gui = new DragonGUI();
  68. gui.setVisible(true);
  69. }
  70. });
  71. while(gui.isVisible()){
  72. sleep(100);
  73. }
  74. if (!startScript){
  75. return false;
  76. }
  77. }catch (Exception e){
  78. log("gui fail");
  79. return false;
  80. }
  81.  
  82. return true;
  83. }
  84.  
  85. public int loop() {
  86. return 300;
  87. }
  88.  
  89.  
  90. @SuppressWarnings("serial")
  91. public class DragonGUI extends JFrame {
  92.  
  93. public DragonGUI() {
  94. initComponents();
  95. }
  96.  
  97. private void button1ActionPerformed(ActionEvent e) {
  98. startScript = true;
  99. setVisible(false);
  100. }
  101.  
  102. private void button2ActionPerformed(ActionEvent e) {
  103. //Thread thread = new BasicThread1();
  104. //thread.start();
  105. }
  106.  
  107. private void button3ActionPerformed(ActionEvent e) {
  108. totalhours = 0;
  109. totalminutes = 0;
  110. totalmoneystring = "0";
  111. label11.setText("Total Money Gained: " + totalmoneygained);
  112. label9.setText("Total Login Time: " + totalhours + ":" + totalminutes);
  113. log("Total time and money cleared.");
  114. }
  115.  
  116. private void hpresetbuttonActionPerformed(ActionEvent e) {
  117. final int totalhp = Skills.getRealLevel(Skills.CONSTITUTION) * 10;
  118.  
  119. if (totalhp >= 500) {
  120. textField2.setText("350");
  121. textField3.setText("400");
  122. }
  123. if (totalhp >= 700) {
  124. textField2.setText("400");
  125. textField3.setText("550");
  126. }
  127. if (totalhp >= 800) {
  128. textField2.setText("550");
  129. textField3.setText("650");
  130. }
  131. }
  132.  
  133. private void initComponents() {
  134.  
  135. runedaggercheck = new JCheckBox();
  136. botwarningcheck = new JCheckBox();
  137. runwhentbedcheck = new JCheckBox();
  138. guionstartcheck = new JCheckBox();
  139. equipmentcheck = new JCheckBox();
  140. dragonbonescheck = new JCheckBox();
  141. dragonhidecheck = new JCheckBox();
  142. cluescrollcheck = new JCheckBox();
  143. bluecharmcheck = new JCheckBox();
  144. goldcharmcheck = new JCheckBox();
  145. greencharmcheck = new JCheckBox();
  146. crimsoncharmcheck = new JCheckBox();
  147.  
  148. foodbox = new JComboBox();
  149. logoutbox = new JComboBox();
  150. loginbox = new JComboBox();
  151. tabbedPane1 = new JTabbedPane();
  152. panel1 = new JPanel();
  153. label1 = new JLabel();
  154. label2 = new JLabel();
  155. label3 = new JLabel();
  156. textField1 = new JTextField();
  157. potionamount = new JTextField();
  158. textField2 = new JTextField();
  159. label4 = new JLabel();
  160. textField3 = new JTextField();
  161. usernamefield = new JTextField();
  162. passwordfield = new JPasswordField();
  163. panel2 = new JPanel();
  164. label5 = new JLabel();
  165. label6 = new JLabel();
  166. panel3 = new JPanel();
  167. panel4 = new JPanel();
  168. label7 = new JLabel();
  169. label8 = new JLabel();
  170. label9 = new JLabel();
  171. label10 = new JLabel();
  172. label11 = new JLabel();
  173. energylabel = new JLabel();
  174. button1 = new JButton();
  175. button2 = new JButton();
  176. button3 = new JButton();
  177. hpresetbutton = new JButton();
  178.  
  179. if (filepath.exists()){
  180. //readsettings();
  181. }
  182.  
  183.  
  184.  
  185. //======== this ========
  186. setTitle(displayname + " - Jake's Green Dragon Killer");
  187. setAlwaysOnTop(true);
  188. setResizable(false);
  189. setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  190. Container contentPane = getContentPane();
  191. contentPane.setLayout(null);
  192.  
  193. //======== tabbedPane1 ========
  194. {
  195.  
  196. //======== panel1 ========
  197. {
  198. panel1.setLayout(null);
  199.  
  200. //foodbox
  201. foodbox.setModel(new DefaultComboBoxModel(new String[] {
  202. "Tuna", "Lobster", "Swordfish", "Monkfish" }));
  203. panel1.add(foodbox);
  204. foodbox.setBounds(10, 30, 130, foodbox.getPreferredSize().height);
  205. foodbox.setSelectedItem("Lobster");
  206. if (filepath.exists()) {
  207. foodbox.setSelectedItem(opts[11]);
  208. }
  209.  
  210. //---- label1 ----
  211. label1.setText("Select food type:");
  212. panel1.add(label1);
  213. label1.setBounds(10, 10, 85, label1.getPreferredSize().height);
  214.  
  215. //---- label2 ----
  216. label2.setText("Ammount of food to withdraw:");
  217. panel1.add(label2);
  218. label2.setBounds(10, 85, label2.getPreferredSize().width, label2.getPreferredSize().height);
  219.  
  220. //---- textField1 ----
  221. textField1.setText("28");
  222. panel1.add(textField1);
  223. textField1.setBounds(160, 81, 20, textField1.getPreferredSize().height);
  224. if (filepath.exists()){
  225. textField1.setText(opts[16]);
  226. }
  227.  
  228. //---- energylabel ----
  229. energylabel.setText("Ammount of energy potions to withdraw:");
  230. panel1.add(energylabel);
  231. energylabel.setBounds(10, 115, energylabel.getPreferredSize().width, energylabel.getPreferredSize().height);
  232.  
  233. //---- potionamount ----
  234. potionamount.setText("0");
  235. panel1.add(potionamount);
  236. potionamount.setBounds(210, 111, 20, potionamount.getPreferredSize().height);
  237. if (filepath.exists()){
  238. potionamount.setText(opts[25]);
  239. }
  240.  
  241. //---- label3 ----
  242. label3.setText("Eat when HP is");
  243. panel1.add(label3);
  244. label3.setBounds(10, 160, 75, label3.getPreferredSize().height);
  245.  
  246. //---- textField2 ----
  247. textField2.setText("350");
  248. panel1.add(textField2);
  249. textField2.setBounds(89, 156, 30, textField2.getPreferredSize().height);
  250.  
  251. //---- label4 ----
  252. label4.setText("-");
  253. panel1.add(label4);
  254. label4.setBounds(124, 159, 15, label4.getPreferredSize().height);
  255.  
  256. //---- textField3 ----
  257. textField3.setText("450");
  258. panel1.add(textField3);
  259. textField3.setBounds(135, 156, 30, 20);
  260.  
  261. //---- hpresetbutton ----
  262. hpresetbutton.setText("Reset");
  263. hpresetbutton.addActionListener(new ActionListener() {
  264. public void actionPerformed(ActionEvent e) {
  265. hpresetbuttonActionPerformed(e);
  266. }
  267. });
  268. panel1.add(hpresetbutton);
  269. hpresetbutton.setBounds(175, 154, hpresetbutton.getPreferredSize().width,
  270. hpresetbutton.getPreferredSize().height);
  271.  
  272.  
  273. //equipmentcheck
  274. equipmentcheck.setText("Check Equipment");
  275. panel1.add(equipmentcheck);
  276. equipmentcheck.setBounds(5, 195, 125, equipmentcheck.getPreferredSize().height);
  277. if (!filepath.exists()) {
  278. equipmentcheck.setSelected(true);
  279. }
  280.  
  281. //guionstartcheck
  282. guionstartcheck.setText("Show GUI on startup");
  283. panel1.add(guionstartcheck);
  284. guionstartcheck.setBounds(5, 215, guionstartcheck.getPreferredSize().width,
  285. guionstartcheck.getPreferredSize().height);
  286. if (!filepath.exists()) {
  287. guionstartcheck.setSelected(true);
  288. }
  289.  
  290. //botwarningcheck
  291. botwarningcheck.setText("Notify me when called a bot");
  292. panel1.add(botwarningcheck);
  293. botwarningcheck.setBounds(5, 235, botwarningcheck.getPreferredSize().width,
  294. botwarningcheck.getPreferredSize().height);
  295. if (!filepath.exists()) {
  296. botwarningcheck.setSelected(true);
  297. }
  298.  
  299. //runwhentbedcheck
  300. runwhentbedcheck.setText("Run when tbed.");
  301. panel1.add(runwhentbedcheck);
  302. runwhentbedcheck.setBounds(5, 255, runwhentbedcheck.getPreferredSize().width,
  303. runwhentbedcheck.getPreferredSize().height);
  304.  
  305. final int totalhp = Skills.getRealLevel(Skills.CONSTITUTION) * 10;
  306.  
  307. if (totalhp >= 500) {
  308. textField2.setText("350");
  309. textField3.setText("400");
  310. }
  311. if (totalhp >= 700) {
  312. textField2.setText("400");
  313. textField3.setText("550");
  314. }
  315. if (totalhp >= 800) {
  316. textField2.setText("500");
  317. textField3.setText("650");
  318. }
  319.  
  320. if (filepath.exists()){
  321. textField2.setText(opts[14]);
  322. textField3.setText(opts[15]);
  323. }
  324.  
  325. { // compute preferred size
  326. Dimension preferredSize = new Dimension();
  327. for(int i = 0; i < panel1.getComponentCount(); i++) {
  328. Rectangle bounds = panel1.getComponent(i).getBounds();
  329. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  330. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  331. //preferredSize.width = 165;
  332. //preferredSize.height = 176;
  333. preferredSize.width = 198;
  334. preferredSize.height = 211;
  335. }
  336. Insets insets = panel1.getInsets();
  337. preferredSize.width += insets.right;
  338. preferredSize.height += insets.bottom;
  339. panel1.setMinimumSize(preferredSize);
  340. panel1.setPreferredSize(preferredSize);
  341. }
  342. }
  343.  
  344.  
  345. //======== panel2 ========
  346. {
  347. panel2.setLayout(null);
  348.  
  349. //---- label5 ----
  350. label5.setText("Checked Items will be picked up and kept, unchecked items will be left or dropped.");
  351. panel2.add(label5);
  352. label5.setBounds(10, 10, 245, 40);
  353.  
  354. //---- dragonbones ----
  355. dragonbonescheck.setText("Dragon bones " + "(" + dragonbonesprice + ")");
  356. panel2.add(dragonbonescheck);
  357. dragonbonescheck.setBounds(10, 50, 128, dragonbonescheck.getPreferredSize().height);
  358. if (!filepath.exists()) {
  359. dragonbonescheck.setSelected(true);
  360. }
  361.  
  362. //---- dragonhide ----
  363. dragonhidecheck.setText("Dragonhide " + "(" + dragonhideprice + ")");
  364. panel2.add(dragonhidecheck);
  365. dragonhidecheck.setBounds(10, 70, 130, 23);
  366. if (!filepath.exists()) {
  367. dragonhidecheck.setSelected(true);
  368. }
  369.  
  370. //---- cluescroll ----
  371. cluescrollcheck.setText("Clue Scroll");
  372. panel2.add(cluescrollcheck);
  373. cluescrollcheck.setBounds(10, 90, 130, 23);
  374. if (!filepath.exists()) {
  375. cluescrollcheck.setSelected(true);
  376. }
  377.  
  378. //---- bluecharm ----
  379. bluecharmcheck.setText("Blue Charm");
  380. panel2.add(bluecharmcheck);
  381. bluecharmcheck.setBounds(10, 110, 130, 23);
  382.  
  383. //---- greencharm ----
  384. greencharmcheck.setText("Green Charm");
  385. panel2.add(greencharmcheck);
  386. greencharmcheck.setBounds(10, 130, 130, 23);
  387.  
  388. //---- goldcharm ----
  389. goldcharmcheck.setText("Gold Charm");
  390. panel2.add(goldcharmcheck);
  391. goldcharmcheck.setBounds(10, 150, 130, 23);
  392.  
  393. //---- crimsoncharm ----
  394. crimsoncharmcheck.setText("Crimson Charm");
  395. panel2.add(crimsoncharmcheck);
  396. crimsoncharmcheck.setBounds(10, 170, 130, 23);
  397.  
  398. //---- runedagger ----
  399. runedaggercheck.setText("Rune dagger");
  400. panel2.add(runedaggercheck);
  401. runedaggercheck.setBounds(10, 190, 130, 23);
  402. if (!filepath.exists()) {
  403. runedaggercheck.setSelected(true);
  404. }
  405.  
  406. {
  407. // compute preferred size
  408. Dimension preferredSize = new Dimension();
  409. for(int i = 0; i < panel2.getComponentCount(); i++) {
  410. Rectangle bounds = panel2.getComponent(i).getBounds();
  411. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  412. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  413. }
  414. Insets insets = panel2.getInsets();
  415. preferredSize.width += insets.right;
  416. preferredSize.height += insets.bottom;
  417. panel2.setMinimumSize(preferredSize);
  418. panel2.setPreferredSize(preferredSize);
  419. }
  420. }
  421.  
  422.  
  423. //======== panel3 ========
  424. {
  425. panel3.setLayout(null);
  426.  
  427. //---- label7 ----
  428. label7.setText("Logout After:");
  429. panel3.add(label7);
  430. label7.setBounds(10, 10, 100, label7.getPreferredSize().height);
  431.  
  432. //logoutbox
  433. logoutbox.setModel(new DefaultComboBoxModel(new String[] {
  434. "Never", "1 Hour", "2 Hours", "3 Hours", "4 Hours"}));
  435. panel3.add(logoutbox);
  436. logoutbox.setBounds(10, 25, 130, logoutbox.getPreferredSize().height);
  437. if (filepath.exists()) {
  438. logoutbox.setSelectedItem(opts[12]);
  439. }
  440.  
  441. //---- label8 ----
  442. label8.setText("Log back in After:");
  443. panel3.add(label8);
  444. label8.setBounds(10, 50, 100, label8.getPreferredSize().height);
  445.  
  446. //loginbox
  447. loginbox.setModel(new DefaultComboBoxModel(new String[] {
  448. "Never", }));//"1 Hour", "2 Hours", "3 Hours", "4 Hours"}));
  449. panel3.add(loginbox);
  450. loginbox.setBounds(10, 65, 130, loginbox.getPreferredSize().height);
  451. if (filepath.exists()) {
  452. loginbox.setSelectedItem(opts[13]);
  453. }
  454.  
  455. //---- label10 ----
  456. label10.setText("<html>Username: " +
  457. "<br>" +
  458. "<br>" +
  459. "<br>Password:" +
  460. "</html>");
  461. panel3.add(label10);
  462. label10.setBounds(10, 115, label10.getPreferredSize().width,
  463. label10.getPreferredSize().height);
  464.  
  465. //---- usernamefield ----
  466. usernamefield.setText("");
  467. panel3.add(usernamefield);
  468. usernamefield.setBounds(10, 134, 100, usernamefield.getPreferredSize().height);
  469. if (filepath.exists()){
  470. usernamefield.setText(opts[0]);
  471. }
  472.  
  473. //password
  474. passwordfield.setText("");
  475. panel3.add(passwordfield);
  476. passwordfield.setBounds(10, 173, 100, passwordfield.getPreferredSize().height);
  477. if (filepath.exists()){
  478. passwordfield.setText(opts[1]);
  479. }
  480.  
  481. //---- label10 ----
  482. label11.setText("Total Money Gained: " + totalmoneystring);
  483. panel3.add(label11);
  484. label11.setBounds(10, 229, label11.getPreferredSize().width,
  485. label11.getPreferredSize().height);
  486.  
  487. //---- label9 ----
  488. label9.setText("Total Login Time: " + totalhours + ":" + totalminutes);
  489. panel3.add(label9);
  490. label9.setBounds(10, 249, label9.getPreferredSize().width,
  491. label9.getPreferredSize().height);
  492.  
  493. //---- button3 ----
  494. button3.setText("Reset");
  495. button3.addActionListener(new ActionListener() {
  496. public void actionPerformed(ActionEvent e) {
  497. button3ActionPerformed(e);
  498. }
  499. });
  500. panel3.add(button3);
  501. button3.setBounds(130, 244, button3.getPreferredSize().width,
  502. button3.getPreferredSize().height);
  503.  
  504.  
  505. { // compute preferred size
  506. Dimension preferredSize = new Dimension();
  507. for(int i = 0; i < panel3.getComponentCount(); i++) {
  508. Rectangle bounds = panel3.getComponent(i).getBounds();
  509. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  510. preferredSize.height = Math.max(bounds.y + bounds.height,
  511. preferredSize.height);
  512. }
  513. Insets insets = panel3.getInsets();
  514. preferredSize.width += insets.right;
  515. preferredSize.height += insets.bottom;
  516. panel3.setMinimumSize(preferredSize);
  517. panel3.setPreferredSize(preferredSize);
  518. }
  519. }
  520.  
  521. //======== panel4 ========
  522. {
  523. panel4.setLayout(null);
  524.  
  525. //---- label6 ----
  526. label6.setText("<html>Script suggestions: " +
  527. "<br>You should start the script wearing Ring of kinship." +
  528. "<br>You should start the script wielding antidragonshield." +
  529. "<br>You should start script wearing a charged Amulet of glory" +
  530. "<br>" +
  531. "<br>Suggested items in Bank:" +
  532. "<br>5k+ Lobster" +
  533. "<br>100+ anti-dragon shields" +
  534. "<br>Charged Amulets of Glory" +
  535. "<br>anti-poison potions" +
  536. "<br>" +
  537. "<br>Supported weapons:----------Supported Armour:" +
  538. "<br>Brackish blade------------------Granite body" +
  539. "<br>Abyssal whip--------------------Dragon plate" +
  540. "<br>Dragon scimitar-----------------Rune platelegs" +
  541. "<br>Dragon Longsword-------------Black dragonhide chaps" +
  542. "</html>"
  543. );
  544.  
  545.  
  546. panel4.add(label6);
  547. label6.setBounds(10, 10, label6.getPreferredSize().width,
  548. label6.getPreferredSize().height);
  549.  
  550.  
  551. {
  552. // compute preferred size
  553. Dimension preferredSize = new Dimension();
  554. for(int i = 0; i < panel4.getComponentCount(); i++) {
  555. Rectangle bounds = panel4.getComponent(i).getBounds();
  556. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  557. preferredSize.height = Math.max(bounds.y + bounds.height,
  558. preferredSize.height);
  559. }
  560. Insets insets = panel4.getInsets();
  561. preferredSize.width += insets.right;
  562. preferredSize.height += insets.bottom;
  563. panel4.setMinimumSize(preferredSize);
  564. panel4.setPreferredSize(preferredSize);
  565. }
  566. }
  567.  
  568. }
  569. contentPane.add(tabbedPane1);
  570. tabbedPane1.setBounds(5, 5, 307, 306);
  571.  
  572. //panel order
  573. tabbedPane1.addTab("Combat", panel1);
  574. tabbedPane1.addTab("Item Pickup", panel2);
  575. tabbedPane1.addTab("Logout", panel3);
  576. tabbedPane1.addTab("Info", panel4);
  577. if (filepath.exists()) {
  578. tabbedPane1.setSelectedIndex(Integer.parseInt(opts[17]));
  579. }
  580.  
  581. //---- button1 ----
  582. button1.setText("Start");
  583. button1.addActionListener(new ActionListener() {
  584. public void actionPerformed(ActionEvent e) {
  585. button1ActionPerformed(e);
  586. }
  587. });
  588. contentPane.add(button1);
  589. button1.setBounds(4, 318, 150, button1.getPreferredSize().height);
  590.  
  591. //---- button2 ----
  592. button2.setText("Price Lookup");
  593. button2.addActionListener(new ActionListener() {
  594. public void actionPerformed(ActionEvent e) {
  595. button2ActionPerformed(e);
  596. }
  597. });
  598. contentPane.add(button2);
  599. button2.setBounds(155, 318, 150, button2.getPreferredSize().height);
  600.  
  601. { // compute preferred size
  602. Dimension preferredSize = new Dimension();
  603. for(int i = 0; i < contentPane.getComponentCount(); i++) {
  604. Rectangle bounds = contentPane.getComponent(i).getBounds();
  605. preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  606. preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  607. }
  608. Insets insets = contentPane.getInsets();
  609. preferredSize.width += insets.right;
  610. preferredSize.height += insets.bottom;
  611. contentPane.setMinimumSize(preferredSize);
  612. contentPane.setPreferredSize(preferredSize);
  613. }
  614. setSize(325, 384);
  615. setLocationRelativeTo(getOwner());
  616. if (dragonbonesprice == 0) {
  617. //Thread thread = new BasicThread1();
  618. //thread.start();
  619. }
  620. }
  621. private JPanel panel1;
  622. private JLabel label1;
  623. private JLabel label2;
  624. private JLabel label3;
  625. private JLabel label4;
  626. private JPanel panel2;
  627. private JLabel label5;
  628. private JLabel label6;
  629. private JPanel panel3;
  630. private JPanel panel4;
  631. private JLabel label7;
  632. private JLabel label8;
  633. private JLabel label9;
  634. private JLabel label10;
  635. private JLabel label11;
  636. private JLabel energylabel;
  637. }
  638.  
  639. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement