Jump to content

Exception: AWT-EventQueue-0: java.lang.NullPointerException

- - - - -

  • Please log in to reply
4 replies to this topic

#1
VircoH

VircoH

    Newbie

  • Members
  • Pip
  • 1 posts
The Whole Script is here:
If anyone can tell me what is the problem and can he fix it.


// MAY ONLY BE EDITED WITH PERMISSION FROM VircoH

// COPYRIGHT © VircoH 2011

// IF EDITED OR COPIED WITHOUT MY PERMISSION I HAVE ALL

// THE RIGHTS TO REMOVE IT






import java.awt.Color;

import java.awt.Font;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.Point;

import java.awt.event.KeyEvent;

import java.text.NumberFormat;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.event.*;

import java.awt.Image;

import java.io.IOException;

import java.net.URL;

import javax.imageio.ImageIO;


import org.rsbot.script.wrappers.RSInterface;

import org.rsbot.script.wrappers.*;

import org.rsbot.event.events.MessageEvent;

import org.rsbot.event.listeners.MessageListener;

import org.rsbot.event.listeners.PaintListener;

import org.rsbot.script.Script;

import org.rsbot.script.ScriptManifest;

import org.rsbot.script.wrappers.RSArea;

import org.rsbot.script.wrappers.RSNPC;

import org.rsbot.script.wrappers.RSObject;

import org.rsbot.script.wrappers.RSTile;



@ScriptManifest(authors = { "VircoH" }, keywords = { "Mithril, seeds, flowers, plant, money, cash, making" }, name = "VircoH Planter", version = 1.2, description = ("Start at bank."), website = "http://wrede.webs.com")

public class VircoHPlanter extends Script implements PaintListener, MouseListener, MessageListener {

	



	//AREAS


	public RSArea varrockWestBankArea = new RSArea(new RSTile(3182, 3446), new RSTile(

				3189, 3432));

	

	public RSArea varrockEastBankArea = new RSArea(new RSTile(3250, 3423), new RSTile(

			3257, 3419));

	

	public RSArea lumbridgeBankArea = new RSArea(new RSTile(3210, 3220), new RSTile(

			3207, 3215));

	

	public RSArea seerBankArea = new RSArea(new RSTile(2721, 3493), new RSTile(

			2730, 3490));

	

	public RSArea catherbyBankArea = new RSArea(new RSTile(2806, 3441), new RSTile(

			3812, 3438));

	

	public RSArea faladorWestBankArea = new RSArea(new RSTile(2949, 3368), new RSTile(

			2943, 3373));

	

	public RSArea faladorEastBankArea = new RSArea(new RSTile(3018, 3358), new RSTile(

			3009, 3355));

	

	public RSArea draynorBankArea = new RSArea(new RSTile(3092, 3246), new RSTile(

			3097, 3240));

	

	public RSArea ardougneNorthBankArea = new RSArea(new RSTile(2612, 3335), new RSTile(

			2621, 3332));

	

	public RSArea yanilleBankArea = new RSArea(new RSTile(2613, 3097), new RSTile(

			2609, 3088));

	

	

	

	//Yanille Bank Slots

	public RSArea yanilleBankSlot1 = new RSArea(new RSTile(2613, 3094), new RSTile(

			2612, 3095));

	//2213

	//walking.walkTileMM(new RSTile(2613, 3095));

	

	//Ardougne North Bank Slots

	public RSArea ardougneNorthBankSlot1 = new RSArea(new RSTile(2614, 3332), new RSTile(

			2613, 3333));

	//34752

	//walking.walkTileMM(new RSTile(2614, 3333));

	

	

	//Draynor Bank Slots

	public RSArea draynorBankSlot1 = new RSArea(new RSTile(3092, 3245), new RSTile(

			3093, 3245));

	public RSArea draynorBankSlot2 = new RSArea(new RSTile(3092, 3242), new RSTile(

			3093, 3242));

	public RSArea draynorBankSlot3 = new RSArea(new RSTile(3092, 3240), new RSTile(

			3093, 3240));

	//2012

	//"Use-quickly Counter"

	//Same as Varrock West

	

	//Falador East Bank Slots

	public RSArea faladorEastBankSlot1 = new RSArea(new RSTile(3010, 3355), new RSTile(

			3009, 3355));

	//11758

	//First Tile Here											^^^^^^^^^^

	

	//Falador West Bank Slots

	public RSArea faladorWestBankSlot1 = new RSArea(new RSTile(2945, 3368), new RSTile(

			2943, 3368));

	//11758

	//First Tile Here										^^^^^^^^^^

	

	//Catherby Bank Slots

	public RSArea catherbyBankSlot1 = new RSArea(new RSTile(2807, 3441), new RSTile(

			3808, 3441));

	//2213

	//First Tile Here										^^^^^^^^^^

	

	//Seers Bank Slots

	public RSArea seerBankSlot1 = new RSArea(new RSTile(2721, 3493), new RSTile(

			2722, 3493));

	//25808

	//First Tile Here									^^^^^^^^^^

	

	

	//Lubridge Bank Slots

	public RSArea lumbridgeBankSlot1 = new RSArea(new RSTile(3207, 3220), new RSTile(

			3208, 3220));

	//36786

	//First Tile Here										^^^^^^^^^^

	

	

	//Varrock East Bank Slots

	

	public RSArea VarrockEasBankSlot1 = new RSArea(new RSTile(3251, 3420), new RSTile(

			3250, 3420));

	//Same as Warrock West

	//     ^^^^^^^^^^^^ Second Tile Here

	

	

	//Warrock West Bank Slots

	

	public RSArea varrockWestBankSlot1 = new RSArea(new RSTile(3182, 3444), new RSTile(

			3183, 3444));

	public RSArea varrockWestBankSlot2 = new RSArea(new RSTile(3182, 3442), new RSTile(

			3183, 3442));

	public RSArea varrockWestBankSlot3 = new RSArea(new RSTile(3182, 3440), new RSTile(

			3183, 3440));

	public RSArea varrockWestBankSlot4 = new RSArea(new RSTile(3182, 3438), new RSTile(

			3183, 3438));

	public RSArea varrockWestBankSlot5 = new RSArea(new RSTile(3182, 3436), new RSTile(

			3183, 3436));

	//782

	//^^^^


	//STUFF


	

	private String runtime = "0:0:0";

	String status = "Starting";

	public boolean showPaint = true;

	Rectangle rect = new Rectangle(435, 350, 70, 10);

	Point p;

	long startTime = 0;

	public long startTimeForCalc;

	int tab = 1;

	int times = 0;

	public int profit = 0;

	public int flowers = 0;

	public boolean change = false;

	int bankID;

	int failT = 0;

	

	

	PlanterGUI gui;

	public boolean guiWait = true;

	

	public int mix1F = 2460;

	public int redF = 2462;

	public int blueF = 2464;

	public int yellowF = 2466;

	public int purpleF = 2468;

	public int orangeF = 2470;

	public int mix2F = 2472;

	public int whiteF = 2474;

	public int blackF = 2476;

	public int seeds = 299;

	

	

	

	public int mix1C = 0;

	public int redC = 0;

	public int blueC = 0;

	public int yellowC = 0;

	public int purpleC = 0;

	public int orangeC = 0;

	public int mix2C = 0;

	public int whiteC = 0;

	public int blackC = 0;

	

	public int mix1CC = 0;

	public int redCC = 0;

	public int blueCC = 0;

	public int yellowCC = 0;

	public int purpleCC = 0;

	public int orangeCC = 0;

	public int mix2CC = 0;

	public int whiteCC = 0;

	public int blackCC = 0;

	

	public int mix1FC;

	public int redFC;

	public int blueFC;

	public int yellowFC;

	public int purpleFC;

	public int orangeFC;

	public int mix2FC;

	public int whiteFC;

	public int blackFC;


	public int mix1FP;

	public int redFP;

	public int blueFP;

	public int yellowFP;

	public int purpleFP;

	public int orangeFP;

	public int mix2FP;

	public int whiteFP;

	public int blackFP;

