I have a main class(which is basically a netbeans form;drag and drop) from where my application starts and another class(call it class 2) where my functions resides.I first call a function in class2 from my main method and that method has a while loop which increments a counter.Depending on that counter i call a function of my main class and try to display the counter in a textfield and also st the progressbar in intermediate but it is not working though it shows the print statements correctly(the counter).
Some code i am adding it is giving me problem as it is neither updating the progressbar nor updating the textfield.Kindly help me why is this happening
i have edited the code but still it displays nothing :(
public class NewClass
{
public static int counter = 0;
public NewJFrame p = new NewJFrame();
public void packet()
{
try
{
while (true)
{
//some code ,right now which i have omitted
counter = counter + 1;
counter2(counter);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void counter2(int counter)
{
counter3();
}
public void counter3()
{
p.progress(counter);
}
}
Now here is the main method from where i call the functions present in other class()code of that is given above)
public class NewJFrame extends javax.swing.JFrame
{
/** Creates new form NewJFrame */
public NewJFrame()
{
initComponents();
}
@SuppressWarnings("unchecked")
public void progress(int y)
{
jProgressBar1.setIndeterminate(true);
jTextField1.setText(y+"packets processed");
System.out.println(y);
}
private void jButton1MouseClicked(java.awt.event.MouseEvent evt)
{
NewClass m=new NewClass();
m.packet();
}
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e)
{
e.printStackTrace();
}
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JProgressBar jProgressBar1;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}