日期:2014-05-20 浏览次数:20845 次
import javax.swing.UIManager; public class LookAndFeelTest { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub LookAndFeelClass lafc = new LookAndFeelClass(); lafc.ViewAll(); } } public class LookAndFeelClass() { public void ViewAll() { UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels(); for(int i=0;i<infos.length ;i++) { name = infos[i].getName(); className = infos[i].getClassName(); System.out.println(name+className); } } String name = ""; String className = ""; }
public class LookAndFeelClass { public void ViewAll() { UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels(); for(int i=0;i<infos.length ;i++) { name = infos[i].getName(); className = infos[i].getClassName(); System.out.println(name+className); } } String name = ""; String className = ""; }
------解决方案--------------------
第二个类LookAndFeelClass
不能定义成public,或者单独写在另外一个文件
------解决方案--------------------
/** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub LookAndFeelClass lafc = new LookAndFeelClass(); lafc.ViewAll(); } } class LookAndFeelClass { public void ViewAll() { UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels(); for(int i=0;i<infos.length ;i++) { name = infos[i].getName(); className = infos[i].getClassName(); System.out.println(name+className); } } String name = ""; String className = ""; }
------解决方案--------------------
貌似一个类只能有一个public类~~
------解决方案--------------------
修饰符去掉class LookAndFeelClass括号去掉
{
public void ViewAll()
{
UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
for(int i=0;i<infos.length ;i++)
{
name = infos[i].getName();
className = infos[i].getClassName();
System.out.println(name+className);
}
}
String name = "";
String className = "";
}改成这个样子 试试
------解决方案--------------------
一个.java文件多可以写多个类,但是只能有一个类是public 修饰的
------解决方案--------------------
LookAndFeelClass不要()
------解决方案--------------------