which pauses the system. But i dont know how to make the button not freezing and the gui program interactive.
example
import java....
public class Example extends JPanel{
public Example(){
//I add the button here;
//add an actionlistener to that button
//i added the button to the panel
label = new JLabel();
add(label);
}
this is the method to be performed when the button is pressed
public void beginExec(){
try
Thread.sleep();
label.setText(It will print whatever happens in the program);
}
here is the class ButtonListener
public class ButtonListener implements ActionListener{
public void actionPerfomed(ActionEvent e){
if(start == e.getSource()){//if the start is pressed;
beginExec();
}
}
}
public static void main(String[] args)
add the panel to frame;
}


Sign In
Create Account


Back to top









