Results 1 to 20 of 21
- 05-30-2011, 11:21 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
Need help with a lot of code please.
Hey, can anyone see why this class is causing a null pointer exception?
Java Code:package HouseHockey; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.PrintWriter; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class ErrorMessages { JLabel label = new JLabel(); final JFrame frame = new JFrame("Error"); JPanel panel = new JPanel(); JButton Yes1 = new JButton("Yes"); JButton No1 = new JButton("No"); JButton Yes2 = new JButton("Yes"); JButton close = new JButton("Ok"); JButton Yes4 = new JButton("Yes"); JButton No2 = new JButton("No"); String house2; Statistics g; private File file = new File("/Users/eric.manget/Desktop/Scores.txt"); private FileWriter outFile; private PrintWriter out = new PrintWriter(outFile); int martlands = 0; int scaddings = 0; int mchughs = 0; int mowbray = 0; int orrs = 0; int brem = 0; int jacksons = 0; int howards = 0; public ErrorMessages(final JFrame frame2){ panel.add(label); frame.add(panel); frame.setSize(300,65); frame.setVisible(true); frame.setResizable(false); try { out = new PrintWriter(outFile); outFile = new FileWriter(file); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } close.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { frame.dispose(); } }); Yes1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.exit(0); } }); Yes2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { new MainPage(); frame.dispose(); frame2.dispose(); } }); No1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { frame.dispose(); } }); No2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { frame.dispose(); } }); } public void housesSame(){ label.setText("Error: Houses must be different."); panel.add(close); } public void addingplayer(){ label.setText("Error: Player being added is not in team."); frame.setSize(350,65); panel.add(close); } public void unsavedData(){ label.setText("If you exit you will lose all unsaved data. Proceed?"); panel.add(Yes1); panel.add(No1); frame.setSize(390,80); } public void navMain(){ label.setText("If you navigate to main you will lose all unsaved data. Proceed?"); panel.add(Yes2); panel.add(No1); frame.setSize(420,85); } public void notEnoughPlayers(final String house,final String house2){ label.setText("There are not enough players playing for " + house + "." + " Is this a default loss for " + house + "?" ); panel.add(Yes4,BorderLayout.SOUTH); panel.add(No2,BorderLayout.SOUTH); if(house.equals("Orr's")){ frame.setSize(540,100); } else{ frame.setSize(620,100); } Yes4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if(house.equals("Bremner's")){ brem = brem - 2; System.out.println(brem); out.write(brem - 2); out.close(); } if(house.equals("Orr's")){ out.write(orrs - 2); out.close(); } if(house.equals("Scadding's")){ out.write(scaddings - 2); out.close(); } if(house.equals("Mowbray's")){ out.write(mowbray - 2); out.close(); } if(house.equals("Jackson's")){ out.write(jacksons - 2); out.close(); } if(house.equals("Howard's")){ out.write(howards - 2); out.close(); } if(house.equals("McHugh's")){ out.write(mchughs - 2); out.close(); } if(house.equals("Martland's")){ out.write(martlands - 2); out.close(); } if(house2.equals("Bremner's")){ out.write(brem + 2); out.close(); } if(house2.equals("Orr's")){ out.write(orrs + 2); out.close(); } if(house2.equals("Scadding's")){ out.write(scaddings + 2); out.close(); } if(house2.equals("Mowbray's")){ out.write(mowbray + 2); out.close(); } if(house2.equals("Jackson's")){ out.write(jacksons + 2); out.close(); } if(house2.equals("Howard's")){ out.write(howards + 2); out.close(); } if(house2.equals("McHugh's")){ out.write(mchughs + 2); out.close(); } if(house2.equals("Martland's")){ out.write(martlands + 2); out.close(); } } }); } public void noPDF(){ label.setText("Error: PDF not found..." ); panel.add(close); } public Integer getHousePoints(String house) { if (house.equals("Bremner's")) { return brem; } if (house.equals("Scadding's")) { return scaddings; } if (house.equals("Orr's")) { return orrs; } if (house.equals("Jackson's")) { return jacksons; } if (house.equals("Mowbray's")) { return mowbray; } if (house.equals("Howard's")) { return howards; } if (house.equals("McHugh's")) { return mchughs; } if (house.equals("Martland's")) { return martlands; } else { return null; } } }
My next class that is accessing the integers.
Thanks, and can anyone help me with my file IO because it sucks? I am trying to write the house points to a file and then access them and I feel there is a better way but I don't know how.Java Code:package HouseHockey; import java.awt.BorderLayout; import java.awt.Color; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.ArrayList; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.RowFilter; import javax.swing.table.TableRowSorter; public class Statistics { JPanel panel = new JPanel(); static JTable table; JScrollPane scrollPane; static Integer BremP; Integer ScadP; Integer OrrP; Integer JackP; Integer MowP; Integer HowP; Integer McHP; Integer MartP; String Brem = "Bremner's"; String Scad = "Scadding's"; String Orr = "Orr's"; String Jack = "Jackson's"; String Mow = "Mowbray's"; String How = "Howard's"; String McH = "McHugh's"; String Mart = "Martland's"; JFrame frame = new JFrame("Statistics"); JFrame fram = new JFrame(); ErrorMessages msg = new ErrorMessages(fram); public Statistics() { Integer BremP = msg.getHousePoints("Bremner's"); Integer ScadP = msg.getHousePoints("Scadding's"); Integer OrrP = msg.getHousePoints("Orr's"); Integer JackP = msg.getHousePoints("McHugh's"); Integer MowP = msg.getHousePoints("Jackson's"); Integer HowP = msg.getHousePoints("Mowbray's"); Integer McHP = msg.getHousePoints("Martland's"); Integer MartP = msg.getHousePoints("Howard's"); System.out.println(msg.getHousePoints("Bremner's")); fram.dispose(); String columnNames[] = { "Houses", "Points" }; Object dataValues[][] = { { Brem, BremP }, { Scad, ScadP }, { Orr, OrrP }, { Jack, JackP }, { Mow, MowP }, { How, HowP }, { McH, McHP }, { Mart, MartP }, }; table = new JTable(dataValues, columnNames); table.setShowGrid(true); table.setGridColor(Color.BLACK); scrollPane = new JScrollPane(table); panel.add(scrollPane, BorderLayout.WEST); frame = new JFrame("Statistics"); frame.setResizable(false); frame.setLocation(840, 10); frame.setSize(458, 174); frame.add(panel); frame.setVisible(true); refreshTable(); } public static void refreshTable(){ System.out.println(BremP); System.out.println("LOL"); table.updateUI(); table.validate(); } }
- 05-30-2011, 11:37 PM #2
Please copy and paste here the full text of the error message.this class is causing a null pointer exception
How is this code being executed? I don't see the starting main method.Last edited by Norm; 05-30-2011 at 11:41 PM.
- 05-30-2011, 11:59 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
Java Code:Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at java.io.Writer.<init>(Writer.java:71) at java.io.PrintWriter.<init>(PrintWriter.java:75) at java.io.PrintWriter.<init>(PrintWriter.java:62) at HouseHockey.ErrorMessages.<init>(ErrorMessages.java:34) at HouseHockey.playerAttendance$8.actionPerformed(playerAttendance.java:271) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6374) at javax.swing.JComponent.processMouseEvent(JComponent.java:3267) at java.awt.Component.processEvent(Component.java:6139) at java.awt.Container.processEvent(Container.java:2085) at java.awt.Component.dispatchEventImpl(Component.java:4736) at java.awt.Container.dispatchEventImpl(Container.java:2143) at java.awt.Component.dispatchEvent(Component.java:4566) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4621) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212) at java.awt.Container.dispatchEventImpl(Container.java:2129) at java.awt.Window.dispatchEventImpl(Window.java:2478) at java.awt.Component.dispatchEvent(Component.java:4566) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:680) at java.awt.EventQueue.access$000(EventQueue.java:86) at java.awt.EventQueue$1.run(EventQueue.java:639) at java.awt.EventQueue$1.run(EventQueue.java:637) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98) at java.awt.EventQueue$2.run(EventQueue.java:653) at java.awt.EventQueue$2.run(EventQueue.java:651) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:650) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
I have the main method else where but if you need to see my other classes then ask.
- 05-31-2011, 12:07 AM #4
These two lines refer to your code. At line 271 it creates a new ErrorMessages objectat HouseHockey.ErrorMessages.<init>(ErrorMessages.jav a:34)
at HouseHockey.playerAttendance$8.actionPerformed(pla yerAttendance.java:271)
What is the code in ErrorMessages at line 34? What variable at that line is null?
- 05-31-2011, 12:12 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
Java Code:package HouseHockey; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import javax.swing.BoxLayout; import javax.swing.DefaultListModel; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTable; import javax.swing.ListModel; import javax.swing.ListSelectionModel; import javax.swing.RowFilter; import javax.swing.table.TableRowSorter; public class playerAttendance { JFrame frame = new JFrame("Attendance"); JPanel panel = new JPanel(); JPanel panel2 = new JPanel(); JPanel panel3 = new JPanel(); JLabel space = new JLabel(""); final static DefaultListModel listmodel = new DefaultListModel(); final JList list = new JList(listmodel); JScrollPane pane2 = new JScrollPane(list); final static DefaultListModel listmodel2 = new DefaultListModel(); final JList list2 = new JList(listmodel2); JScrollPane pane3 = new JScrollPane(list2); static Object data; Object data2; static Object[] ray; public playerAttendance(final String house1, final String house2){ frame.add(panel); String Brem = "Bremner's"; String Scad = "Scadding's"; String Orr = "Orr's"; String Jack = "Jackson's"; String Mow = "Mowbray's"; String How = "Howard's"; String McH = "McHugh's"; String Mart = "Martland's"; String[] houses = { Brem, Scad, Orr, Jack, Mow, How, McH, Mart }; final JComboBox houselist = new JComboBox(houses); String[] grades = { "Year 1", "Year 2", "Foundation Year", "IB1", "IB2" }; final JComboBox gradelist = new JComboBox(grades); JButton go = new JButton("Filter Houses"); JButton go2 = new JButton("Filter Grades"); JButton go3 = new JButton("Filter Both"); JButton go4 = new JButton("Search"); JPanel navAtt = new JPanel(); navAtt.add(houselist); navAtt.add(go); navAtt.add(gradelist); navAtt.add(go2); navAtt.add(go3); navAtt.add(go4); panel.add(navAtt); final JTable names = new JTable(); final DataFileModel model = new DataFileModel( "/Users/eric.manget/Desktop/allstuds.xls"); names.setModel(model); final TableRowSorter<DataFileModel> sorter = new TableRowSorter<DataFileModel>( model); final ArrayList<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>(); names.setRowSorter(sorter); JScrollPane pane = new JScrollPane(names); panel.add(pane); JButton addPlayerhouse1 = new JButton("Add Player To " + house1); JButton addPlayerhouse2 = new JButton("Add Player To " + house2); JButton remove1 = new JButton("Remove Player"); JButton remove2 = new JButton("Remove Player"); panel.add(panel2); final JFrame frame2 = new JFrame("Navigator"); JPanel panelN = new JPanel(); frame2.add(panelN); frame2.setSize(350,60); frame2.setResizable(false); frame2.setLocation(890,0); JButton close = new JButton("Close"); JButton complete = new JButton("Continue"); JButton mainB = new JButton("Main Page"); panelN.add(complete); panelN.add(mainB); panelN.add(close); frame2.setVisible(true); JLabel playinghouse1 = new JLabel(" " + house1); panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS)); panel2.add(playinghouse1); panel2.add(pane2); panel2.add(addPlayerhouse1); panel2.add(remove1); JLabel playinghouse2 = new JLabel(" " + house2); panel2.add(playinghouse2); panel2.add(pane3); panel2.add(addPlayerhouse2); panel2.add(remove2); frame.setResizable(false); frame.setSize(810, 495); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); names.getTableHeader().setResizingAllowed(false); names.getTableHeader().setReorderingAllowed(false); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION ); go.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { String text = houselist.getSelectedItem().toString(); if (text.length() == 0) { sorter.setRowFilter(null); } else { sorter.setRowFilter(null); sorter.setRowFilter(RowFilter.regexFilter(text)); } } }); go2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { String text2 = gradelist.getSelectedItem().toString(); if (text2.length() == 0) { sorter.setRowFilter(null); } else { sorter.setRowFilter(null); sorter.setRowFilter(RowFilter.regexFilter(text2)); } } }); go3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { String list1 = houselist.getSelectedItem().toString(); String list2 = gradelist.getSelectedItem().toString(); RowFilter<Object, Object> text = RowFilter.regexFilter(list1); RowFilter<Object, Object> text2 = RowFilter.regexFilter(list2); filters.clear(); filters.add(text); filters.add(text2); sorter.setRowFilter(null); sorter.setRowFilter(RowFilter.andFilter(filters)); } }); go4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { SEARCH search = new SEARCH(filters,sorter,model); } }); addPlayerhouse1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Object houseconf1 = names.getValueAt(names.getSelectedRow(), 3); if(!houseconf1.equals(house1)){ ErrorMessages confmsg1 = new ErrorMessages(frame); confmsg1.addingplayer(); } else{ Object listelement1 = names.getValueAt(names.getSelectedRow(), 2); Object listelement2 = names.getValueAt(names.getSelectedRow(), 1); listmodel.addElement(listelement1 + " " + listelement2); for(int i = 0; i < listmodel.getSize(); i++) { int n = listmodel.getSize(); } } } }); addPlayerhouse2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Object houseconf2 = names.getValueAt(names.getSelectedRow(), 3); if(!houseconf2.equals(house2)){ ErrorMessages confmsg2 = new ErrorMessages(frame); confmsg2.addingplayer(); } else{ Object listelement3 = names.getValueAt(names.getSelectedRow(), 2); Object listelement4 = names.getValueAt(names.getSelectedRow(), 1); listmodel2.addElement(listelement3 + " " + listelement4); } } }); close.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ErrorMessages rusure = new ErrorMessages(frame); rusure.unsavedData(); } }); complete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { int size = list.getModel().getSize(); int size2 = list2.getModel().getSize(); if(size < 6){ ErrorMessages rusure3 = new ErrorMessages(frame); rusure3.notEnoughPlayers(house1,house2); } if(size2 < 6){ ErrorMessages rusure4 = new ErrorMessages(frame); rusure4.notEnoughPlayers(house2,house1); } else{ frame.dispose(); frame2.dispose(); new GameScoreSheet(); } } }); mainB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { ErrorMessages rusure2 = new ErrorMessages(frame); rusure2.navMain(); } }); remove1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { listmodel.removeElement(list.getSelectedValue()); } }); remove2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { listmodel2.removeElement(list2.getSelectedValue()); } }); } public static void getL1(JList list){ list.setModel(listmodel); } public static void getL2(JList list){ list.setModel(listmodel2); } }
- 05-31-2011, 12:13 AM #6
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
AHHH im so confused I have been struggling for so long now.
- 05-31-2011, 12:15 AM #7
Did you look at the line in your code to see what variable was null?
- 05-31-2011, 12:18 AM #8
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
ya its the printwriter but what can I do about it?
- 05-31-2011, 12:20 AM #9
What variable is null?
Assign a value to the null variable so that it is not null.
Declaring variables does NOT give them values (except for primitives like int or boolean)
-
Post the offending line here.
- 05-31-2011, 12:25 AM #11
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
Fubarable - ?
Norm - Ok sure. Thanks, anything else needs fixing?
- 05-31-2011, 12:26 AM #12
There is way too much code for anyone to look thru.anything else needs fixing?
Did you find and fix the null variable problem?
-
If you've solved your problem already, you may disregard this, but if not, you and only you have the full code, and you have the error message the should indicate which line in that code is causing the nullpointerexception. Again, please post that line of offending code here.
- 05-31-2011, 12:52 AM #14
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
I did something and now it is letting me venture farther in my program without errors but I am getting another error message.
Here are the things I did.
Java Code:File file = new File("/Users/eric.manget/Desktop/Scores.txt"); int martlands = 0; int scaddings = 0; int mchughs = 0; int mowbray = 0; int orrs = 0; int brem = 0; int jacksons = 0; int howards = 0; PrintWriter out; public ErrorMessages(final JFrame frame2){ panel.add(label); frame.add(panel); frame.setSize(300,65); frame.setVisible(true); frame.setResizable(false); FileWriter outFile = null; try { outFile = new FileWriter(file); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } PrintWriter out = new PrintWriter(outFile); close.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { frame.dispose(); } });
Here is my error.
Java Code:Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at HouseHockey.ErrorMessages$6.actionPerformed(ErrorMessages.java:182) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6374) at javax.swing.JComponent.processMouseEvent(JComponent.java:3267) at java.awt.Component.processEvent(Component.java:6139) at java.awt.Container.processEvent(Container.java:2085) at java.awt.Component.dispatchEventImpl(Component.java:4736) at java.awt.Container.dispatchEventImpl(Container.java:2143) at java.awt.Component.dispatchEvent(Component.java:4566) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4621) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212) at java.awt.Container.dispatchEventImpl(Container.java:2129) at java.awt.Window.dispatchEventImpl(Window.java:2478) at java.awt.Component.dispatchEvent(Component.java:4566) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:680) at java.awt.EventQueue.access$000(EventQueue.java:86) at java.awt.EventQueue$1.run(EventQueue.java:639) at java.awt.EventQueue$1.run(EventQueue.java:637) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98) at java.awt.EventQueue$2.run(EventQueue.java:653) at java.awt.EventQueue$2.run(EventQueue.java:651) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:650) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
-
Again you're not indicating to us which lines of code are causing the error message.
Last edited by Fubarable; 05-31-2011 at 01:05 AM.
- 05-31-2011, 12:57 AM #16
You need to be able to read thru the error message and find your problem.at HouseHockey.ErrorMessages$6.actionPerformed(ErrorM essages.java:182)
Start from the bottom and scan up until you find a reference to one of your classes. Here the error occured at line 182 in ErrorMessages.java. Again its a NPE. Look at line 182 and figure out which variable is null. If you can't determine which one, add a System.out.println("var1=" + var1 + ", var2=" + var2 .. (replacing var1 etc with variables from the line with the NPE) to your code just before line 182. Execute the program again and look at what is printed out. One of the variables should have a null value. Now back up in the code to see why.
- 05-31-2011, 01:14 AM #17
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
Thank you Norm for that tip on errors. It seems that when I try to write to the file the program starts to whine. Can you give suggestions on how to link the integer I am writing with the hockey house.
- 05-31-2011, 01:15 AM #18
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
P.S: What does NPE stand for?
-
- 05-31-2011, 01:29 AM #20
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
Similar Threads
-
look @ code and give ideas! Install new code....
By turbowhat in forum New To JavaReplies: 2Last Post: 04-27-2011, 03:08 AM -
C server code - Java CLient Code _ TCP Connection Problem
By rmd22 in forum NetworkingReplies: 0Last Post: 02-21-2011, 11:50 AM -
can any one pls send me a sample code for calling a jsp code in swings
By sniffer139 in forum AWT / SwingReplies: 1Last Post: 03-04-2010, 11:19 AM -
Convert java code to midlet code
By coldvoice05 in forum New To JavaReplies: 1Last Post: 08-12-2009, 11:14 AM -
Generating Code Automatically Using Custom code Template In Eclipse
By JavaForums in forum EclipseReplies: 1Last Post: 04-26-2007, 03:52 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks