Results 1 to 4 of 4
- 07-26-2011, 10:08 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 7
- Rep Power
- 0
I am created this program.but it shows null pointer exception...can any one help me..
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Progress extends JFrame implements Runnable,ActionListener
{
JProgressBar jp=new JProgressBar(1,100);
Container con=getContentPane();
Button b1=new Button("start");
Thread t;
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
new Thread(this);
t.start();
}
}
public void run()
{
try
{
for(int i=1;i<101;i++)
{
jp.setValue(i);
t.sleep(10);
}
}
catch (Exception ex)
{
System.out.println("ERROR HAS OCCURED.....SORRY.....");
}
}
public static void main(String args[])
{
new Progress();
}
public Progress()
{
con.setLayout(new FlowLayout());
con.add(jp);
con.add(b1);
b1.addActionListener(this);
setSize(300,100);
setVisible(true);
setTitle("PROGRESSBAR");
}
}
- 07-26-2011, 10:32 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,068
- Blog Entries
- 3
- Rep Power
- 15
All you've done is dump your code(without code tags), why not provide us with useful information? What is the exact error message you see(copy/paste it)?
To use code tags do the following
[code]
YOUR CODE HERE
[/code]
That being said; without looking at your code I can say pretty confidently that you haven't initialized something and you tried calling a method on it. Try adding print statements to print different variables throughout the program. Also, follow the stack trace the exception gives you back to the line which caused the exception.
- 07-26-2011, 11:00 AM #3
Would you like to reply to Fubarable's response on the thread you started yesterday? Like maybe to say 'Thank you'?
Or is it your intention to start thread after thread and never get back to them?
db
- 07-26-2011, 12:30 PM #4
Member
- Join Date
- Jul 2011
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Need help with Null Pointer Exception (program using inheritance)
By kali1980 in forum New To JavaReplies: 6Last Post: 06-27-2011, 09:40 AM -
Help with my Tic Tac Toe program-null pointer exception
By TheBadBoy in forum New To JavaReplies: 4Last Post: 06-11-2011, 02:35 AM -
Null Pointer Exception
By jonytek in forum New To JavaReplies: 5Last Post: 03-02-2011, 08:16 AM -
Null pointer exception
By samuel.roshni in forum Java ServletReplies: 14Last Post: 01-22-2011, 03:25 PM -
Null Pointer exception
By diegoyj in forum New To JavaReplies: 7Last Post: 01-29-2010, 05:17 PM
Bookmarks