我有这个代码(在继承自的类中调用)。paintComponentJPanel
assert(red >= 0);
assert(red <= 255);
assert(green >= 0);
assert(green <= 255);
assert(blue >= 0);
assert(blue <= 255);
Color color = new Color(red, green, blue);
一段时间后,我得到一个例外:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Color parameter outside of expected range: Red
at java.awt.Color.testColorValueRange(Unknown Source)
at java.awt.Color.<init>(Unknown Source)
at java.awt.Color.<init>(Unknown Source)
at display.DrawCanvas.drawLed(DrawCanvas.java:55)
at display.DrawCanvas.paintComponent(DrawCanvas.java:36)
at javax.swing.JComponent.paint(Unknown Source)
DrawCanvas.java:55(第 55 行)是上面代码片段中的最后一行。
当所有值都介于 0 和 255(包括)之间时,参数怎么可能超出范围?
慕丝7291255
相关分类