SpinningAround
December 28th, 2009, 09:49 PM
I'm having some problem with these two code parts, in the first part can't be compiled since plotTraffic is non-static and part of the inner class Draw. paintDiagram is a non-static method in Draw.
In the other part will trigger when 'START' is clicked after that will the GUI window will lock up, I guess because the program never return from actionPerformed.
Question is what is needed to be done to get it working?
private static void active(long trafficLimit){
while(todayTraffic<=trafficLimit){
Wait.oneSec();
if(runScript()!=null){
todayTraffic = Long.parseLong(runScript());
trafficAmount.setText("" + todayTraffic + " of " + trafficLimit);
plotTraffic.paintDiagram();
}
else{
break;
}
}
closeOperation();
}
public void actionPerformed(ActionEvent event){
Object obj = event.getSource();
if(obj instanceof JButton){
String info = event.getActionCommand();
int tal = Integer.parseInt(info);
switch(tal){
case 10: trafficInput.setEditable(false);
if(trafficInput.getText()!=null){
try{
trafficLimit=(Long.parseLong(trafficInput.getText( )))*1000000000;
//convert the info in trafficInput from GB to byte
errorMSG.setText(""); //new try reset error message
active(trafficLimit);
}
}
In the other part will trigger when 'START' is clicked after that will the GUI window will lock up, I guess because the program never return from actionPerformed.
Question is what is needed to be done to get it working?
private static void active(long trafficLimit){
while(todayTraffic<=trafficLimit){
Wait.oneSec();
if(runScript()!=null){
todayTraffic = Long.parseLong(runScript());
trafficAmount.setText("" + todayTraffic + " of " + trafficLimit);
plotTraffic.paintDiagram();
}
else{
break;
}
}
closeOperation();
}
public void actionPerformed(ActionEvent event){
Object obj = event.getSource();
if(obj instanceof JButton){
String info = event.getActionCommand();
int tal = Integer.parseInt(info);
switch(tal){
case 10: trafficInput.setEditable(false);
if(trafficInput.getText()!=null){
try{
trafficLimit=(Long.parseLong(trafficInput.getText( )))*1000000000;
//convert the info in trafficInput from GB to byte
errorMSG.setText(""); //new try reset error message
active(trafficLimit);
}
}