TechTaco 23 Share Posted June 19, 2016 Hello, my script is starting like it should be, but upon doing so, a sort of minimized window with no content upon expansion pops up (my gui) and I have absolutely no idea why it isn't displaying anything. Here is my code, hopefully you can help out. /* * Created by JFormDesigner on Sat Jun 18 19:58:17 EDT 2016 */ package me.tacos1223.xWoodFletcher; import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * @[member='Authorities'] Tyler Caudy */ public class theGUI extends JFrame { private Main ctx; public theGUI(Main main) { this.ctx = main; initComponents(); } private void startButtonActionPerformed(ActionEvent e) { ctx.setStartScript(true); this.setVisible(false); } private void initComponents() { xWoodFletcher = new JPanel(); label1 = new JLabel(); label2 = new JLabel(); cutCombo = new JComboBox<>(); makeCombo = new JComboBox<>(); label3 = new JLabel(); label4 = new JLabel(); startButton = new JButton(); //======== xWoodFletcher ======== { xWoodFletcher.setMinimumSize(new Dimension(400, 400)); xWoodFletcher.setPreferredSize(new Dimension(400, 300)); // JFormDesigner evaluation mark xWoodFletcher.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), xWoodFletcher.getBorder())); xWoodFletcher.addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}}); xWoodFletcher.setLayout(null); //---- label1 ---- label1.setText("xWoodFletcher"); label1.setHorizontalAlignment(SwingConstants.CENTER); label1.setFont(new Font("Verdana", Font.BOLD, 20)); label1.setForeground(Color.blue); xWoodFletcher.add(label1); label1.setBounds(new Rectangle(new Point(120, 20), label1.getPreferredSize())); //---- label2 ---- label2.setText("by tacos1223"); label2.setHorizontalAlignment(SwingConstants.CENTER); xWoodFletcher.add(label2); label2.setBounds(165, 45, label2.getPreferredSize().width, 16); //---- cutCombo ---- cutCombo.setModel(new DefaultComboBoxModel<>(new String[] { "Tree", "Oak", "Willow", "Yew", "Magic" })); xWoodFletcher.add(cutCombo); cutCombo.setBounds(15, 135, 150, 40); //---- makeCombo ---- makeCombo.setModel(new DefaultComboBoxModel<>(new String[] { "Shortbow", "Longbow" })); xWoodFletcher.add(makeCombo); makeCombo.setBounds(235, 135, 151, 40); //---- label3 ---- label3.setText("Tree to cut"); label3.setHorizontalAlignment(SwingConstants.CENTER); xWoodFletcher.add(label3); label3.setBounds(20, 120, 140, 15); //---- label4 ---- label4.setText("What to make"); label4.setHorizontalAlignment(SwingConstants.CENTER); xWoodFletcher.add(label4); label4.setBounds(245, 115, 135, 20); //---- startButton ---- startButton.setText("Start!"); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { startButtonActionPerformed(e); } }); xWoodFletcher.add(startButton); startButton.setBounds(130, 205, 150, 59); { // compute preferred size Dimension preferredSize = new Dimension(); for(int i = 0; i < xWoodFletcher.getComponentCount(); i++) { Rectangle bounds = xWoodFletcher.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 = xWoodFletcher.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; xWoodFletcher.setMinimumSize(preferredSize); xWoodFletcher.setPreferredSize(preferredSize); } } // JFormDesigner - End of component initialization //GEN-END:initComponents } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // Generated using JFormDesigner Evaluation license - Tyler Caudy private JPanel xWoodFletcher; private JLabel label1; private JLabel label2; private JComboBox<String> cutCombo; private JComboBox<String> makeCombo; private JLabel label3; private JLabel label4; private JButton startButton; // JFormDesigner - End of variables declaration //GEN-END:variables public String treeToCut() { return cutCombo.getSelectedItem().toString(); } public String whatToMake() { return makeCombo.getSelectedItem().toString(); } } package me.tacos1223.xWoodFletcher; import org.dreambot.api.methods.Calculations; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; @ScriptManifest(author = "tacos1223", category = Category.MISC, name = "xWoodFletcher", version = 1) public class Main extends AbstractScript { private String logType; private String conditionType; private int state; private boolean startScript; private theGUI gui; public void setStartScript(boolean startScript) { this.startScript = startScript; } public void onStart() { state = 0; gui = new theGUI(this); gui.setVisible(true); gui.setLocationRelativeTo(null); } public void onEnd() { } @Override public int onLoop() { //state 0 = cut //state 1 = make //state 2 = drop logType = gui.treeToCut(); conditionType = gui.whatToMake(); if(startScript == true) { if(state == 0) { } else if(state == 1) { } else if(state == 2) { } else { } } return Calculations.random(500, 600); } } Link to comment Share on other sites More sharing options...
Dreamlicker 750 Share Posted June 19, 2016 o Link to comment Share on other sites More sharing options...
Hopewelljnj 46 Share Posted June 19, 2016 Sorry forgot to post in here. This was solved. His gui was missing a main function including a run function. Link to comment Share on other sites More sharing options...
Cardozz 46 Share Posted June 19, 2016 What is "ctx"? seen it popup all over the forums lol. Link to comment Share on other sites More sharing options...
TechTaco 23 Author Share Posted June 19, 2016 Sorry forgot to post in here. This was solved. His gui was missing a main function including a run function. It wasn't solved. The run function you gave me actually made it display nothing instead of the small window I was getting. What is "ctx"? seen it popup all over the forums lol. ctx or context is an instance so you can access the main class from lets say, the gui class. Never mind everyone, I was able to fiddle with stuff and fix it myself. There are a few things that might of made it work, one being I used an application window, I didn't extend JFrame from the class but instead used a private method for accessing JFrame, and I also used a preferred size for the GUI. Link to comment Share on other sites More sharing options...
Mad 86 Share Posted June 20, 2016 It wasn't solved. The run function you gave me actually made it display nothing instead of the small window I was getting. ctx or context is an instance so you can access the main class from lets say, the gui class. Never mind everyone, I was able to fiddle with stuff and fix it myself. There are a few things that might of made it work, one being I used an application window, I didn't extend JFrame from the class but instead used a private method for accessing JFrame, and I also used a preferred size for the GUI. ctx is basically a context that returns an instance to AbstractScript which contains all the API methods Link to comment Share on other sites More sharing options...
TechTaco 23 Author Share Posted June 20, 2016 ctx is basically a context that returns an instance to AbstractScript which contains all the API methods Is there a way to mark this as solved? I forgot to do that. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.