	public int seedsP;

	

	public int mix1GC = 0;

	public int redGC = 0;

	public int blueGC = 0;

	public int yellowGC = 0;

	public int purpleGC = 0;

	public int orangeGC = 0;

	public int mix2GC = 0;

	public int whiteGC = 0;

	public int blackGC = 0;

	

	

	

	



	public boolean onStart() {

		

		

		gui = new PlanterGUI();

		gui.setVisible(true);

		while (guiWait) {

			sleep(100);

		}

		

		mix1FP = grandExchange.lookup(mix1F).getGuidePrice();

		redFP = grandExchange.lookup(redF).getGuidePrice();

		blueFP = grandExchange.lookup(blueF).getGuidePrice();

		yellowFP = grandExchange.lookup(yellowF).getGuidePrice();

		purpleFP = grandExchange.lookup(purpleF).getGuidePrice();

		orangeFP = grandExchange.lookup(orangeF).getGuidePrice();

		mix2FP = grandExchange.lookup(mix2F).getGuidePrice();

		whiteFP = grandExchange.lookup(whiteF).getGuidePrice();

		blackFP = grandExchange.lookup(blackF).getGuidePrice();

		seedsP = grandExchange.lookup(seeds).getGuidePrice();

		

		

		mix1FC = mix1FP - seedsP;

		redFC = redFP - seedsP;

		blueFC = blueFP - seedsP;

		yellowFC = yellowFP - seedsP;

		purpleFC = purpleFP - seedsP;

		orangeFC = orangeFP - seedsP;

		mix2FC = mix2FP - seedsP;

		whiteFC = whiteFP - seedsP;

		blackFC = blackFP - seedsP;

		

		

		

		mouse.setSpeed(9);

		keyboard.pressKey((char) KeyEvent.VK_UP);

		sleep(random(1100,1800));

		keyboard.releaseKey((char) KeyEvent.VK_UP);

		startTimeForCalc = System.currentTimeMillis();

		bank1();

		return true;

	}




	public void mouseClicked(MouseEvent e) {

        p = e.getPoint();

        if (rect.contains(p)) {

        	if (tab==1) {

        		tab = 0;

        		showPaint = false;

        	}

        	else if (tab==0) {

        		tab = 1;

        		showPaint = true;

        	}

        }

        

	}



    public void mouseEntered(MouseEvent e) {

    }


    public void mouseExited(MouseEvent e) {

    }


    public void mouseReleased(MouseEvent e) {

    }


    public void mousePressed(MouseEvent e) {

    }


	@Override

 	public void onFinish() {

		 log(Color.RED, "Thanks for using Wrede's Planter");

    }


	public boolean inArea(RSArea area) {

		return area.contains(getMyPlayer().getLocation());

	}


	public boolean isTileLegit(RSTile b) {

		Point z = calc.tileToMinimap(b);

		return z != null;

	}

	


	

	//RUNTIME TIMERS ETC...


	

	

	public void setRuntime(long ms) {

		this.runtime = formatTime((int) ms);

	}


	final NumberFormat NF = NumberFormat.getInstance();


	private boolean doAction;


	private String formatTime(final int milliseconds) {

		if (milliseconds <= 0) {

			return "0:0:0";

		}


		final long t_seconds = milliseconds / 1000;

		final long t_minutes = t_seconds / 60;

		final long t_hours = t_minutes / 60;

		final int seconds = (int) (t_seconds % 60);

		final int minutes = (int) (t_minutes % 60);

		final int hours = (int) (t_hours % 60);

		return NF.format(hours) + ":" + NF.format(minutes) + ":"

				+ NF.format(seconds);

		

		

	}

	

	

	














//VOID(s)


	public void logout() {

		sleep(random(100,200));

		mouse.move(754, 10);

		sleep(random(100,200));

		mouse.click(true);

		sleep(random(100,200));

		mouse.move(637, 406);

		sleep(random(100,200));

		mouse.click(true);

		stopScript();

		

	}



	public void antiBan() {

		mouse.move(random(10, 720),random(10, 490));

		sleep(random(3000, 5000));

	}



		

	

