• Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying the Color on a frame based on the RGB values.  RSS feed

 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Am new to java Swings. I tried a small example to display a color on a frame based on the given RGB values. But it is giving me NullPointerException. I don't know why am getting this error. Please if anyone know why it is giving the error, Please let me know.. This is my example program code,

ColorApp.java
---------------


---------------------


 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you've posted the right code?
Because this one is working well.
 
Campbell Ritchie
Sheriff
Posts: 55366
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What’s Swings? I did not get that Exception when I tried your code.
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Just now i checked this code in other systems. This is working in other systems. But not with mine.. I dnt know why..
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Why does your class extend JFrame? Do you think it should?
2. Do you have a class of your own (badly) named JFrame? Did you ever create a class with that name? (The .class file may still be around.)

edit
3. What do java -version and javac -version output?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vidya Gupta wrote:ColorApp.java
---------------


Error StackTrace:
---------------------


That's not the code that produced this stack trace. Please PostRealCode.
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Darryl Burke,

I posted the correct code and correct Stack trace only.



Darryl Burke wrote:
Vidya Gupta wrote:ColorApp.java
---------------


Error StackTrace:
---------------------


That's not the code that produced this stack trace. Please PostRealCode.
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


java version "1.6.0_26"

Darryl Burke wrote:1. Why does your class extend JFrame? Do you think it should?
2. Do you have a class of your own (badly) named JFrame? Did you ever create a class with that name? (The .class file may still be around.)

edit
3. What do java -version and javac -version output?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vidya Gupta wrote:
Hi Darryl Burke,

I posted the correct code and correct Stack trace only.

The stack trace refers to line 26. You posted 23 lines of code that cannot be compiled.
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:
Vidya Gupta wrote:
Hi Darryl Burke,

I posted the correct code and correct Stack trace only.

The stack trace refers to line 26. You posted 23 lines of code that cannot be compiled.



Including import statements in the program total lines are 26.. Here i didn't post import statements..
 
Campbell Ritchie
Sheriff
Posts: 55366
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have been given this link several times, now actually read it.
Now you will know how you have been misleading everybody and posting the wrong numbers. You also know all the complaints in this thread have been justified. What is more, the last code you posted compiles and runs without Exceptions. The only likely explanation is that you have created your own JFrame class.
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:You have been given this link several times, now actually read it.
Now you will know how you have been misleading everybody and posting the wrong numbers. You also know all the complaints in this thread have been justified. What is more, the last code you posted compiles and runs without Exceptions. The only likely explanation is that you have created your own JFrame class.



Actually i posted correct code and stacktrace only.. That code is not working with me.. Thats why i posted.. Sorry am not misleading any one.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!