aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes passing value and setting it to jlabel text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "passing value and setting it to jlabel text" Watch "passing value and setting it to jlabel text" New topic
Author

passing value and setting it to jlabel text

Rodney Ibanez
Greenhorn

Joined: Aug 30, 2012
Posts: 17
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

Joined: Jun 19, 2012
Posts: 156
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

Joined: Aug 30, 2012
Posts: 17
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

Joined: Jun 19, 2010
Posts: 825
    
    5

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.


The quieter you are, the more you are able to hear.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2359
    
  50
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

Joined: Jun 19, 2010
Posts: 825
    
    5

Besides the code missing (I assumed this is a stripped version) there are too many syntax errors.
Rodney Ibanez
Greenhorn

Joined: Aug 30, 2012
Posts: 17
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

Joined: Jun 09, 2003
Posts: 4632
you've missed adding this line in the constructor of 'Choice' (also, there is an existing AWT class by that name)

mic.init();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing value and setting it to jlabel text