2012-02-15 3 views
1

J'ai une application en Java et je veux qu'elle ait un RibbonApplicationMenu avec une icône.comment ajouter une icône pour RibbonApplicationMenu?

J'ai déjà le RibbonApplicationMenu mais sans icône. Je me demandais s'il est possible d'ajouter une icône au RibbonApplicationMenu?

Et je trouve le code suivant, à chaque fois que je le code ci-dessous, il me donne exception

statique ResizableIcon getResizableIconFromResource public (ressource String) {

return ImageWrapperResizableIcon.getIcon(MainFrame.class.getClassLoader().getResource(resource), new Dimension(48, 48)); 
} 

Exception:

Exception dans le fil "AWT-EventQueue-0" java.lang.NullPointerException à org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon.getIcon (ImageWrapperResizableIcon.java:71) à com.scamex.app.MainFrame.getResizableIconFromResource (MainFrame.java:187) à com.scamex.app.MainFrame $ 1.run (MainFrame.java:86) à java.awt.event.InvocationEvent.dispatch (InvocationEvent .java: 251) à java.awt.EventQueue.dispatchEventImpl (EventQueue.java:705) à java.awt.EventQueue.access $ 000 (EventQueue.java:101) à java.awt.EventQueue $ 3.run (EventQueue .java: 666) à java.awt.EventQueue $ 3.run (EventQueue.java:664) à java.security.AccessController.doPrivileged (méthode native) à java.security.ProtectionDomain $ 1.doIntersectionPrivilege (ProtectionDomain.java: 76) à java.awt.EventQueue.dispatchEvent (EventQueue.java:675) à java.awt.EventDispatch Thread.pumpOneEventForFilters (EventDispatchThread.java:211) à java.awt.EventDispatchThread.pumpEventsForFilter (EventDispatchThread.java:128) à java.awt.EventDispatchThread.pumpEventsForHierarchy (EventDispatchThread.java:117) à java.awt.EventDispatchThread. pumpEvents (EventDispatchThread.java:113) à java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:105) à java.awt.EventDispatchThread.run (EventDispatchThread.java:90)

+0

Un de votre objet est nul, je vous recommande d'imprimer chacun d'eux pour voir lequel c'est. – Alexandre

Répondre

0
JCommandButton button1 = new JCommandButton("Square", getResizableIconFromResource("48px-Crystal_Clear_action_bookmark.png")); 

public static ResizableIcon getResizableIconFromResource(String resource) 
{ 
    System.out.println("Resources:"+resource); 
    return ImageWrapperResizableIcon.getIcon(MainFrame.class.getClassLoader().getResource("resources/"+resource), new Dimension(48, 48)); 
} 
Questions connexes