I have a simple application from some thread, I need some thread from swing GUI (I'm using Netbeans).
This is my main form that I need to update:
public class mainForm javax.swing.JFrame {Private GameControl OBG; Public Mainform () {initComponents (); } Public Zero Runto () {Thread-test th1 = New Thread Test (1, 1, OBJ); Thread Test th8 = New Thread Test (8, 95000, OBJ); Thread Test Th 2 = New Thread Test (2, 100000, OBJ); Thread Test Th3 = New Thread Test (3, 120000, OBJ); Thread Test Th 4 = New Thread Test (4, 140000, OBJ); Thread Test Thub 22 = New Thread Test (22, 1000, OBJ); Thread thread 1 = new thread (th1); Thread thread2 = new thread (th2); Thread thread3 = new thread (th3); Thread thread4 = new thread (th4); Thread thread22 = new thread (th22); Thread thread8 = new thread (th8); Thread1.start (); Thread2.start (); Thread3.start (); Thread4.start (); Thread22.start (); Thread8.start (); } Public Static Zero Main (string algos []) {SwingUtilities.invokeLater (public void run) {mainForm app = new mainForm (); app.setVisible (true);}}); } Private javax.swing.JButton jButton1; Private javax.swing.JButton jButton10; Private javax.swing.JButton jButton2; Private javax.swing.JButton jButton3; Private javax.swing.JButton jButton4; Private javax.swing.JLabel jLabel1; Private javax.swing.JLabel jLabel2; Private javax.swing.JLabel jLabel4; Private javax.swing.JLabel jLabel5; Private javax.swing.JSeparator jSeparator1; Private javax.swing.JTextField jTextField1; Private javax.swing.JTextField pathtbox; }
Now I have some threads:
implements a public square thread test Runnable {public static mainForm main = new mainForm (); Private finals function nimbar; Private Final In Time 2 Start; Public Thread Test (int function number, int time 2 start, game control obje) {this.functionNumber = functionNumber; This.time2start = time2start; } @ Override public wide run (try.leep.sleep (time2start);} hold (exception before) {} / time delay before function switch (functionNumber) {case 1: // system.out.println (" case 1"); Obj.runFirst (); break; Case 2: // System.out.println ("Case 2"); Obj.runSecond (); break; Case 3: {try {obj.runThird (); } Hold (IOException pre) {Logger.getLogger (ThreadTest.class.getName ()). Log (Level.SEVERE, null, ex); } } break; ...
I have in another category:
public void runFirst () {System.out.println ("I need to show this Text on Jlabel5 "); }
Each part of the code is in a different file (class). How do I apply swing workers to be able to show text on my main GUI form?