Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 10th, 2012  |  syntax: None  |  size: 18.07 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.Color;
  2. import java.awt.Container;
  3. import java.awt.Dimension;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Insets;
  8. import java.awt.Point;
  9. import java.awt.Rectangle;
  10. import java.awt.RenderingHints;
  11. import java.awt.event.ActionEvent;
  12. import java.awt.event.ActionListener;
  13. import java.awt.image.BufferedImage;
  14. import java.io.IOException;
  15. import java.math.BigInteger;
  16. import java.net.MalformedURLException;
  17. import java.net.URL;
  18. import java.text.DecimalFormat;
  19. import java.text.DecimalFormatSymbols;
  20. import java.util.Map;
  21.  
  22. import javax.imageio.ImageIO;
  23. import javax.swing.DefaultComboBoxModel;
  24. import javax.swing.JButton;
  25. import javax.swing.JComboBox;
  26. import javax.swing.JFrame;
  27. import javax.swing.JLabel;
  28.  
  29. import org.rsbot.event.listeners.PaintListener;
  30. import org.rsbot.script.Script;
  31. import org.rsbot.script.ScriptManifest;
  32. import org.rsbot.script.methods.Skills;
  33. import org.rsbot.script.wrappers.RSComponent;
  34. import org.rsbot.script.wrappers.RSInterface;
  35. import org.rsbot.script.wrappers.RSItem;
  36. import org.rsbot.script.wrappers.RSObject;
  37.  
  38. @ScriptManifest(authors = { "A_C" }, category = "Magic", name = "The Enchanter", version = 0.1, description = "Setting are in the GUI")
  39. public class Enchanter extends Script implements PaintListener {
  40.  
  41.         //Jewellery ID's -- Credits to Black Ice
  42.         //0=ring, 1=neck, 2=ammulet
  43.         int[] sapphireUn = {1637, 1656, 1694};
  44.         int[] sapphireE = {2550, 3853, 1727};  
  45.         int[] emeraldUn = {1639, 1658, 1696};
  46.         int[] emeraldE = {2552, 5521, 1729};   
  47.         int[] rubyUn = {1641, -1, 1698};
  48.         int[] rubyE = {2568, -1, 1725};
  49.         int[] diamondUn = {1643, 1662, 1700};
  50.         int[] diamondE = {2570, 11090, 1731};  
  51.         int[] dstoneUn = {1645, 1664, 1702};
  52.         int[] dstoneE = {2572, 11105, 1712};
  53.  
  54.         //Other ID's
  55.         int spell;
  56.         int chest = 42192;
  57.         int jewellery;
  58.         int enchanted;
  59.  
  60.         //Paint
  61.         int startLvl = 0;
  62.         int startXp = 0;
  63.         private long timeStarted = 0;
  64.         double xpCast;
  65.         String status;
  66.     BufferedImage normal = null;
  67.     BufferedImage clicked = null;
  68.  
  69.         //Other Stuff
  70.         boolean canStart = false;
  71.  
  72.         public boolean onStart(Map<String, String> map) {
  73.                
  74.                 status = "Loading mouse images";
  75.                 try {
  76.             final URL cursorURL = new URL(
  77.                     "http://i48.tinypic.com/313623n.png");
  78.             final URL cursor80URL = new URL(
  79.                     "http://i46.tinypic.com/9prjnt.png");
  80.             normal = ImageIO.read(cursorURL);
  81.             clicked = ImageIO.read(cursor80URL);
  82.         } catch (MalformedURLException e) {
  83.             log("Unable to buffer cursor.");
  84.         } catch (IOException e) {
  85.             log("Unable to open cursor image.");
  86.         }
  87.                
  88.         status = "Loading GUI";
  89.                 timeStarted = System.currentTimeMillis();
  90.                 EnchanterGUI gui = new EnchanterGUI();
  91.                 gui.setVisible(true);          
  92.                
  93.                 return true;
  94.         }
  95.  
  96.  
  97.                 @Override
  98.                 public int loop() {
  99.  
  100.                         if (canStart) {
  101.  
  102.                                 if (getMyPlayer().getAnimation() != -1) {
  103.                                         return 0;
  104.                                 }
  105.                                
  106.                                 if (!inventory.contains(564)) {
  107.                                         log("You ran out of runes!");
  108.                                         return -1;
  109.                                 }
  110.                                
  111.                                 int antiban = random(0,4);
  112.                                 if (antiban == 4) {
  113.                                         camera.moveRandomly(random(100,500));
  114.                                 }
  115.  
  116.                                 mouse.setSpeed(random(5,7));
  117.  
  118.                                 if (!inventory.contains(jewellery)) {
  119.                                         status = "Banking";
  120.                                         if (!bank.isOpen()) {
  121.                                                 RSObject bChest = objects.getNearest(chest);
  122.                                                 if (bChest != null) {
  123.                                                         bChest.doAction("Use");
  124.                                                         return random(1000,1500);
  125.                                                 }
  126.                                         } else {
  127.                                                 if (bank.getCount(jewellery) == 0) {
  128.                                                         log("You have no more jewellery, stopping script");
  129.                                                         return -1;
  130.                                                 }
  131.                                                 if (inventory.contains(enchanted)) {
  132.                                                         bank.deposit(enchanted, 0);
  133.                                                         return random(1000,1500);
  134.                                                 }
  135.                                                 if (!inventory.contains(jewellery)) {
  136.                                                         bank.withdraw(jewellery, 0);
  137.                                                         return random(1000,1500);
  138.                                                 }
  139.                                         }
  140.                                 } else {
  141.                                         if (bank.isOpen()) {
  142.                                                 status = "Closing bank";
  143.                                                 bank.close();
  144.                                                 return random(250,500);
  145.                                         }
  146.                                         if (!magic.isSpellSelected()) {
  147.                                                 status = "Enchanting";
  148.                                                 magic.castSpell(spell);
  149.                                                 return random(250,500);
  150.                                         } else if (magic.isSpellSelected()) {
  151.                                                 RSItem cast = inventory.getItem(jewellery);
  152.                                                 if (cast != null)
  153.                                                 cast.doClick(true);
  154.                                                 return random(250,500);
  155.                                         }
  156.                                 }
  157.                         }
  158.                         return 0;
  159.                 }
  160.  
  161.                 @Override
  162.                 public void onRepaint(Graphics render) {
  163.  
  164.                         RSComponent inv = interfaces.get(149).getComponent(0);
  165.  
  166.                         if (game.isLoggedIn() && inv != null) {
  167.  
  168.                                 int paintX = inv.getAbsoluteX() + 5;
  169.                                 int paintY = inv.getAbsoluteY() + 17;
  170.  
  171.  
  172.                                 ((Graphics2D) render).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  173.  
  174.                                 long run = System.currentTimeMillis() - timeStarted;
  175.                                 double hour = (double) run / 1000 / 60 / 60;
  176.  
  177.                                 if (startLvl == 0) {
  178.                                         startLvl = skills.getCurrentLevel(Skills.MAGIC);
  179.                                 }
  180.                                 if (startXp == 0) {
  181.                                         startXp = skills.getCurrentExp(Skills.MAGIC);
  182.                                 }
  183.  
  184.                         final int mouse_x = mouse.getClientLocation().x;
  185.                         final int mouse_y = mouse.getClientLocation().y;
  186.                         final int mouse_x2 = mouse.getClientPressLocation().x;
  187.                         final int mouse_y2 = mouse.getClientPressLocation().y;
  188.                         final long mpt = System.currentTimeMillis()
  189.                                 - mouse.getClientPressTime();
  190.                         if (mouse.getClientPressTime() == -1 || mpt >= 1000) {
  191.                             render.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse when its not clicked
  192.                         }
  193.                         if (mpt < 1000) {
  194.                             render.drawImage(clicked, mouse_x2 - 8, mouse_y2 - 8, null); //this show the four squares where you clicked.
  195.                             render.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse as normal when its/just clicked
  196.                         }
  197.  
  198.  
  199.                                 Color transBlack = new Color(0, 0, 0, 170);
  200.                                 render.setColor(transBlack);
  201.                                 render.drawRoundRect(paintX - 17, paintY - 20, 181, 250, 20, 20);
  202.                                 render.fillRoundRect(paintX - 17, paintY - 20, 181, 250, 20, 20);
  203.                                 render.setColor(Color.WHITE);
  204.                                 render.setFont(new Font("Lucida", 0, 14));
  205.                                 render.drawString("A_C's Enchanter", paintX, paintY);
  206.                                 render.setFont(new Font("Lucida", 0, 11));
  207.                                 paintY += 15;
  208.                                 render.drawString("Ran for: " + getFormattedTimeElapsed(), paintX, paintY);
  209.                                 paintY += 15;
  210.                                 render.drawString("Status: " + status, paintX, paintY);
  211.                                 paintY += 15;
  212.                                 render.drawString("Casts: " + format((int)((skills.getCurrentExp(Skills.MAGIC) - startXp)/(xpCast))), paintX, paintY);
  213.                                 paintY += 15;
  214.                                 render.drawString("Casts p/hr : " + format((int)((skills.getCurrentExp(Skills.MAGIC) - startXp)/(xpCast)/hour)), paintX, paintY);
  215.                                 paintY += 30;
  216.                                 render.drawString("Magic xp gained: " + format(skills.getCurrentExp(Skills.MAGIC) - startXp), paintX, paintY);
  217.                                 paintY += 15;
  218.                                 render.drawString("Magic xp to next level: " + format(skills.getExpToNextLevel(Skills.MAGIC)), paintX, paintY);
  219.                                 paintY += 15;
  220.                                 render.drawString("Current magic Level: " +(skills.getCurrentLevel(Skills.MAGIC)) + " (" + (skills.getCurrentLevel(Skills.MAGIC) - startLvl) + ")", paintX, paintY);
  221.                                 paintY += 15;
  222.                                 render.drawString("Magic XP/Hour: " + format((int)((skills.getCurrentExp(Skills.MAGIC) - startXp)/hour)), paintX, paintY);
  223.                                 paintY += 15;
  224.                                 try {
  225.                                         render.drawString("TTNL: " + getTimeToLevel((int)((skills.getCurrentExp(Skills.MAGIC) - startXp)/hour), ((skills.getCurrentLevel(Skills.MAGIC)) +1), Skills.MAGIC), paintX, paintY);
  226.                                         paintY += 15;
  227.                                 } catch (InterruptedException e) {}
  228.                                 render.drawString("Percent to next level: " + skills.getPercentToNextLevel(Skills.MAGIC) + "%", paintX, paintY);
  229.                                 paintY += 10;
  230.                                 drawProgressBar(render, (int)skills.getPercentToNextLevel(Skills.MAGIC), paintX, paintY);
  231.  
  232.  
  233.                                 /*render.setColor(Color.GREEN);
  234.                         if (startLvl == 0) {
  235.                                 startLvl = skills.getCurrentLevel(Skills.MAGIC);
  236.                         }
  237.                         if (startXp == 0) {
  238.                                 startXp = skills.getCurrentExp(Skills.MAGIC);
  239.                         }
  240.                         render.drawString("Exp Gained: " + (skills.getCurrentExp(Skills.MAGIC) - startXp), 20, 135);
  241.                         render.drawString("Lvls Gained: " + (skills.getCurrentLevel(Skills.MAGIC) - startLvl), 20, 150);*/
  242.                         }
  243.  
  244.                 }
  245.  
  246.  
  247.                 //-----Methods-----
  248.                 public void drawProgressBar(Graphics g, int percent, int x, int y) {
  249.                         Color forestGreen = new Color(34, 139, 34);
  250.                         Color limeGreen = new Color(50, 205, 50);
  251.                         Color gold = new Color(255, 215, 0);
  252.                         Color darkOrange = new Color(255, 140, 0);
  253.                         Color orangeRed = new Color (255, 69, 0);
  254.                         Color red = new Color(255, 0, 0);
  255.                         g.setColor(Color.white);
  256.                         g.drawRect(x - 1, y - 1, 100 + 1, 11);
  257.                         if (percent <= 33) {
  258.                                 g.setColor(red);
  259.                         } else if (percent <= 66) {
  260.                                 g.setColor(darkOrange);
  261.                         } else if (percent > 66) {
  262.                                 g.setColor(forestGreen);
  263.                         }
  264.                         g.fillRect(x, y, 1 * percent, 10);
  265.                         if (percent <= 33) {
  266.                                 g.setColor(orangeRed);
  267.                         } else if (percent <= 66) {
  268.                                 g.setColor(gold);
  269.                         } else if (percent > 66) {
  270.                                 g.setColor(limeGreen);
  271.                         }
  272.                         g.fillRect(x, y, 1 * percent, 5);
  273.                 }
  274.  
  275.                 public long getTimeElapsed() {
  276.                         return System.currentTimeMillis() - timeStarted;
  277.                 }
  278.  
  279.                 public String getFormattedTimeElapsed() {
  280.                         final long runTime = getTimeElapsed();
  281.  
  282.                         final long seconds = runTime / 1000;
  283.                         final long minutes = seconds / 60;
  284.                         final long hours = minutes / 60;
  285.                         final long days = hours / 24;
  286.                         final int s = (int) seconds % 60;
  287.                         final int m = (int) minutes % 60;
  288.                         final int h = (int) hours % 60;
  289.  
  290.                         if (h >= 24) {
  291.                                 final int d = (int) days % 24;
  292.                                 return String.format("%0,2d:%0,2d:%0,2d:%0,2d", d, h, m, s);
  293.                         }
  294.  
  295.                         return String.format("%0,2d:%0,2d:%0,2d", h, m, s);
  296.                 }
  297.  
  298.                 public String format(int num) {
  299.                         DecimalFormat df = new DecimalFormat();
  300.                         DecimalFormatSymbols dfs = new DecimalFormatSymbols();
  301.                         dfs.setGroupingSeparator(',');
  302.                         df.setDecimalFormatSymbols(dfs);
  303.                         return df.format(num);
  304.                 }
  305.  
  306.                 public String getTimeToLevel(int xpPerHour, int targetLevel, int theSkill) throws InterruptedException {
  307.                         if (xpPerHour <= 0) {
  308.                                 return "00:00:00";
  309.                         }
  310.  
  311.                         String timeToLevel = "";
  312.                         int remainingXP = skills.getExpToNextLevel(theSkill);
  313.  
  314.                         BigInteger secondsToLevel = BigInteger.valueOf(remainingXP).multiply(BigInteger.valueOf(3600)).divide(
  315.                                         BigInteger.valueOf(xpPerHour));
  316.                         BigInteger hoursToLevel = secondsToLevel.divide(BigInteger.valueOf(3600));
  317.                         secondsToLevel = secondsToLevel.subtract(hoursToLevel.multiply(BigInteger.valueOf(3600)));
  318.                         BigInteger minutesToLevel = secondsToLevel.divide(BigInteger.valueOf(60));
  319.                         secondsToLevel = secondsToLevel.subtract(minutesToLevel.multiply(BigInteger.valueOf(60)));
  320.  
  321.                         if (hoursToLevel.compareTo(BigInteger.TEN) < 0) {
  322.                                 timeToLevel += "0";
  323.                         }
  324.                         timeToLevel += hoursToLevel + ":";
  325.                         if (minutesToLevel.compareTo(BigInteger.TEN) < 0) {
  326.                                 timeToLevel += "0";
  327.                         }
  328.                         timeToLevel += minutesToLevel + ":";
  329.                         if (secondsToLevel.compareTo(BigInteger.TEN) < 0) {
  330.                                 timeToLevel += "0";
  331.                         }
  332.                         timeToLevel += secondsToLevel;
  333.  
  334.                         return timeToLevel;
  335.                 }
  336.  
  337.  
  338.  
  339.  
  340.                 //-----GUI-----
  341.                 public class EnchanterGUI extends JFrame {
  342.  
  343.                         private static final long serialVersionUID = 1L;
  344.                         public EnchanterGUI() {
  345.                                 initComponents();
  346.                         }
  347.  
  348.                         private void button1ActionPerformed(ActionEvent e) {
  349.                                 if (e.getActionCommand().equals("Start")) {
  350.                                         if (comboBox1.getSelectedItem().equals("Please Select...") || comboBox2.getSelectedItem().equals("Please Select...")) {
  351.                                                 log("Please select Stone and Jewellery type!");
  352.                                         }
  353.                                         if (comboBox1.getSelectedItem().equals("Sapphire")) {
  354.                                                 if (comboBox2.getSelectedItem().equals("Ring")) {
  355.                                                         jewellery = sapphireUn[0];
  356.                                                         enchanted = sapphireE[0];
  357.                                                         spell = magic.SPELL_LVL1_ENCHANT;
  358.                                                         xpCast = 17.5;
  359.  
  360.                                                 }
  361.                                                 if (comboBox2.getSelectedItem().equals("Necklace")) {
  362.                                                         jewellery = sapphireUn[1];
  363.                                                         enchanted = sapphireE[1];
  364.                                                         spell = magic.SPELL_LVL1_ENCHANT;
  365.                                                         xpCast = 17.5;
  366.                                                 }
  367.                                                 if (comboBox2.getSelectedItem().equals("Amulet")) {
  368.                                                         jewellery = sapphireUn[2];
  369.                                                         enchanted = sapphireE[2];
  370.                                                         spell = magic.SPELL_LVL1_ENCHANT;
  371.                                                         xpCast = 17.5;
  372.                                                 }
  373.                                         }
  374.                                         if (comboBox1.getSelectedItem().equals("Emerald")) {
  375.                                                 if (comboBox2.getSelectedItem().equals("Ring")) {
  376.                                                         jewellery = emeraldUn[0];
  377.                                                         enchanted = emeraldE[0];
  378.                                                         spell = magic.SPELL_LVL2_ENCHANT;
  379.                                                         xpCast = 37.0;
  380.                                                 }
  381.                                                 if (comboBox2.getSelectedItem().equals("Necklace")) {
  382.                                                         jewellery = emeraldUn[1];
  383.                                                         enchanted = emeraldE[1];
  384.                                                         spell = magic.SPELL_LVL2_ENCHANT;
  385.                                                         xpCast = 37.0;
  386.                                                 }
  387.                                                 if (comboBox2.getSelectedItem().equals("Amulet")) {
  388.                                                         jewellery = emeraldUn[2];
  389.                                                         enchanted = emeraldE[2];
  390.                                                         spell = magic.SPELL_LVL2_ENCHANT;
  391.                                                         xpCast = 37.0;
  392.                                                 }
  393.                                         }
  394.                                         if (comboBox1.getSelectedItem().equals("Ruby")) {
  395.                                                 if (comboBox2.getSelectedItem().equals("Ring")) {
  396.                                                         jewellery = rubyUn[0];
  397.                                                         enchanted = rubyE[0];
  398.                                                         spell = magic.SPELL_LVL3_ENCHANT;
  399.                                                         xpCast = 59.0;
  400.                                                 }
  401.                                                 if (comboBox2.getSelectedItem().equals("Necklace")) {
  402.                                                         jewellery = rubyUn[1];
  403.                                                         enchanted = rubyE[1];
  404.                                                         spell = magic.SPELL_LVL3_ENCHANT;
  405.                                                         xpCast = 59.0;
  406.                                                 }
  407.                                                 if (comboBox2.getSelectedItem().equals("Amulet")) {
  408.                                                         jewellery = rubyUn[2];
  409.                                                         enchanted = rubyE[2];
  410.                                                         spell = magic.SPELL_LVL3_ENCHANT;
  411.                                                         xpCast = 59.0;
  412.                                                 }
  413.                                         }
  414.                                         if (comboBox1.getSelectedItem().equals("Diamond")) {
  415.                                                 if (comboBox2.getSelectedItem().equals("Ring")) {
  416.                                                         jewellery = diamondUn[0];
  417.                                                         enchanted = diamondE[0];
  418.                                                         spell = magic.SPELL_LVL4_ENCHANT;
  419.                                                         xpCast = 67.0;
  420.                                                 }
  421.                                                 if (comboBox2.getSelectedItem().equals("Necklace")) {
  422.                                                         jewellery = diamondUn[1];
  423.                                                         enchanted = diamondE[1];
  424.                                                         spell = magic.SPELL_LVL4_ENCHANT;
  425.                                                         xpCast = 67.0;
  426.                                                 }
  427.                                                 if (comboBox2.getSelectedItem().equals("Amulet")) {
  428.                                                         jewellery = diamondUn[2];
  429.                                                         enchanted = diamondE[2];
  430.                                                         spell = magic.SPELL_LVL4_ENCHANT;
  431.                                                         xpCast = 67.0;
  432.                                                 }
  433.                                         }
  434.                                         if (comboBox1.getSelectedItem().equals("Dragonstone")) {
  435.                                                 if (comboBox2.getSelectedItem().equals("Ring")) {
  436.                                                         jewellery = dstoneUn[0];
  437.                                                         enchanted = dstoneE[0];
  438.                                                         spell = magic.SPELL_LVL5_ENCHANT;
  439.                                                         xpCast = 78.0;
  440.                                                 }
  441.                                                 if (comboBox2.getSelectedItem().equals("Necklace")) {
  442.                                                         jewellery = dstoneUn[1];
  443.                                                         enchanted = dstoneE[1];
  444.                                                         spell = magic.SPELL_LVL5_ENCHANT;
  445.                                                         xpCast = 78.0;
  446.                                                 }
  447.                                                 if (comboBox2.getSelectedItem().equals("Amulet")) {
  448.                                                         jewellery = dstoneUn[2];
  449.                                                         enchanted = dstoneE[2];
  450.                                                         spell = magic.SPELL_LVL5_ENCHANT;
  451.                                                         xpCast = 78.0;
  452.                                                 }
  453.                                         }
  454.                                 }
  455.                                 log("Enchanting " + comboBox1.getSelectedItem().toString() + " " + comboBox2.getSelectedItem().toString());
  456.                                 canStart = true;
  457.                                 setVisible(false);
  458.                         }
  459.  
  460.                         private void initComponents() {
  461.                                 // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
  462.                                 label1 = new JLabel();
  463.                                 comboBox1 = new JComboBox();
  464.                                 label2 = new JLabel();
  465.                                 label3 = new JLabel();
  466.                                 comboBox2 = new JComboBox();
  467.                                 button1 = new JButton();
  468.  
  469.                                 //======== this ========
  470.                                 Container contentPane = getContentPane();
  471.                                 contentPane.setLayout(null);
  472.  
  473.                                 //---- label1 ----
  474.                                 label1.setText("A_C's Jewelery Enchanter");
  475.                                 contentPane.add(label1);
  476.                                 label1.setBounds(0, 0, 185, label1.getPreferredSize().height);
  477.  
  478.                                 //---- comboBox1 ----
  479.                                 comboBox1.setModel(new DefaultComboBoxModel(new String[] {
  480.                                                 "Please Select...",
  481.                                                 "Sapphire",
  482.                                                 "Emerald",
  483.                                                 "Ruby",
  484.                                                 "Diamond",
  485.                                                 "Dragonstone"
  486.                                 }));
  487.                                 contentPane.add(comboBox1);
  488.                                 comboBox1.setBounds(new Rectangle(new Point(55, 15), comboBox1.getPreferredSize()));
  489.  
  490.                                 //---- label2 ----
  491.                                 label2.setText("Stone:");
  492.                                 label2.setLabelFor(comboBox1);
  493.                                 contentPane.add(label2);
  494.                                 label2.setBounds(0, 15, label2.getPreferredSize().width, 25);
  495.  
  496.                                 //---- label3 ----
  497.                                 label3.setText("Jewelery:");
  498.                                 label3.setLabelFor(comboBox2);
  499.                                 contentPane.add(label3);
  500.                                 label3.setBounds(0, 40, label3.getPreferredSize().width, 25);
  501.  
  502.                                 //---- comboBox2 ----
  503.                                 comboBox2.setModel(new DefaultComboBoxModel(new String[] {
  504.                                                 "Please Select...",
  505.                                                 "Ring",
  506.                                                 "Necklace",
  507.                                                 "Amulet"
  508.                                 }));
  509.                                 contentPane.add(comboBox2);
  510.                                 comboBox2.setBounds(new Rectangle(new Point(55, 40), comboBox2.getPreferredSize()));
  511.  
  512.                                 //---- button1 ----
  513.                                 button1.setText("Start");
  514.                                 button1.addActionListener(new ActionListener() {
  515.                                         @Override
  516.                                         public void actionPerformed(ActionEvent e) {
  517.                                                 button1ActionPerformed(e);
  518.                                         }
  519.                                 });
  520.                                 contentPane.add(button1);
  521.                                 button1.setBounds(0, 65, 185, button1.getPreferredSize().height);
  522.  
  523.                                 { // compute preferred size
  524.                                         Dimension preferredSize = new Dimension();
  525.                                         for(int i = 0; i < contentPane.getComponentCount(); i++) {
  526.                                                 Rectangle bounds = contentPane.getComponent(i).getBounds();
  527.                                                 preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
  528.                                                 preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
  529.                                         }
  530.                                         Insets insets = contentPane.getInsets();
  531.                                         preferredSize.width += insets.right;
  532.                                         preferredSize.height += insets.bottom;
  533.                                         contentPane.setMinimumSize(preferredSize);
  534.                                         contentPane.setPreferredSize(preferredSize);
  535.                                 }
  536.                                 pack();
  537.                                 setLocationRelativeTo(getOwner());
  538.                                 // JFormDesigner - End of component initialization  //GEN-END:initComponents
  539.                         }
  540.  
  541.                         public void ShowComponents() {
  542.                                 java.awt.EventQueue.invokeLater(new Runnable() {
  543.                                         public void run() {
  544.                                                 new EnchanterGUI().setVisible(true);
  545.                                         }
  546.                                 });
  547.                         }
  548.  
  549.                         // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
  550.                         private JLabel label1;
  551.                         private JComboBox comboBox1;
  552.                         private JLabel label2;
  553.                         private JLabel label3;
  554.                         private JComboBox comboBox2;
  555.                         private JButton button1;
  556.                         // JFormDesigner - End of variables declaration  //GEN-END:variables
  557.                 }
  558.  
  559.         }