public static String privilege = "9"; public static boolean isAdministrator(){ if (privilege.equalsIgnoreCase("0"))return true; else return false; } 在另外一个类中调用 if (new LoginFrame().isAdministrator()){ xiaoShouGuanLiMenu.setEnabled(true);} else xiaoShouGuanLiMenu.setEnabled(false);最好在另外一个类中不要更改,使用get方法和set方法比较好,记得用static函数
都会互相影响……,可能会出现无法预料的错误。
if (privilege.equalsIgnoreCase("0"))return true;
else return false;
}
在另外一个类中调用
if (new LoginFrame().isAdministrator()){
xiaoShouGuanLiMenu.setEnabled(true);}
else xiaoShouGuanLiMenu.setEnabled(false);最好在另外一个类中不要更改,使用get方法和set方法比较好,记得用static函数
1.这个String是从数据库里面读出来的
2.楼上自己似乎定义了很多自己的东西,在下看不太明白。
比如:
public class ReturnString{
public static String getString(){
return str;}private static String str;
}然后在你需要调用的另外一个类中写如下代码:
String stringGetted = new ReturnString().getString();
这样子就得到了你从数据库中取的的String。
而且在其他任何一个类中,只要使用这样的方法都可以调用的。
还有一个,变量定义最好不要用public不安全
还有什么不明白的么?