title: Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
body: <p>Hi I am trying to add an icon to my button, it seems it works fine for one image but as soon as i change the image to some other image  i get this error: the only difference is that the previous image had a resolution of 48x48 and the new image has a resolution of 32x32</p>
  
  <p>Here is the code:</p>
  
  <pre><code>dashboardButton = new JButton("Dashboard", new ImageIcon("images/dashbd.png"));
          dashboardButton.addActionListener(this);
          topPanel.add(dashboardButton, topCC.xy(2,2));
  </code></pre>
  
  <p>This is the error:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be &lt;= 0
      at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1016)
      at java.awt.image.BufferedImage.&lt;init&gt;(BufferedImage.java:338)
      at in.tcs.dct.ui.custom.UnifiedToolbarButtonUI.paintIcon(UnifiedToolbarButtonUI.java:48)
      at javax.swing.plaf.basic.BasicButtonUI.paint(BasicButtonUI.java:216)
      at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
      at javax.swing.JComponent.paintComponent(JComponent.java:778)
      at javax.swing.JComponent.paint(JComponent.java:1054)
      at javax.swing.JComponent.paintChildren(JComponent.java:887)
      at javax.swing.JComponent.paint(JComponent.java:1063)
      at javax.swing.JComponent.paintChildren(JComponent.java:887)
      at javax.swing.JComponent.paint(JComponent.java:1063)
      at javax.swing.JComponent.paintChildren(JComponent.java:887)
      at javax.swing.JComponent.paint(JComponent.java:1063)
      at javax.swing.JComponent.paintChildren(JComponent.java:887)
      at javax.swing.JComponent.paint(JComponent.java:1063)
      at javax.swing.JLayeredPane.paint(JLayeredPane.java:585)
      at javax.swing.JComponent.paintChildren(JComponent.java:887)
      at javax.swing.JComponent.paint(JComponent.java:1063)
      at javax.swing.JComponent.paintToOffscreen(JComponent.java:5221)
      at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:295)
      at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
      at javax.swing.JComponent._paintImmediately(JComponent.java:5169)
      at javax.swing.JComponent.paintImmediately(JComponent.java:4980)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:793)
      at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
      at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
      at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
      at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
      at java.awt.EventQueue.access$000(EventQueue.java:101)
      at java.awt.EventQueue$3.run(EventQueue.java:666)
      at java.awt.EventQueue$3.run(EventQueue.java:664)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:121)
      at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
      at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
      at java.awt.Dialog.show(Dialog.java:1072)
      at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:871)
      at javax.swing.JOptionPane.showConfirmDialog(JOptionPane.java:797)
      at javax.swing.JOptionPane.showConfirmDialog(JOptionPane.java:759)
      at in.tcs.dct.ui.DCTFrame.windowClosing(DCTFrame.java:146)
      at java.awt.AWTEventMulticaster.windowClosing(AWTEventMulticaster.java:349)
      at java.awt.Window.processWindowEvent(Window.java:2045)
      at javax.swing.JFrame.processWindowEvent(JFrame.java:296)
      at java.awt.Window.processEvent(Window.java:2003)
      at java.awt.Component.dispatchEventImpl(Component.java:4860)
      at java.awt.Container.dispatchEventImpl(Container.java:2287)
      at java.awt.Window.dispatchEventImpl(Window.java:2713)
      at java.awt.Component.dispatchEvent(Component.java:4686)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
      at java.awt.EventQueue.access$000(EventQueue.java:101)
      at java.awt.EventQueue$3.run(EventQueue.java:666)
      at java.awt.EventQueue$3.run(EventQueue.java:664)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
      at java.awt.EventQueue$4.run(EventQueue.java:680)
      at java.awt.EventQueue$4.run(EventQueue.java:678)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
  </code></pre>