Advertisement
Dlrowniatrec_2110

Untitled

Jun 22nd, 2018
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. import java.awt.EventQueue;
  2.  
  3. import javax.swing.JFrame;
  4. import javax.swing.JButton;
  5. import javax.swing.JTextArea;
  6. import java.awt.TextArea;
  7. import java.util.Timer;
  8. import java.util.TimerTask;
  9. import java.awt.event.ActionListener;
  10. import java.awt.event.ActionEvent;
  11.  
  12. public class WTH {
  13.  
  14.     private JFrame frame;
  15.  
  16.     /**
  17.      * Launch the application.
  18.      */
  19.     public static void main(String[] args) {
  20.         EventQueue.invokeLater(new Runnable() {
  21.             public void run() {
  22.                 try {
  23.                     WTH window = new WTH();
  24.                     window.frame.setVisible(true);
  25.                 } catch (Exception e) {
  26.                     e.printStackTrace();
  27.                 }
  28.             }
  29.         });
  30.     }
  31.  
  32.     /**
  33.      * Create the application.
  34.      */
  35.     public WTH() {
  36.         initialize();
  37.     }
  38.  
  39.     /**
  40.      * Initialize the contents of the frame.
  41.      */
  42.     private void initialize() {
  43.         frame = new JFrame();
  44.         frame.setBounds(100, 100, 588, 482);
  45.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  46.         frame.getContentPane().setLayout(null);
  47.        
  48.         TextArea Result = new TextArea();
  49.         Result.setBounds(29, 74, 515, 347);
  50.         frame.getContentPane().add(Result);
  51.        
  52.         JButton btnNewButton = new JButton("New button");
  53.         btnNewButton.addActionListener(new ActionListener() {
  54.             public void actionPerformed(ActionEvent e) {
  55.                
  56.                 Timer timer = new Timer();
  57.                 Process_PSP PSP = new Process_PSP();
  58.                
  59.                 new Thread(()->{
  60.                    
  61.                     PSP.Process(50, 100000);
  62.                    
  63.                 }).start();
  64.                 timer.schedule(new TimerTask(){
  65.                     public void run(){
  66.                         Result.setText(Result.getText()+"\n"+"Obj:"+PSP.getBest_Obj());
  67.                     }
  68.                 }, 0, 100);    
  69.                        
  70.                        
  71.                 /*Process_PSP PSP = new Process_PSP();
  72.                 PSP.Process(10, 100000);
  73.                 int x[] = PSP.getBest_Sol();
  74.                 Result.setText("Obj:"+PSP.getBest_Obj()+"\nSol(x_1, x_2, x_3, x_4):"+x[0]+""+x[1]+""+x[2]+""+x[3]);
  75.                 */
  76.             }
  77.         });
  78.         btnNewButton.setBounds(29, 31, 87, 23);
  79.         frame.getContentPane().add(btnNewButton);
  80.        
  81.        
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement