Results 1 to 6 of 6
- 08-30-2009, 03:44 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 16
- Rep Power
- 0
- 08-30-2009, 09:14 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Reading some tutorials should help.
Here is one.
- 08-31-2009, 06:01 AM #3
Member
- Join Date
- Aug 2009
- Posts
- 16
- Rep Power
- 0
I try the same code in JCreator,it works but not in netbeans.Whenever I want to add image to any swing controls(such as JButton) it shows exceptions.
here is the code:
jButton1 = new javax.swing.JButton();
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/hrm/orange_new_06.gif")));
jButton1.setText("jButton1");
and here is the exception:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:138)
at hrm.NewJFrame.initComponents(NewJFrame.java:35)
at hrm.NewJFrame.<init>(NewJFrame.java:18)
at hrm.NewJFrame$1.run(NewJFrame.java:64)
at java.awt.event.InvocationEvent.dispatch(Invocation Event.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 461)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:110)
- 08-31-2009, 10:19 AM #4
Senior Member
- Join Date
- Aug 2009
- Location
- Pittsburgh, PA
- Posts
- 282
- Rep Power
- 4
getResource is not finding "/hrm/orange_new_06.gif"
When I had this sort of problem it was because I had not done a "clean and build" on the project. The build will copy the image from the source tree to the destination tree. getResource looks in the destination tree
- 08-31-2009, 07:29 PM #5
Member
- Join Date
- Aug 2009
- Posts
- 16
- Rep Power
- 0
Oh, it works.
Thanks zweibieren.
- 09-01-2009, 07:56 AM #6
Member
- Join Date
- Aug 2009
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
How to draw in a JPanel using Netbeans 6.1 GUI maker
By Gatts79 in forum New To JavaReplies: 4Last Post: 08-28-2009, 06:50 PM -
Add Image to JPanel
By Seonix in forum AWT / SwingReplies: 1Last Post: 08-12-2009, 01:54 PM -
Image appear at random co-ord within jpanel
By IHateNetbeans in forum New To JavaReplies: 1Last Post: 04-30-2009, 07:06 PM -
How to display image from byte array in JPANEL
By waqasdaar in forum AWT / SwingReplies: 0Last Post: 03-22-2009, 12:11 AM -
how to set image to a jpanel
By masa in forum AWT / SwingReplies: 1Last Post: 03-02-2009, 08:36 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks