Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing value and setting it to jlabel text

 
Rodney Ibanez
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This site is really helping a lot of people! I have a simple program that I can't understand why I am getting the NullPointerException each time I try to pass a value from one form to another and setting it up as a text in a label. If I pass the value and do the pritln, I can actually see the result but if I place it in the jlabel as text, that's the time I get the error. Please Help! Thanks! Here is the code to pass the value to the other form.
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for why reason you tried to create Hybrid Application by creating a JApplet and JFrame (basically nothing wrong, but ...),

- create JApplet and use Java WebStart

- create desktop app. based on JFrame
 
Rodney Ibanez
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
m Korbel wrote:for why reason you tried to create Hybrid Application by creating a JApplet and JFrame (basically nothing wrong, but ...),

- create JApplet and use Java WebStart

- create desktop app. based on JFrame


thank you for pointing that out to me. You're probably right but it's working fine the way it is. It's just that the passing of value and placing it to the jlabel that gets some error. That's what I'm trying to resolve.
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think this code can be compiled at all. Not sure how you managed to get NullPointerException, but you are definitely not talking about the code you posted.
 
Tony Docherty
Bartender
Posts: 2957
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think this code can be compiled at all.
There's so much code missing from the post it's hard to work out what's going on but you're right you can't compile what's shown.

Rodney please show the exception message, full stack trace and the actual code you are running.

 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Besides the code missing (I assumed this is a stripped version) there are too many syntax errors.
 
Rodney Ibanez
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:
I don't think this code can be compiled at all.
There's so much code missing from the post it's hard to work out what's going on but you're right you can't compile what's shown.

Rodney please show the exception message, full stack trace and the actual code you are running.



oh.. okay.. this is my whole code ...


This is the exception error:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Micolocoi.setLblRem1(Micolocoi.java:181)
at Choice.selectionAction(Choice.java:83)
at Choice.access$0(Choice.java:71)
at Choice$1.actionPerformed(Choice.java:39)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.JToggleButton$ToggleButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Thank You.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you've missed adding this line in the constructor of 'Choice' (also, there is an existing AWT class by that name)

mic.init();
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic