我试图将值 t 从一个类传递给另一个类,但在我运行程序之前,我non static method cannot be referenced from static context
从这行代码中得到:
t = (PrinterSettings.getT() * 60);
我正在尝试从此代码中获取值 t :
public int t = 1; //defualt value for amount of mintues in the future the job should wait untill sent
public int getT() {
return (t);
}
public void setT(int t) {
this.t = t;
}
我做错了什么?我怎样才能得到t
编辑 :
我从中得到的整个代码
public int t = 1; //defualt value for amount of seconds in the future the job should wait untill sent
public int getT() {
return (t);
}
public void setT(int t) {
this.t = t;
}
这是我正在使用的类,它从上述类中调用 t 来使用:
public class DealyTillPrint {
public int t;
public String CompletefileName;
private String printerindx;
private static int s;
private static int x;
public static int SecondsTillRelase;
public void countDown() {
System.out.println("Countdown called");
s = 1; // interval
t = ((new PrinterSettings().getT()) * 60); //(PrinterSettings.SecondsTillRelase); // number of seconds
System.out.println("t is : " + t);
while (t > 0) {
System.out.println("Printing in : " + t);
try {
Thread.sleep(s * 1000);
} catch (Exception e) {
}
t--;
}
这是我t
使用微调器设置的地方
<p:spinner min="1" max="1000" value="#{printerSettings.t}" size ="1">
<p:ajax update="NewTime"/>
</p:spinner>