	public void changeBank() {

		

		if(inArea(varrockWestBankArea)) {

		

			if (inArea(varrockWestBankSlot1)){

				walking.walkTileMM(new RSTile(3182, 3442));

			} else if (inArea(varrockWestBankSlot2)){

				walking.walkTileMM(new RSTile(3182, 3440));

			} else if (inArea(varrockWestBankSlot3)){

				walking.walkTileMM(new RSTile(3182, 3438));

			} else if (inArea(varrockWestBankSlot4)){

				walking.walkTileMM(new RSTile(3182, 3436));

			} else if (inArea(varrockWestBankSlot5)){

				walking.walkTileMM(new RSTile(3182, 3444));

				sleep(random(5000,5500));

			}

		} else if (inArea(draynorBankArea)) {

			if (inArea(draynorBankSlot1)){

				walking.walkTileMM(new RSTile(3092, 3242));

			} else if (inArea(draynorBankSlot2)) {

				walking.walkTileMM(new RSTile(3092, 3240));

			} else if (inArea(draynorBankSlot3)) {

				walking.walkTileMM(new RSTile(3092, 3245));

			}

		}

		sleep(random(3000,3500));

		

		change = false;

		

	}

	

	

	

	

	

	public void bank1() {

		status = "Starting";

		

		if (inArea(varrockWestBankArea)) {

			walking.walkTileMM(new RSTile(3182, 3444));

		} else if (inArea(varrockEastBankArea)) {

			walking.walkTileMM(new RSTile(3251, 3420));

		} else if (inArea(lumbridgeBankArea)) {

			walking.walkTileMM(new RSTile(3207, 3220));

		} else if (inArea(seerBankArea)) {

			walking.walkTileMM(new RSTile(2721, 3493));

		} else if (inArea(catherbyBankArea)) {

			walking.walkTileMM(new RSTile(2807, 3441));

		} else if (inArea(faladorWestBankArea)) {

			walking.walkTileMM(new RSTile(2945, 3368));

		} else if (inArea(faladorEastBankArea)) {

			walking.walkTileMM(new RSTile(3010, 3355));

		} else if (inArea(draynorBankArea)) {

			walking.walkTileMM(new RSTile(3092, 3245));

		} else if (inArea(ardougneNorthBankArea)) {

			walking.walkTileMM(new RSTile(2614, 3332));

		} else if (inArea(yanilleBankArea)) {

			walking.walkTileMM(new RSTile(2613, 3094));

		} else {

			stopScript();

		}

		

		sleep(random(2000,2500));

		

		RSObject bankBooth = objects.getNearest(bankID);

		bankBooth.doAction("Use-quickly");

		sleep(random(1800,2000));

		if(bank.isOpen()) {

			bank.depositAllExcept(299);

			sleep(random(100,300));

			bank.close();

		}

		sleep(random(200,300));

		times += 1;

		walkThere();

	}

	

	

	public void walkThere() {

		if (inArea(yanilleBankArea)){

			walking.walkTileMM(new RSTile(2613, 3095));

			sleep(random(900,1000));

		}

		if (inArea(ardougneNorthBankArea)) {

			walking.walkTileMM(new RSTile(2614, 3333));

			sleep(random(900,1000));

		}

	}

	

	

	

	

	

	

