Hello to all, I have following simple Applet program. import java.applet.*; import java.awt.*; public class myapp1 extends Applet { Label l1, l2, l3, l4; TextField t1; TextArea t2; Checkbox c1,c2,c3,c4,c5,c6; CheckboxGroup cg; Button b; public void init() { l1=new Label("Enter your name: ", Label.RIGHT); t1=new TextField(20); l4= new Label("Enter your gender: "); cg=new CheckboxGroup(); c5=new Checkbox("Male",cg,true); c6=new Checkbox("Female",cg,false); l2=new Label ("About Workshop: "); c1=new Checkbox("Timely Completion"); c2=new Checkbox("Excellent Resourse Persons", true); c2.setEnabled(false); c3=c1=new Checkbox("Good Food"); c1=new Checkbox("Excellent Hospitality"); l3=new Label("Any other comment:"); t2=new TextArea(10,20); b=new Button("OK"); b.setForeground(Color.blue); add(l1); add(t1); add(l4); add(c5); add(c6); add(l2); add(c1); add(c2); add(c3); add(c4); add(l3); add(t2); add(b); …

Member Avatar
Member Avatar
+0 forum 2

Hello, I am trying to create an MDI application and am having problems with one of the frames. Walking through the errors, the first error points to a list generated by Netbeans code that I think is the null problem. When I look further down the error list, I get to code that I have added in the main frame of the MDI. I was thinking I need to initialize this list from the MonthlyBudgetUI Frame in the MainFrame (at MainFram.<int>). But what I have tried isn't working. I have googled this error message and it seems initiliazing whatever is …

Member Avatar
Member Avatar
+0 forum 3

I am new to Java, and I have been trying to get an assignment coded and keep gettin java.lang.NullPointerException in Main Class.java:39. Ok, no prob. Unfortunately I can't quite get this fixed. Any suggestions? I'm using Eclipse Juno. Also, any suggestions on any books, sites, etc that review java in layman's terms would be greatly appreciated. Main import javax.swing.JOptionPane; public class Main_Class { public static void main(String[] args) { //declare variables and make objects String inputVal; Employee newEmployee1 = new Employee(); Benefit benefit1 = new Benefit("Cigna", 25000, 10); Salaried salary1 = new Salaried(1); //Introduction message System.out.println("Welcome to the Employee Lab"); …

Member Avatar
Member Avatar
+0 forum 4

This code works perfectly fine when I run it as a class file (the font is located in the same directory) - however when I package it into a JAR file it can't find the font and the program crashes. The font is definitely being included in the JAR archive, so I suspect I'm not using the correct syntax to point to it. How would I modify this so that it works in both cases? [CODE] // Text area font try { // Determine the font file path String path = System.getProperty("java.class.path"); String fileseparator = System.getProperty("file.separator"); int pathlength = path.length(); …

Member Avatar
Member Avatar
+0 forum 8

I can't figure out why I get the NullPointerException on Line 223. Would appreciate any help whatsoever. Sorry about the spacing below. Some of the code appears messy. Toggle Plain Text and it should look better. [CODE]/* Section 1: Import Statements. Imports the Scanner class and the IO Package. */ import java.util.Scanner; import java.io.*; /* Section 2: Class ReadFiles, contains the methods to open, read and close all the files to be read by the program. */ class ReadFiles { String [] codes = new String[99]; String [] description = new String[99]; int [] pricesAndTax = new int[99]; int [] …

Member Avatar
Member Avatar
+0 forum 2

run: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at com.sun.java.swing.plaf.nimbus.NimbusStyle.init(NimbusStyle.java:418) at com.sun.java.swing.plaf.nimbus.NimbusStyle.validate(NimbusStyle.java:359) at com.sun.java.swing.plaf.nimbus.NimbusStyle.getValues(NimbusStyle.java:927) at com.sun.java.swing.plaf.nimbus.NimbusStyle.getInsets(NimbusStyle.java:605) at javax.swing.plaf.synth.SynthStyle.installDefaults(SynthStyle.java:896) at javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(SynthLookAndFeel.java:275) at javax.swing.plaf.synth.SynthLabelUI.updateStyle(SynthLabelUI.java:53) at javax.swing.plaf.synth.SynthLabelUI.propertyChange(SynthLabelUI.java:232) at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339) at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276) at java.awt.Component.firePropertyChange(Component.java:8128) at java.awt.Component.setName(Component.java:935) at javax.swing.plaf.synth.SynthComboBoxUI$SynthComboBoxRenderer.getListCellRendererComponent(SynthComboBoxUI.java:409) at javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize(BasicComboBoxUI.java:1334) at javax.swing.plaf.basic.BasicComboBoxUI.getMinimumSize(BasicComboBoxUI.java:903) at javax.swing.plaf.basic.BasicComboBoxUI.getPreferredSize(BasicComboBoxUI.java:892) at javax.swing.JComponent.getPreferredSize(JComponent.java:1634) at javax.swing.GroupLayout$ComponentSpring.calculateNonlinkedPreferredSize(GroupLayout.java:2944) at javax.swing.GroupLayout$ComponentSpring.calculateNonlinkedMinimumSize(GroupLayout.java:2930) at javax.swing.GroupLayout$ComponentSpring.calculateMinimumSize(GroupLayout.java:2897) at javax.swing.GroupLayout$Spring.getMinimumSize(GroupLayout.java:1315) at javax.swing.GroupLayout$ComponentSpring.calculatePreferredSize(GroupLayout.java:2904) at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325) at javax.swing.GroupLayout$ComponentSpring.getBaseline(GroupLayout.java:2998) at javax.swing.GroupLayout$BaselineGroup.calculateBaselineAndResizeBehavior(GroupLayout.java:2657) at javax.swing.GroupLayout$BaselineGroup.calculateSize(GroupLayout.java:2633) at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568) at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325) at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604) at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1593) at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568) at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325) at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604) at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1588) at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568) at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325) at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604) at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1588) at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568) at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325) at javax.swing.GroupLayout$SequentialGroup.setValidSize(GroupLayout.java:1972) at javax.swing.GroupLayout$Group.setSize(GroupLayout.java:1553) at javax.swing.GroupLayout.calculateAutopadding(GroupLayout.java:1058) at javax.swing.GroupLayout.layoutContainer(GroupLayout.java:899) at java.awt.Container.layout(Container.java:1421) at java.awt.Container.doLayout(Container.java:1410) at java.awt.Container.validateTree(Container.java:1507) …

Member Avatar
Member Avatar
+0 forum 11

I'm trying to run a simple servlet that counts the number of times a user visits the page using cookies but I'm getting the following error. I thought that NullPointerException was because there were no cookies at all in the browser. But after checking I found a couple of cookies existing. This is the error I'm getting. HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception java.lang.NullPointerException PageCount.doGet(PageCount.java:24) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 …

Member Avatar
Member Avatar
+0 forum 1

Can anyone please help me out in removing this error Exception in thread "main" java.lang.NullPointerException at java.awt.Container.addImpl(Container.java:1045) at java.awt.Container.add(Container.java:365) at Client.<init>(Client.java:33) at Client.main(Client.java:17) [CODE=java] import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; public class Client { JFrame frame1; JList list; JList list1; JTextField tf; JButton send; JButton lout; JLabel label; JScrollPane scrollpane; JScrollPane scrollpane1; public static void main(String args[]) { Client myclient = new Client(); } public Client() { frame1 = new JFrame("Client"); tf=new JTextField(); send=new JButton("Send"); lout=new JButton("Logout"); label=new JLabel("Message"); JPanel panel = new JPanel(); panel.add(label); panel.add(tf); panel.add(label); panel.add(send); panel.add(lout); panel.add(scrollpane1); panel.add(scrollpane); label.setBounds(10,320,80,30); tf.setBounds(10,350,220,50); send.setBounds(260,350,90,20); lout.setBounds(260,375,90,20); scrollpane.setBounds(10,20,220,300); …

Member Avatar
Member Avatar
+0 forum 2

While running basic HelloWorld program using JSAPI, it is showing error "java.lang.NullPointerException at HelloWorld.main(HelloWorld.java:11)" Following is the code: [CODE]import javax.speech.*; import javax.speech.synthesis.*; import java.util.Locale; public class HelloWorld { public static void main(String args[]) { try { // Create a synthesizer for English Synthesizer synth = Central.createSynthesizer(new SynthesizerModeDesc(Locale.ENGLISH)); // Get it ready to speak synth.allocate(); synth.resume(); // Speak the "Hello world" string synth.speakPlainText("Hello, world!", null); // Wait till speaking is done synth.waitEngineState(Synthesizer.QUEUE_EMPTY); // Clean up synth.deallocate(); } catch (Exception e) { e.printStackTrace(); } } } [/CODE] I edit my program: [CODE]import javax.speech.*; import javax.speech.synthesis.*; import java.util.Locale; public class HelloWorld { public …

Member Avatar
+0 forum 0

I am working on may code and I received a null pointer error , how do I fix this? all I wanted to do was remove the selected array here's my code [CODE] import java.util.Scanner; public class Game { public static void main(String args[]){ Scanner input = new Scanner( System.in ); Briefcase briefcase[] = new Briefcase[11]; double amounts[] = {0,100,200,300,400,500,600,700,800,900,1000,25000}; for(int i = 0; i<11 ; i++){ briefcase[i] = new Briefcase(); double value = amounts[i]; briefcase[i].setAmount(value); briefcase[i].setFace(i); } for(int a = 1 ;a<11; a++){ System.out.print("\t "+briefcase[a].getFace()+" "); if(a%5==0){ System.out.println(); } } System.out.print("\tPlease Chose your Case! : "); int nUser = …

Member Avatar
Member Avatar
+0 forum 11

I need to make 45 objects of a nested class within my main class. I have tried instantiating the objects inside the main class' data fields and then inside of its default constructor. After being instantiated, i need to add 15 of the objects to 15 more arrays (each object in three different arrays), and reference them in a nested classes and the main method. As a result, instantiating and adding them to the arrays cannot be performed in the main method as they would not be able to be referenced in nested classes if they are made at runtime. …

Member Avatar
Member Avatar
+0 forum 1

how to implement the game called entanglement in java ??

Member Avatar
Member Avatar
+0 forum 8

I have two classes. The first class is called [ICODE]EmployeePayRoll.java[/ICODE] (this compiles fine) and the second is called [ICODE]TestEmployeePayRoll.java[/ICODE] (this does not compile). The trouble I'm having is that I'm trying to pass in methods as parameters when I instantiate my objects in the main method of the test class. I've tried a bunch of different things and I just get errors. I've had static/non-static related errors, null pointer errors, etc... I've got some tweaks I'm going to make when I get the test class to compile but this is holding me up. Any advice or suggestions would be appreciated. …

Member Avatar
Member Avatar
+0 forum 5

Hello all I am using reading a config file in which there is a entry [CODE]code_list="515,522,560,000" [/CODE] while i am reading this string in my java application and using split on it and then assigning it to a string[].it is giving null pointer exception.needed code is as follows [CODE] static String[] splittArray=null; code_req=properties.getProperty("code_list"); if (code_req != null || !code_req.equalsIgnoreCase("")) { splittArray=code_req.split(","); System.out.println(code_req + " code request and splittarray" + splittArray); } [/CODE] output comes as follows Reading configuration file :: ./config.cfg "515,522,560,000" code request and splittarray[Ljava.lang.String;@a981ca This exception is caught READ CONFIG FILE :: java.lang.NullPointerException

Member Avatar
Member Avatar
+0 forum 6

Hello all can anybody tell me why i am getting null pointer exception. [CODE] String mesg=""; try { URL u = new URL(strOp); BufferedReader r = new BufferedReader(new InputStreamReader( u.openStream())); String s=""; while((s=r.readLine())!=null) System.out.println(s); if(s.equals("SUCCESS")) mesg = mesg+"Your Request has been Processed.you will be intimated by a sms soon"; else mesg = mesg.concat("Service is not available.Please try later"); } [/CODE] when i print the value of s it is giving "SUCCESS".But when assigning the string to mesg it is giving nullpointerexception

Member Avatar
Member Avatar
+0 forum 6

Help with DOM.I am trying to access the nodes acc. to their levels in an xml file.reached upto 3-4 levels then getting a nullpointer exception.Please help...wat datastructure would better suit this.i need to index all the nodes.the xml file is cs.xml given under and the java code below tht. <department> <deptname>Computer Sciences</deptname> <gradstudent> <name> <lastname>Aboulnaga</lastname> <firstname>Ashraf</firstname> </name> <phone>2626623</phone> <email>ashraf@cs.wisc.edu</email> <address> <city>Madison</city> <state>WI</state> <zip>53705</zip> </address> <office>7360</office> <url>www.cs.wisc.edu/~ashraf</url> <gpa>4.0</gpa> </gradstudent> <gradstudent> <name> <lastname>Ailamaki</lastname> <firstname>Anastasia</firstname> </name> <phone>2652311</phone> <email>natassa@cs.wisc.edu</email> <address> <city>Madison</city> <state>WI</state> <zip>53706</zip> </address> <address> <city>Madison</city> <state>WI</state> <zip>53706</zip> </address> <office>7351</office> <url>www.cs.wisc.edu/~natassa</url> <gpa>4.0</gpa> </gradstudent> </department> import org.w3c.dom.*; import org.w3c.dom.Element.*; import javax.xml.parsers.*; import java.io.*; import org.xml.sax.*; …

Member Avatar
Member Avatar
+0 forum 1

I keep getting a null pointer on this assignment and I figure that I can't fix it because my logic is deeply flawed somewhere. Here is the code that I have: [CODE] import java.util.*; import java.io.*; public class Project1 { public static class MapPoint { private String elevation; private String lattitude; private String longitude; public MapPoint() { elevation = ""; lattitude = ""; longitude = ""; } //set public void setElevation(String s) { elevation = s; } public void setLattitude(String s) { lattitude = s; } public void setLongitude(String s) { longitude = s; } //get public String getElevation() { …

Member Avatar
Member Avatar
+0 forum 4

Hi all, this is my codes. [CODE]import java.io.*; public class Testing3 { static double[][] mydouble; static int a, b; static double d; static String[] temp; public static void main(String args[]) throws Exception { try { BufferedReader in = new BufferedReader(new FileReader("C:\\Users\\Serene\\Documents\\Major Project\\Alignment Algorithms\\Testing2.txt")); //reading files in specified directory String str, output=""; while ((str = in.readLine()) != null) //file reading { output += str; temp = str.split(","); for (String s : temp) { d = Double.parseDouble(s); mydouble[a][b] = d; System.out.println(mydouble[a][b]); for(a=0; a<mydouble.length; a++) { for(b=0; b<mydouble[a].length; b++) { System.out.println(mydouble[a][b]); } } } } in.close(); System.out.print(output); }catch( IOException ioException ) {} } …

Member Avatar
Member Avatar
+0 forum 28

Hey guys, im getting a null pointer exception... but i dont know what is wrong. Im trying to get data from a hashmap, and place it in a swing tabel. [CODE=java] ArrayList planes_array[] = null; //planes_array[0] = new ArrayList(); for(int i=0; i<planes.size(); i++) { ArrayList tmp_array = new ArrayList(); tmp_array.add("1"); tmp_array.add("asdfaf"); tmp_array.add("12"); planes_array[i]=null; <--- null pointer on this row planes_array[i]=tmp_array; }[/CODE] Do you guys know what the problem is? or do you need more info? (what info?) Thx

Member Avatar
Member Avatar
+0 forum 21

I am creating a game in which I import images from files to represent characters, etc. I have created a class called Contents which represents anything that can be placed on a tile of the gameboard. A subclass of Contents (by several levels) is Wizard, to create a wizard character. I have it set up so that Contents contains several protected variables whose values are set in Wizard. [CODE] protected Tile currentTile; //The tile of the contents protected final Toolkit tools=Toolkit.getDefaultToolkit(); protected URL url; //url of the image corresponding to the contents protected Image image; //the image itself [/CODE] In …

Member Avatar
Member Avatar
+0 forum 6

I have spent over a WEEK trying to figure out why my code isn't working. It's a long code, I will post it all but I will break down the code as I explain. First off, I have called double[] arrays and then initialized them later on in the program on certain steps. What problem is that even though they are initialized, later on in the code, it's telling me that the double[] I'm requesting is NULL, as if it didn't know that I have already done all that and added elements to it. Here's the program..... [code] package usefulapps; …

Member Avatar
Member Avatar
+0 forum 2

I have to write a JUnit test method for a short program that lets the user add/remove/browse images in a collection. (Adding an image is done with a JFileChooser) The test method that I wrote exhibits some really bizarre behavior; it passes every so often, but fails most of the time and produces the following error message: [iCODE]java.lang.NullPointerException at javax.swing.plaf.basic.BasicListUI.updateLayoutState(Unknown Source) at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(Unknown Source) at javax.swing.plaf.basic.BasicListUI.getCellBounds(Unknown Source) at javax.swing.JList.getCellBounds(Unknown Source) at javax.swing.JList.ensureIndexIsVisible(Unknown Source) at sun.swing.FilePane.ensureIndexIsVisible(Unknown Source) at sun.swing.FilePane.doDirectoryChanged(Unknown Source) at sun.swing.FilePane.propertyChange(Unknown Source) at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) at java.awt.Component.firePropertyChange(Unknown Source) at javax.swing.JFileChooser.setCurrentDirectory(Unknown Source) at javax.swing.JFileChooser.setSelectedFile(Unknown Source) at GalleryPanelTest.testGalleryPanel(GalleryPanelTest.java:35) at …

Member Avatar
Member Avatar
+0 forum 6

Hey guys, I'm creating a Maze class along with a client class where it allows the user to input a direction (U/L/R/D), and then the validity of the move will be returned as well as the new position of the maze. So far, I've got this, but when I try to run it, two nullPointExceptions are thrown and I've tried fixing them but can't seem to understand as to why they're being thrown.. Any help would be appreciated, Ecliptical. [CODE]//Maze.Java //This program creates a maze, and allows the user to attempt to solve it through the client class. // // …

Member Avatar
Member Avatar
+0 forum 1

I'm trying to read a file which contains: Dante Beatrice 3 5 and put them into an array. Then I will assign the values of each member of the array to static variables. when i run the main class of my project, it throws a NullPointerException starting from the line in bold T_T i dunno what to do T_T can anyone please please help me? i badly need this for my project T_T [CODE] public static void loadPositions(){ try{ BufferedReader loadPlayerPositions = new BufferedReader(new FileReader("/media/KEI-SAMA/CS11/JOKE CS11/KnowGoMilestone5/playerpositions.txt")); String info[] = new String[3]; for (int l = 0; l < info.length; l++){ …

Member Avatar
Member Avatar
+0 forum 9

The End.