I am trying to get my program to constantly update the values of progress indicators inside the method during some operations. However, this does not happen until the end, and the user interface freezes.
Having examined similar issues with my problems, I tried to implement the decisions made (using threads), however I cannot get it to work correctly. Similarly, if they are not there.
My program contains several classes, and Mainthis is one that is automatically created by netbeans in JFrame Design mode, so there are certain things, such as static void mainand public Mainwhich, are not really sure about some of its contents. In the "I" section, fragments of these methods will be placed along with the implementation of my stream.
public class Main extends javax.swing.JFrame implements ActionListener, Runnable{
...
static Main _this;
...
public static void main(String args[]) {
Main m = new Main();
new Thread(m).start();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Main().setVisible(true);
}
});
}
...
public Main() {
initComponents();
_this = this;
}
...
public void actionPerformed(ActionEvent e) {
synchronized(this){
notifyAll();
}
}
public void run() {
try{synchronized(this){wait();}}
catch (InterruptedException e){}
progressBar.setValue(50);
}
...
private void buttonPressed(java.awt.event.MouseEvent evt) {
for(int i=0; i<=100; i++) {
for(int j=0; j<=5; j++) {
}
run();
}
}
All I commented on as I added...are the things that I posted in accordance with the tutorials and answers that I saw on the Internet, but nothing works, and it seems to me that I tried to get closer to millions of different combinations ...
Thanks in advance for your help.
source
share