	public void calc() {

		

		if (inventory.containsOneOf(mix1F)) {

			mix1C = inventory.getCount(mix1F);

			mix1CC = mix1C * mix1FC;

		}

		if (inventory.containsOneOf(redF)) {

			redC = inventory.getCount(redF);

			redCC = redC * redFC;

		}

		if (inventory.containsOneOf(blueF)) {

			blueC = inventory.getCount(blueF);

			blueCC = blueC * blueFC;

		}

		if (inventory.containsOneOf(yellowF)) {

			yellowC = inventory.getCount(yellowF);

			yellowCC = yellowC * yellowFC;

		}

		if (inventory.containsOneOf(purpleF)) {

			purpleC = inventory.getCount(purpleF);

			purpleCC = purpleC * purpleFC;

		}

		if (inventory.containsOneOf(orangeF)) {

			orangeC = inventory.getCount(orangeF);

			orangeCC = orangeC * orangeFC;

		}

		if (inventory.containsOneOf(mix2F)) {

			mix2C = inventory.getCount(mix2F);

			mix2CC = mix2C * mix2FC;

		}

		if (inventory.containsOneOf(whiteF)) {

			whiteC = inventory.getCount(whiteF);

			whiteCC = whiteC * whiteFC;

		}

		if (inventory.containsOneOf(blackF)) {

			blackC = inventory.getCount(blackF);

			blackCC = blackC * blackFC;

		}

		

		

		

		profit += mix1CC + redCC + blueCC + yellowCC + purpleCC + orangeCC + mix2CC + whiteCC + blackCC;

		

		mix1GC += mix1C;

		redGC += redC;

		blueGC += blueC;

		yellowGC += yellowC;

		purpleGC += purpleC;

		orangeGC += orangeC;

		mix2GC += mix2C;

		whiteGC += whiteC;

		blackGC += blackC;

		

		

		mix1C = 0;

		redC = 0;

		blueC = 0;

		yellowC = 0;

		purpleC = 0;

		orangeC = 0;

		mix2C = 0;

		whiteC = 0;

		blackC = 0;

		

		mix1CC = 0;

		redCC = 0;

		blueCC = 0;

		yellowCC = 0;

		purpleCC = 0;

		orangeCC = 0;

		mix2CC = 0;

		whiteCC = 0;

		blackCC = 0;

		bankIt();

	}

		

		

		

	public void bankIt() {

		if (failT == 5) {

			logout();

		}

		RSObject bankBooth = objects.getNearest(bankID);

		bankBooth.doAction("Use-quickly");

		sleep(random(1900,2100));

		if (bank.isOpen()) {

			bank.depositAll();

			sleep(random(1900,2000));

			bank.withdraw(299, 0);

			sleep(random(100,150));

			bank.close();

			sleep(random(300,400));

		}

			

		if (!inventory.containsOneOf(299)) {

			failT += 1;

			bankIt();

		} else {

			failT = 0;

		}

		walkThere();

	}

	

	

	

	

	@Override

	public void messageReceived(MessageEvent e) {

		String txt = e.getMessage();

		if (txt.contains("can't")) {

			change = true;

			log("Something is blocking us from planting.");

		}

	}

	

	

	


	

//LOOP



	

	@Override

	public int loop() {


		if(inArea(varrockWestBankArea) && change == true) {

			changeBank();

		}

		if(inArea(draynorBankArea) && change == true) {

			changeBank();

		}

			

			if(inventory.containsOneOf(299)) {

				status = "Planting";

				inventory.getItem(299).doClick(true);

				mouse.move(random(70,446), random(399,405));

				sleep(random(1350,1400));

				interfaces.get(236).getComponent(1).doClick(true);

				status = "Picking";

				flowers += 1;

				sleep(random(900,1000));

				if(inventory.isFull()) {

					calc();

				}

			} else if (!inventory.containsOneOf(299)) {

				log("Out of Mithril Seeds, logging out");

				logout();

			}

		return 50;

    }

	




//PAINT


	

	@Override

