ikk Posted February 3, 2016 Share Posted February 3, 2016 (edited) I'm not sure why, but like 25% of the time when I start my script, it will freeze the OSBot window, forcing the user to close the task. The Logger shows no issues, it simply freezes.. I built the GUI using JFormDesigner with the evaluation version (doubt this could matter, but who knows?) Would someone mind looking through the code to see if you can spot any possible reason for such an issue? I've looked through this countless times but it's been rattling my mind lol GUI.class Source: import java.awt.Container; import java.awt.Dimension; import java.awt.Font; import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; 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.JPanel; import javax.swing.JScrollPane; import javax.swing.JSpinner; import javax.swing.JTextPane; import javax.swing.SpinnerNumberModel; import javax.swing.SwingConstants; import javax.swing.border.EtchedBorder; import javax.swing.border.TitledBorder; public class GUI extends JFrame { private JFrame frame1; private JLabel label1; private JPanel panel2; private JPanel panel3; private JLabel label2; private JComboBox<String> boxFood; private JSpinner spinFoodAmt; private JLabel label3; private JComboBox<String> boxPot1; private JSpinner spinPot1Amt; private JLabel label4; private JComboBox<String> boxPot2; private JSpinner spinPot2Amt; private JLabel label5; private JComboBox<String> boxSpec; private JPanel panel4; private JLabel label8; private JSpinner spinHP; private JLabel label10; private JSpinner spinHPDev; private JLabel label9; private JComboBox<String> boxMethod; private JCheckBox lootValuables; private JPanel panel5; private JScrollPane scrollPane1; private JTextPane textPane1; private JButton start; public GUI() { frame1 = new JFrame(); label1 = new JLabel(); panel2 = new JPanel(); panel3 = new JPanel(); label2 = new JLabel(); boxFood = new JComboBox<>(); spinFoodAmt = new JSpinner(); label3 = new JLabel(); boxPot1 = new JComboBox<>(); spinPot1Amt = new JSpinner(); label4 = new JLabel(); boxPot2 = new JComboBox<>(); spinPot2Amt = new JSpinner(); label5 = new JLabel(); boxSpec = new JComboBox<>(); panel4 = new JPanel(); label8 = new JLabel(); spinHP = new JSpinner(); label10 = new JLabel(); spinHPDev = new JSpinner(); label9 = new JLabel(); boxMethod = new JComboBox<>(); lootValuables = new JCheckBox(); panel5 = new JPanel(); scrollPane1 = new JScrollPane(); textPane1 = new JTextPane(); start = new JButton(); // ======== frame1 ======== { frame1.setTitle("ikkDefenders Setup"); frame1.setVisible(true); setDefaultCloseOperation(3); // frame1.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame1.setAlwaysOnTop(false); frame1.setResizable(false); Container frame1ContentPane = frame1.getContentPane(); frame1ContentPane.setLayout(null); // ---- label1 ---- label1.setText("- ikkDefenders -"); label1.setFont(new Font("Arial", Font.PLAIN, 16)); label1.setHorizontalAlignment(SwingConstants.CENTER); frame1ContentPane.add(label1); label1.setBounds(new Rectangle(new Point(215, 5), label1.getPreferredSize())); // ======== panel2 ======== { // JFormDesigner evaluation mark panel2.setBorder(new javax.swing.border.CompoundBorder( new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0), "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red), panel2.getBorder())); panel2.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); panel2.setLayout(null); // ======== panel3 ======== { panel3.setBorder(new TitledBorder(null, "Bank Settings", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, new Font("Arial", Font.PLAIN, 13))); panel3.setFont(new Font("Eras Light ITC", Font.BOLD, 16)); panel3.setLayout(null); // ---- label2 ---- label2.setText("Food:"); panel3.add(label2); label2.setBounds(new Rectangle(new Point(9, 22), label2.getPreferredSize())); // ---- boxFood ---- boxFood.setModel(new DefaultComboBoxModel<>( new String[] { "Trout", "Lobster", "Swordfish", "Monkfish", "Shark" })); boxFood.setSelectedIndex(1); panel3.add(boxFood); boxFood.setBounds(new Rectangle(new Point(55, 19), boxFood.getPreferredSize())); // ---- spinFoodAmt ---- spinFoodAmt.setModel(new SpinnerNumberModel(15, null, 20, 1)); spinFoodAmt.setMinimumSize(new Dimension(21, 22)); panel3.add(spinFoodAmt); spinFoodAmt.setBounds(205, 19, 49, spinFoodAmt.getPreferredSize().height); // ---- label3 ---- label3.setText("Potion:"); panel3.add(label3); label3.setBounds(new Rectangle(new Point(6, 54), label3.getPreferredSize())); // ---- boxPot1 ---- boxPot1.setModel(new DefaultComboBoxModel<>(new String[] { "None", "Super attack", "Super strength", "Attack potion", "Strength potion" })); panel3.add(boxPot1); boxPot1.setBounds(new Rectangle(new Point(55, 51), boxPot1.getPreferredSize())); panel3.add(spinPot1Amt); spinPot1Amt.setBounds(205, 51, 49, spinPot1Amt.getPreferredSize().height); // ---- label4 ---- label4.setText("Potion:"); panel3.add(label4); label4.setBounds(new Rectangle(new Point(6, 86), label4.getPreferredSize())); // ---- boxPot2 ---- boxPot2.setModel(new DefaultComboBoxModel<>(new String[] { "None", "Super attack", "Super strength", "Attack potion", "Strength potion" })); // boxPot2.setSelectedIndex(1); panel3.add(boxPot2); boxPot2.setBounds(new Rectangle(new Point(55, 83), boxPot2.getPreferredSize())); panel3.add(spinPot2Amt); spinPot2Amt.setBounds(205, 83, 49, spinPot2Amt.getPreferredSize().height); // ---- label5 ---- label5.setText("Spec:"); panel3.add(label5); label5.setBounds(new Rectangle(new Point(9, 120), label5.getPreferredSize())); // ---- boxSpec ---- boxSpec.setModel(new DefaultComboBoxModel<>(new String[] { "None", "Dragon dagger(p++)", "Dragon scimitar", "Abyssal whip", "Dragon battleaxe", "Dragon longsword", "Excalibur", "Saradomin sword", "Armadyl godsword", "Saradomin godsword" })); panel3.add(boxSpec); boxSpec.setBounds(new Rectangle(new Point(55, 117), boxSpec.getPreferredSize())); { // 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); } } panel2.add(panel3); panel3.setBounds(0, 0, 270, 160); // ======== panel4 ======== { panel4.setBorder(new TitledBorder(null, "Misc Settings", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, new Font("Arial", Font.PLAIN, 13))); panel4.setLayout(null); // ---- label8 ---- label8.setText("Eat HP:"); panel4.add(label8); label8.setBounds(new Rectangle(new Point(14, 28), label8.getPreferredSize())); // ---- spinHP ---- spinHP.setModel(new SpinnerNumberModel(30, 20, null, 1)); panel4.add(spinHP); spinHP.setBounds(new Rectangle(new Point(80, 25), spinHP.getPreferredSize())); // ---- label10 ---- label10.setText("+/-"); panel4.add(label10); label10.setBounds(new Rectangle(new Point(150, 28), label10.getPreferredSize())); // ---- spinHPDev ---- spinHPDev.setModel(new SpinnerNumberModel(4, 1, 8, 1)); panel4.add(spinHPDev); spinHPDev.setBounds(new Rectangle(new Point(175, 25), spinHPDev.getPreferredSize())); // ---- label9 ---- label9.setText("Method:"); panel4.add(label9); label9.setBounds(new Rectangle(new Point(11, 71), label9.getPreferredSize())); // ---- boxMethod ---- boxMethod.setModel(new DefaultComboBoxModel<>(new String[] { "Tokens", "Defenders" })); panel4.add(boxMethod); boxMethod.setBounds(69, 68, 131, boxMethod.getPreferredSize().height); // ---- lootValuables ---- lootValuables.setText("Loot Valuables"); panel4.add(lootValuables); lootValuables.setBounds(new Rectangle(new Point(60, 110), lootValuables.getPreferredSize())); { // 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); } } panel2.add(panel4); panel4.setBounds(280, 0, 240, 160); { // 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); } } frame1ContentPane.add(panel2); panel2.setBounds(10, 25, 520, 165); // ======== panel5 ======== { panel5.setLayout(null); // ======== scrollPane1 ======== { scrollPane1.setBorder(null); // ---- textPane1 ---- textPane1.setText( "Welcome to ikkDefenders! It is recommended to begin the script in the Warrior's Guild Bank. If using Token Method, have your desired armour set in your inventory. If using Defenders Method, have your highest defender in your inventory. Please let me know how the script is working, enjoy!"); textPane1.setFont(new Font("Arial", Font.PLAIN, 14)); textPane1.setBorder(new EtchedBorder()); scrollPane1.setViewportView(textPane1); } panel5.add(scrollPane1); scrollPane1.setBounds(0, 0, 520, 70); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < panel5.getComponentCount(); i++) { Rectangle bounds = panel5.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 = panel5.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; panel5.setMinimumSize(preferredSize); panel5.setPreferredSize(preferredSize); } } frame1ContentPane.add(panel5); panel5.setBounds(10, 195, 520, 70); // ---- start ---- start.setText("Start"); start.setFont(new Font("Arial", Font.BOLD, 13)); frame1ContentPane.add(start); start.setBounds(230, 270, 88, start.getPreferredSize().height); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < frame1ContentPane.getComponentCount(); i++) { Rectangle bounds = frame1ContentPane.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 = frame1ContentPane.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; frame1ContentPane.setMinimumSize(preferredSize); frame1ContentPane.setPreferredSize(preferredSize); } frame1.pack(); frame1.setLocationRelativeTo(frame1.getOwner()); // setLocationRelativeTo(null); start.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO: Add Config.foodType // Config.enableEating = eat.isSelected(); Config.foodName = boxFood.getSelectedItem().toString(); Config.foodAmt = (int) GUI.this.spinFoodAmt.getValue(); Config.hpBase = (int) GUI.this.spinHP.getValue(); Config.hpDiff = (int) GUI.this.spinHPDev.getValue(); Config.enableLooting = lootValuables.isSelected(); Config.methodGoal = boxMethod.getSelectedItem().toString(); Config.enableSpec = (!boxSpec.getSelectedItem().equals("None")); Config.specWeapon = boxSpec.getSelectedItem().toString(); Config.enableAttPot = (GUI.this.boxPot1.getSelectedItem().equals("Attack potion") || GUI.this.boxPot2.getSelectedItem().equals("Attack potion")); if (Config.enableAttPot) { if (GUI.this.boxPot1.getSelectedItem().equals("Attack potion")) { Config.attAmt = (int) GUI.this.spinPot1Amt.getValue(); } else if (GUI.this.boxPot2.getSelectedItem().equals("Attack potion")) { Config.attAmt = (int) GUI.this.spinPot2Amt.getValue(); } } Config.enableStrPot = (GUI.this.boxPot1.getSelectedItem().equals("Strength potion") || GUI.this.boxPot2.getSelectedItem().equals("Strength potion")); if (Config.enableStrPot) { if (GUI.this.boxPot1.getSelectedItem().equals("Strength potion")) { Config.strAmt = (int) GUI.this.spinPot1Amt.getValue(); } else if (GUI.this.boxPot2.getSelectedItem().equals("Strength potion")) { Config.strAmt = (int) GUI.this.spinPot2Amt.getValue(); } } Config.enableSupAttPot = (GUI.this.boxPot1.getSelectedItem().equals("Super attack") || GUI.this.boxPot2.getSelectedItem().equals("Super attack")); if (Config.enableSupAttPot) { if (GUI.this.boxPot1.getSelectedItem().equals("Super attack")) { Config.supAttAmt = (int) GUI.this.spinPot1Amt.getValue(); } else if (GUI.this.boxPot2.getSelectedItem().equals("Super attack")) { Config.supAttAmt = (int) GUI.this.spinPot2Amt.getValue(); } } Config.enableSupStrPot = (GUI.this.boxPot1.getSelectedItem().equals("Super strength") || GUI.this.boxPot2.getSelectedItem().equals("Super strength")); if (Config.enableSupStrPot) { if (GUI.this.boxPot1.getSelectedItem().equals("Super strength")) { Config.supStrAmt = (int) GUI.this.spinPot1Amt.getValue(); } else if (GUI.this.boxPot2.getSelectedItem().equals("Super strength")) { Config.supStrAmt = (int) GUI.this.spinPot2Amt.getValue(); } } ikkDefenders.run = true; GUI.this.dispose(); } }); } // JFormDesigner - End of component initialization // //GEN-END:initComponents } } Screenshot (if relevant): How I'm initializing the GUI: GUI g; log("Loading GUI"); this.g = new GUI(); Any help would be greatly appreciated Edited February 3, 2016 by ikk Quote Link to comment Share on other sites More sharing options...
Alek Posted February 3, 2016 Share Posted February 3, 2016 What errors are you getting in console? Edit: Pretty sure it's going to tell you there was a packing error, sometimes happens when you have containers too close together with look and feel. Quote Link to comment Share on other sites More sharing options...
Ericthecmh Posted February 3, 2016 Share Posted February 3, 2016 Something you can try (since when OSBot locks it's impossible to interact with it's GUI), start from the command line (using java -jar), and then in the OSBot loader turn on debug (default port should work fine). This will cause any exceptions to print into command line, which is a lot easier to track. You can also force quit OSBot directly using Ctrl-C. Quote Link to comment Share on other sites More sharing options...
itzDot Posted February 3, 2016 Share Posted February 3, 2016 What gui builder are u using? Quote Link to comment Share on other sites More sharing options...