LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-26-2004, 10:43 AM   #1
linux_ub
Member
 
Registered: May 2004
Location: NY
Distribution: fedora core 1
Posts: 65

Rep: Reputation: 18
NullPointerException


Hi

i am writing a code which is using an array of objects ... when i try to run the code it gives me a nullpointer exception on line 24

Code:
import java.awt.Rectangle;
import java.awt.Color;
import javax.swing.*;

public class NewReport extends JInternalFrame{
	
	private JPanel reportPanel = new JPanel();
	private JLabel[] textLabels = new JLabel[10];
	
	public NewReport(Rectangle r) {
		super.setTitle("Report");
		super.setSize(r.width, r.height);
		super.setClosable(true);
		super.setIconifiable(true);
		super.setMaximizable(true);
		getContentPane().add(reportPanel);
		super.setBackground(Color.WHITE);
		reportPanel.setLayout(null);
		paintDesktop();
	}
	
	private void paintDesktop() {
		//JLabel toLabel = new JLabel();
		textLabels[0].setText("To");           // line 24
		textLabels[0].setBounds(4,12,16,11);
		reportPanel.add(textLabels[0]);
	}
}
where am i going wrong

thanks
 
Old 07-26-2004, 11:28 AM   #2
pycoucou
Member
 
Registered: Apr 2004
Location: Edinburgh
Posts: 78

Rep: Reputation: 15
You need to initialise all the JLabels of your array.

ie textLabels[0] = new JLabel();

it's the way I see that.

Cheers.
 
Old 07-26-2004, 11:38 AM   #3
linux_ub
Member
 
Registered: May 2004
Location: NY
Distribution: fedora core 1
Posts: 65

Original Poster
Rep: Reputation: 18
thanks a million ... it worked
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
jsvn fc4 NullPointerException gSalsero Linux - Software 3 06-21-2005 10:09 AM
jcifs problem:NullPointerException borgy_t Programming 1 04-17-2005 10:27 PM
java.lang.NullPointerException in JDBC test chr15t0 Programming 2 07-07-2003 11:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration