Results 1 to 6 of 6
- 04-19-2011, 11:20 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 3
- Rep Power
- 0
can not find icon in .exe made by WinRun4j : java.lang.NullPointerException
Hi all,
I have a problem with icons.
Part of code :
Java Code:private JButton getJButton() { if (jButton == null) { jButton = new JButton(); jButton.setPreferredSize(new Dimension(16, 16)); jButton.setFont(new Font("Dialog", Font.BOLD, 8)); jButton.setIcon(new ImageIcon(getClass().getResource("/com/img/cls.jpg"))); //---> This part fails jButton.setHorizontalAlignment(SwingConstants.CENTER); jButton.setHorizontalTextPosition(SwingConstants.CENTER); jButton.setText(""); jButton.setOpaque(true); jButton.setVisible(false); jButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent e) { jButton.setVisible(false); } public void mouseEntered(java.awt.event.MouseEvent e) { jButton.setVisible(true); } }); } return jButton; }
Error :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at com.FormMain.addtoJTabbedPane(FormMain.java:169)
at com.FormMain.treeSelectionHandler(FormMain.java:12 5)
at com.FormMain.access$0(FormMain.java:102)
at com.FormMain$1.valueChanged(FormMain.java:67)
at javax.swing.JTree.fireValueChanged(Unknown Source)
at javax.swing.JTree$TreeSelectionRedirector.valueCha nged(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.fireVal ueChanged(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.notifyP athChange(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.setSele ctionPaths(UnknownSource)
at javax.swing.tree.DefaultTreeSelectionModel.setSele ctionPath(Unknown Source)
at javax.swing.JTree.setSelectionPath(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI.selectPathForEv ent(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI$Handler.handleS election(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePr essed(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(U nknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn 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.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Tool : Eclipse
Source Folder : src
Package : com.img
When i run or debug this code from eclipse it works, no problem.
When i make runnable jar with this code, jar works, no problem.
When i make .exe with this code using WinRun4j with export type= Standart option(jars are out of .exe, in a folder), .exe works, no problem.
But when i make .exe with this code using WinRun4j and export type= Fat Executable option(jars and all files in .exe)it fails, can not find icons and .jrxml files.
Icons are in com.img package in src source folder, but getClass().getResource("/com/img/cls.jpg") returns null??
Whats the wrong or what can i do to solve this, anybody help ?
okxxLast edited by Fubarable; 04-19-2011 at 12:53 PM. Reason: Moderator Edit: code tags added
- 04-19-2011, 11:29 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
I would say to ask the developers/producers of WinRun4j
-
Is the icon image path a valid resource path? Is the image present in the Jar file here: "/com/img/cls.jpg" (relative to the current class, that is).
- 04-19-2011, 01:27 PM #4
Member
- Join Date
- Apr 2011
- Posts
- 3
- Rep Power
- 0
yess, icons and path valid, it already works by runnable jar or standart exe(jars out of exe) methods. It fails only when you create exe with fat executable method(jars in exe).
- 04-21-2011, 09:07 AM #5
Member
- Join Date
- Apr 2011
- Posts
- 3
- Rep Power
- 0
Hi all again,
I ve solved problem with diffrent method. I think this problem about WinRun4j plugin.
Anyway i found a porgram names Jar2Exe. It creates exe with no problem, no banner, makes a clear exe.
Thanks all reply
- 04-21-2011, 09:10 AM #6
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Similar Threads
-
java.lang.NullPointerException and i don't know why
By Qubes in forum New To JavaReplies: 15Last Post: 01-13-2011, 06:28 PM -
java.lang.NullPointerException
By Travis in forum AWT / SwingReplies: 7Last Post: 09-18-2009, 05:49 PM -
[SOLVED] [newbie] java.lang.String cannot be cast to javax.swing.Icon
By jon80 in forum New To JavaReplies: 6Last Post: 05-27-2009, 01:17 AM -
java.lang.NullPointerException
By vasavi.singh in forum New To JavaReplies: 1Last Post: 02-27-2009, 12:36 PM -
java.lang.NullPointerException
By vasavi.singh in forum New To JavaReplies: 2Last Post: 02-27-2009, 10:11 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks