Consider the code below ...
public class frmMain extends javax.swing.JFrame {
Boolean running;
public class MyThread extends Thread
{
public frmMain owner;
public int value = 0;
public void run()
{
value = 0;
while (value < 200000)
{
if (running == false) break;
owner.setTitle(String.valueOf(value));
value++;
}
}
}
/**
* Creates new form frmMain
*/
public frmMain() {
initComponents();
}
private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
running = true;
MyThread j = new MyThread();
j.owner = this;
j.start();
}
private void btnStopActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
running = false;
}
-----------------------------------
Basically I have a long process in my Swing code. Within that process I want to make sure my jFrame & graphics is constantly being updated & refreshed. My process is in a background thread, but I need a way to ensure that the thread is detached from the jFrame and that the jFrame can display what is happening in the process.
This is a threading issue I believe.