日期:2014-05-20  浏览次数:20990 次

求助:Substance的异常
在使用Java的皮肤包Substance.jar的时候出现了异常:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width (0) and height (40) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
at java.awt.image.BufferedImage.<init>(Unknown Source)
at org.jvnet.substance.utils.SubstanceCoreUtilities.getBlankImage(SubstanceCoreUtilities.java:1343)
at org.jvnet.substance.SubstanceImageCreator.getDragImage(SubstanceImageCreator.java:1667)
at org.jvnet.substance.grip.DragBumpsGripPainter.paintGrip(DragBumpsGripPainter.java:84)
at org.jvnet.substance.SubstanceSplitPaneDivider.paint(SubstanceSplitPaneDivider.java:99)
调用皮肤包的代码如下:
try {
UIManager.setLookAndFeel(new SubstanceLookAndFeel());
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
SubstanceLookAndFeel
.setCurrentTheme(new org.jvnet.substance.theme.SubstancePurpleTheme());
SubstanceLookAndFeel
.setCurrentButtonShaper(new ClassicButtonShaper());
} catch (Exception er) {
System.err.println("Something went wrong!");
}
MainFrame frame = new MainFrame();
如果去掉try/catch里面的代码就没有问题,但这样就不能使用皮肤包了。

------解决方案--------------------
异常信息中的Width是在哪儿进行赋值的,这里有问题的应该。
另外,try中的语句肯定不会引发这个异常的,因为你在catch中用的是Exception,也就是所有种类的异常都能进行捕获,catch中的打印语句也不会有异常。
所以还是先定位异常发生的源头吧
------解决方案--------------------
width不能小于等于0。
------解决方案--------------------
Width (0) and height (40) cannot be <= 0

这个提示不要太明显