	public void onRepaint(Graphics g1) {

		Graphics2D g = (Graphics2D) g1;

		

		if (game.isLoggedIn()) {

			if (startTime == 0)

				startTime = System.currentTimeMillis();

		}


		float TT = 0;

		long millis = System.currentTimeMillis() - startTime;

		final long hours = millis / (1000 * 60 * 60);

		millis -= hours * 1000 * 60 * 60;

		final long minutes = millis / (1000 * 60);

		millis -= minutes * 1000 * 60;

		final long seconds = millis / 1000;

		TT = hours * 3600 + minutes * 60 + seconds;


		setRuntime((long) TT * 1000);




		g.setColor(new Color(255,255,255,255));

		g.fillRoundRect(435, 350, 70, 10, 16, 16);

		g.drawRoundRect(435, 350, 70, 10, 16, 16);

		g.setColor(new Color(0,0,0));

		g.drawString("Show/Hide", 440, 360);


		if (showPaint) {




		g.setColor(new Color(0, 0, 0, 175));

		g.fillRoundRect(7, 345, 505, 127, 16, 16);

		g.setColor(new Color(255,255,255,255));

		g.drawRoundRect(7, 345, 505, 127, 16, 16);


		

		g.fillRoundRect(435, 350, 70, 10, 16, 16);

		g.drawRoundRect(435, 350, 70, 10, 16, 16);

		g.setColor(new Color(0,0,0));

		g.drawString("Show/Hide", 440, 360);


		g.setFont(new Font("Sylfaen", 1, 20));

		g.setColor(new Color(255,255,255,255));




		g.drawString("VircoH Planter", 182, 362);

		g.setFont(new Font("Sylfaen", 0, 15));

		


		//line 1

		

		g.drawString("Runtime: " + runtime, 12, 380);


		g.drawString("Flowers Planted: " + flowers, 12,400);


		final int flowersH = (int) ((flowers) * 3600000D / (System

				.currentTimeMillis() - startTimeForCalc));

		g.drawString("Flowers Per Hour: " + flowersH, 12, 420);

		

		g.drawString("Profit: " + profit, 12, 440);

		

		final int profitH = (int) ((profit) * 3600000D / (System

				.currentTimeMillis() - startTimeForCalc));

		g.drawString("Profit Per Hour: " + profitH, 12, 460);

		

		

		

		//Line 2

		

		g.drawString("Status: " + status, 182, 380);

		

		g.drawString("Mix nr 1: " + mix1GC, 182, 400);

		

		g.drawString("Red Flowers: " + redGC, 182, 420);

		

		g.drawString("Blue Flowers: " + blueGC, 182, 440);

		

		g.drawString("Yellow Flowers: " + yellowGC, 182, 460);

		

		

		

		//Line 3

		

		g.drawString("Purple Flowers: " + purpleGC, 352, 380);

		

		g.drawString("Orange Flowers: " + orangeGC, 352, 400);

		

		g.drawString("Mix nr 2: " + mix2GC, 352, 420);

		

		g.drawString("White Flowers: " + whiteGC, 352, 440);

		

		g.drawString("Black Flowers: " + blackGC, 352, 460);

		

		}



		Point mousey = mouse.getLocation();

		int x = (int) mousey.getX();

		int y = (int) mousey.getY();

		if (System.currentTimeMillis() - mouse.getPressTime() < 900)

			g.setColor(new Color(255,10,0,200));

		else

			g.setColor(new Color(255,10,0,200));

		g.drawLine(x,0,x,game.getHeight());

		g.drawLine(0,y,game.getWidth(),y);

		g.fillRect(x-1,y-1,3,3);





    }

	

	

	

	//GUI

	

	public class PlanterGUI extends JFrame {

		public PlanterGUI() {

			initComponents();

		}



		private void button1ActionPerformed(ActionEvent e) {

			startActionPerformed(e);

		}


		private void startActionPerformed(ActionEvent e) {

			if (comboBox1.getSelectedItem().equals("Varrock West")) {

				bankID = 782;

				log("Location: Varrock West");

			} else if (comboBox1.getSelectedItem().equals("Varrock East")) {

				bankID = 782;

				log("Location: Varrock East");

			} else if (comboBox1.getSelectedItem().equals("Lumbridge")) {

				bankID = 36786;

				log("Location: Lumbridge");

			} else if (comboBox1.getSelectedItem().equals("Seers Village")) {

				bankID = 25808;

				log("Location: Seers Village");

			} else if (comboBox1.getSelectedItem().equals("Catherby")) {

				bankID = 2213;

				log("Location: Catherby");

			} else if (comboBox1.getSelectedItem().equals("Falador West")) {

				bankID = 11758;

				log("Location: Falador West");

			} else if (comboBox1.getSelectedItem().equals("Falador East")) {

				bankID = 11758;

				log("Location: Falador East");

			} else if (comboBox1.getSelectedItem().equals("Draynor")) {

				bankID = 2012;

				log("Location: Draynor");

			} else if (comboBox1.getSelectedItem().equals("Ardougne North")) {

				bankID = 34752;

				log("Location: Ardougne North");

			} else if (comboBox1.getSelectedItem().equals("Yanille")) {

				bankID = 2213;

				log("Location: Yanille");

			}



			guiWait = false;

			dispose();

		}



		private void initComponents() {

			label1 = new JLabel();

			label2 = new JLabel();

			button1 = new JButton();

			comboBox1 = new JComboBox();


			//======== dialog1 ========

			{

				setTitle("GUI");

				setResizable(false);

				setAlwaysOnTop(true);

				Container contentPane = getContentPane();

				contentPane.setLayout(null);


				//---- label1 ----

				label1.setText("Select  Location:");

				label1.setFont(new Font("Tahoma", Font.PLAIN, 14));

				contentPane.add(label1);

				label1.setBounds(10, 5, 105, label1.getPreferredSize().height);


				//---- label2 ----

				label2.setText("Made By: VircoH");

				label2.setForeground(Color.red);

				contentPane.add(label2);

				label2.setBounds(40, 120, 85, label2.getPreferredSize().height);


				//---- button1 ----

				button1.setText("Start");

				button1.addActionListener(new ActionListener() {

					@Override

					public void actionPerformed(ActionEvent e) {

						button1ActionPerformed(e);

					}

				});

				contentPane.add(button1);

				button1.setBounds(10, 80, 105, 35);


				//---- comboBox1 ----

				comboBox1.setModel(new DefaultComboBoxModel(new String[] {

					"Varrock West",

					"Varrock East",

					"Lumbridge",

					"Seers Village",

					"Catherby",

					"Falador West",

					"Falador East",

					"Draynor",

					"Ardougne North",

					"Yanille"

				}));

				comboBox1.setMaximumRowCount(10);

				contentPane.add(comboBox1);

				comboBox1.setBounds(10, 40, 105, 25);


				{ // compute preferred size

					Dimension preferredSize = new Dimension();

					for(int i = 0; i < contentPane.getComponentCount(); i++) {

						Rectangle bounds = contentPane.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 = contentPane.getInsets();

					preferredSize.width += insets.right;

					preferredSize.height += insets.bottom;

					contentPane.setMinimumSize(preferredSize);

					contentPane.setPreferredSize(preferredSize);

				}

				pack();

				setLocationRelativeTo(getOwner());

			}

			

		}


		

		private JDialog dialog1;

		private JLabel label1;

		private JLabel label2;

		private JButton button1;

		private JComboBox comboBox1;

	}




	

}

Edited by Roger, 18 July 2011 - 09:03 PM.
added [CODE][/CODE] tags


#2
twinArmageddons

twinArmageddons

    Newbie

  • Members
  • PipPip
  • 24 posts
aww good old NullPointerException

i tried running the code but it seems im missing the "org" library, could you upload it too?

#3
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Hi, Virco.
Please post the full stack trace you get. Thanks.

--
Wim DC

#4
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP

twinArmageddons said:

is that all you do? havent you thought people usually have already googled their problem BEFORE posting it in the forums?


a NullPointerException is pretty self-explanatory, it means java has encountered a Null value where an object is expected, he wants to know WHAT part of his code is throwing that exception

I have never thought that because most of these questions can be answered by a quick google search. (or any other search engine)
I only post these links when I know this is a typical programming problem and can be solved with a little research.


If you want a better answer:
How to trace down the nullpointerexception:
  • Compile Program
  • Run Program
  • Read stack Trace
  • Acquire Line number/classname where nullpointerexception occurred
  • look at what object could contain null on that line or previous line
  • trace this object down and you'll probably see why you're getting a nullpointerexception

Or... if you simply google:

Quote

Exception: AWT-EventQueue-0: java.lang.NullPointerException
You'll find out how to solve your problem within the first 2 results.

Or is it the job of the users on this forum to do all of these steps and provide the answer to the OP?
I call this spoon feeding.

#5
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
We need the full stack trace to help you pinpoint where the problem is.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users