Results 1 to 4 of 4
  1. #1
    Eldest808 is offline Member
    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Default Packaging GUI Issue

    Hi guys i am having trouble understanding how to tell my GUI to start up a loop cycle from a different public class file. I don't know how to best call forth the public class file in another one of my packages.

    https://www.dropbox.com/sh/fgh8kv10ax66nd0/QmDMpDHJc5

    The Following script is just is an example.

    Java Code:
    import java.awt.AlphaComposite;
    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Point;
    import java.awt.RenderingHints;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    
    import org.powerbot.core.event.events.MessageEvent;
    import org.powerbot.core.event.listeners.MessageListener;
    import org.powerbot.core.event.listeners.PaintListener;
    import org.powerbot.game.api.Manifest;
    import org.powerbot.game.api.methods.Game;
    import org.powerbot.game.api.methods.input.Mouse;
    
    import GrasersTasksPackage.VMethods;
    
    @Manifest(authors = ("Graser"), name = "test", description = "", version = 2)
    public class Test extends org.powerbot.core.script.ActiveScript implements PaintListener, MessageListener {
    	static boolean selected;
    	static String clicked;
    	private static boolean guiWait = true;
    	NewJFrame g = new NewJFrame();
    	public long startTime = System.currentTimeMillis();
    	public String status;
    	public long millis;
    	boolean isRunning = false;
    	private static final Color MOUSE_COLOR = new Color(0, 255, 255),MOUSE_BORDER_COLOR = new Color(220, 220, 220),MOUSE_CENTER_COLOR = new Color(89, 255, 89);
    
    	@Override
    	public void messageReceived(MessageEvent arg0) {
    		// TODO Auto-generated method stub
    
    	}
    
    	//START: Code generated using Enfilade's Easel
    
    		private final Color color1 = new Color(0, 0, 0);
    		private final Color color2 = new Color(0, 204, 255);
    		private final Color color3 = new Color(0, 255, 0);
    
    		private final Font font1 = new Font("Cambria", 1, 20);
    		private final Font font2 = new Font("Cambria", 1, 17);
    
    		public void onRepaint(Graphics g1) {
    			Graphics2D g = (Graphics2D)g1;
    			drawMouse(g);
    			long millis = System.currentTimeMillis() - startTime;
    			long hours = millis / (1000 * 60 * 60);
    			millis -= hours * (1000 * 60 * 60); long minutes = millis / (1000 * 60);
    			millis -= minutes * (1000 * 60); long seconds = millis / 1000;
    			g.setColor(color1);
    			g.fillRect(3, 314, 515, 160);
    			g.setColor(color2);
    			g.fillRect(20, 333, 478, 124);
    			g.setFont(font1);
    			g.setColor(color1);
    			g.drawString("Skeleton by Graser", 29, 357);
    			g.drawString("Time running: " +hours + ":" +minutes + ":" +seconds , 30, 402);
    			g.drawString("Status: " +status, 33, 421);
    			g.setFont(font2);
    			g.setColor(color3);
    			g.fillRoundRect(19, 323, 491, 3, 16, 16);
    			g.fillRoundRect(9, 331, 4, 125, 16, 16);
    			g.fillRoundRect(21, 462, 478, 6, 16, 16);
    			g.fillRoundRect(503, 340, 7, 120, 16, 16);
    			g.setColor(color1);
    			Point p = Mouse.getLocation();
    			Dimension d = Game.getDimensions();
    			int w = (int) d.getWidth(), h = (int) d.getHeight();
    			g.setColor(Color.lightGray);
    			g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
    					0.1f));
    			g.fillRect(0, 0, p.x - 1, p.y - 1);
    			g.fillRect(p.x + 1, 0, w - (p.x + 1), p.y - 1);
    			g.fillRect(0, p.y + 1, p.x - 1, h - (p.y - 1));
    			g.fillRect(p.x + 1, p.y + 1, w - (p.x + 1), h - (p.y - 1));
    		}
    
    		//Credits to Member Magic from Rarebot
    		private void drawMouse(Graphics g) {
    			((Graphics2D) g).setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON));
    			Point p = Mouse.getLocation();
    			Graphics2D spinG = (Graphics2D) g.create();
    			Graphics2D spinGRev = (Graphics2D) g.create();
    			Graphics2D spinG2 = (Graphics2D) g.create();
    			spinG.setColor(MOUSE_BORDER_COLOR);
    			spinGRev.setColor(MOUSE_COLOR);
    			spinG.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2* Math.PI / 180.0, p.x, p.y);
    			spinGRev.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d)* 2 * Math.PI / 180.0, p.x, p.y);
    			final int outerSize = 20;
    			final int innerSize = 12;
    			spinG.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
    			spinGRev.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
    			spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize,outerSize, 100, 75);
    			spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize,outerSize, -100, 75);
    			spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2),innerSize, innerSize, 100, 75);
    			spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2),innerSize, innerSize, -100, 75);
    			g.setColor(MOUSE_CENTER_COLOR);
    			g.fillOval(p.x, p.y, 2, 2);
    			spinG2.setColor(MOUSE_CENTER_COLOR);
    			spinG2.rotate(System.currentTimeMillis() % 2000d / 2000d * 360d* Math.PI / 180.0, p.x, p.y);
    			spinG2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
    			spinG2.drawLine(p.x - 5, p.y, p.x + 5, p.y);
    			spinG2.drawLine(p.x, p.y - 5, p.x, p.y + 5);
    		}
    
    	public void onStart(){
    		log.info("Loading...");
    		g.setVisible(true);
    		while(guiWait)
    			Task.sleep(500);
    	}
    
    	public void onStop(){
    		        status="Thank You for using my Script";
    		    }
    
    	@Override
    	public int loop() {
    		VMethods.loot();
    		return -1;
    	}
    	
    	public class TestGui extends Test {
    		
    		@Override
    		public int loop() {
    			VMethods.FirstTasks();
    			return 1;
    		}
    	}
    	
    	public class NewJFrame extends javax.swing.JFrame {
    		private static final long serialVersionUID = 1L;
    		/**
    		 * Creates new form NewJFrame
    		 */
    		public NewJFrame() {
    			initComponents();
    		}
    
    		public void startButtonActionPerformed(ActionEvent e) {
    			clicked = jButton1.toString();
    			guiWait = false;
    			g.dispose();
    		}
    
    		/**
    		 * This method is called from within the constructor to initialize the form.
    		 * WARNING: Do NOT modify this code. The content of this method is always
    		 * regenerated by the Form Editor.
    		 */
    
    		// <editor-fold defaultstate="collapsed" desc="Generated Code">
    		private void initComponents() {
    			jButton1 = new javax.swing.JButton();
    			jCheckBox1 = new javax.swing.JCheckBox();
    
    			setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    
    			jButton1.setText("Start");
    			jButton1.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                    	isRunning = false; // We tell the setup strategy that the GUI is no longer running and should carry on
                        dispose();
                    }
            });
    
    			jCheckBox1.setText("Test");
    			jCheckBox2.setText("atDesertMineingSpot");
    
    			jCheckBox3.setText("atFishingSpot");
    
    			jCheckBox4.setText("atPriestHouse");
    
    			jCheckBox5.setText("atSmithingSpot");
    
    			jCheckBox6.setText("atTanningStore");
    
    			jCheckBox7.setText("atWaterTemple");
    
    			jCheckBox8.setText("nearBeam");
    
    			jCheckBox9.setText("atshed");
    			
    			addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(WindowEvent winEvt) {
                            System.out.println("GUI exited");
                            setVisible(false);
                    }
            });
    
    			javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    			getContentPane().setLayout(layout);
    			layout.setHorizontalGroup(
    					layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    					.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    							.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    							.addComponent(jButton1)
    							.addContainerGap())
    							.addGroup(layout.createSequentialGroup()
    									.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    											.addComponent(jCheckBox1)
    											.addComponent(jCheckBox2)
    											.addComponent(jCheckBox3)
    											.addComponent(jCheckBox4)
    											.addComponent(jCheckBox5)
    											.addComponent(jCheckBox6)
    											.addComponent(jCheckBox7)
    											.addComponent(jCheckBox8)
    											.addComponent(jCheckBox9))
    											.addGap(0, 29, Short.MAX_VALUE))
    					);
    			layout.setVerticalGroup(
    					layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    					.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
    							.addComponent(jCheckBox1)
    							.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    							.addComponent(jCheckBox2)
    							.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    							.addComponent(jCheckBox3)
    							.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    							.addComponent(jCheckBox4)
    							.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    							.addComponent(jCheckBox5)
    							.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    							.addComponent(jCheckBox6)
    							.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    							.addComponent(jCheckBox7)
    							.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    							.addComponent(jCheckBox8)
    							.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    							.addComponent(jCheckBox9)
    							.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
    							.addComponent(jButton1))
    					);
    
    			pack();
    		}// </editor-fold>
    
    		/**
    		 * @param args the command line arguments
    		 */
    		public void main(String args[]) {
    			/* Set the Nimbus look and feel */
    			//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    			/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
    			 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
    			 */
    			try {
    				for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    					if ("Nimbus".equals(info.getName())) {
    						javax.swing.UIManager.setLookAndFeel(info.getClassName());
    						break;
    					}
    				}
    			} catch (ClassNotFoundException ex) {
    				java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    			} catch (InstantiationException ex) {
    				java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    			} catch (IllegalAccessException ex) {
    				java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    			} catch (javax.swing.UnsupportedLookAndFeelException ex) {
    				java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    			}
    			//</editor-fold>
    
    			/* Create and display the form */
    			java.awt.EventQueue.invokeLater(new Runnable() {
    				public void run() {
    					new NewJFrame().setVisible(true);
    				}
    			});
    		}
    		// Variables declaration - do not modify
    		private javax.swing.JButton jButton1;
    		private javax.swing.JCheckBox jCheckBox1;
    		private javax.swing.JCheckBox jCheckBox2;
    		private javax.swing.JCheckBox jCheckBox3;
    		private javax.swing.JCheckBox jCheckBox4;
    		private javax.swing.JCheckBox jCheckBox5;
    		private javax.swing.JCheckBox jCheckBox6;
    		private javax.swing.JCheckBox jCheckBox7;
    		private javax.swing.JCheckBox jCheckBox8;
    		private javax.swing.JCheckBox jCheckBox9;
    		// End of variables declaration
    	}
    
    
    }
    Last edited by Eldest808; 06-04-2013 at 10:09 PM.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,988
    Rep Power
    9

    Default Re: Packaging GUI Issue

    The best advice I can give you is to ditch the GUI builder until you understand what's going on under the hood. That way you can create an SSCCE that demonstrates the problem, since it's pretty hard to tell what's going on in the code you posted. What does it do? What do you want it to do?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Eldest808 is offline Member
    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Default Re: Packaging GUI Issue

    Quote Originally Posted by KevinWorkman View Post
    The best advice I can give you is to ditch the GUI builder until you understand what's going on under the hood. That way you can create an SSCCE that demonstrates the problem, since it's pretty hard to tell what's going on in the code you posted. What does it do? What do you want it to do?
    Basically i have two classes each with there own loop task to perform. How can i tell the GUI to Run one class when the user clicks a Radio Button and then clicks start? I really need help on this.

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,988
    Rep Power
    9

Similar Threads

  1. Packaging program
    By billq in forum New To Java
    Replies: 2
    Last Post: 07-02-2010, 05:05 AM
  2. packaging files
    By ashish9590 in forum AWT / Swing
    Replies: 2
    Last Post: 02-12-2010, 03:01 PM
  3. Rmi+packaging
    By skliz4rel in forum Networking
    Replies: 0
    Last Post: 01-06-2010, 07:56 PM
  4. Best practice for packaging add-ons
    By Goose in forum Advanced Java
    Replies: 2
    Last Post: 08-05-2009, 10:51 PM
  5. Packaging Driver and Applet
    By ibanez270dx in forum New To Java
    Replies: 0
    Last Post: 11-14-2007, 01:18 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •