你需要把color_set定义为类的数据成员.
以你的例子,在parseArgs结束时,该变量也就没有了,到setBackground(color_set)时,不知到哪儿去找它,自然就出错了.
以你的例子,在parseArgs结束时,该变量也就没有了,到setBackground(color_set)时,不知到哪儿去找它,自然就出错了.
解决方案 »
- 我的Jcreator怎么不能调试,只能设断点啊
- UDP接收堵塞。。。
- 用JFrame和Frame出现不一样的情况。
- javascript 写验证方法是有时是return validate(this.form) 有时是return validate(this)???
- Java Heap Out of Memory 有人知道是什么错吗?
- Exception in thread "main" java.lang.NullPointerException
- class 反编译
- 有可用的calender 控件吗 象VC一样让用户选择日期
- 特殊字符的显示
- 高手,小弟一个比较初级的问题请教,麻烦指教!
- java 2 swing 的一个问题
- 为什么别人看不到我的Applet ???
//Finds a color in the system properties.
//The argument is treated as the name of a system property to be obtained.
//The string value of this property is then interpreted as an integer which is then converted to a Color object.
//If the specified property is not found or could not be parsed as an integer then null is returned. //需要理解getColor他是从system properties获得值,然后将其转换成相应的integer
//如果你没有设属性"green",而使用getColor("green"),将只能能得到为null的Color对象
//依此类推,如
System.setProperty("myblack",Color.black.getRGB()+"");
System.setProperty("mygreen",Color.green.getRGB()+"");
Color color_set=Color.getColor("mygreen");
System.out.println(color_set);