Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. public class server implements Runnable, ActionListener {
  2.  
  3. JFrame frame;
  4. JButton button1;
  5. JButton button2;
  6.  
  7. public void makeFrame() {
  8. frame = new JFrame("Frame");
  9. frame.setSize(1000, 500);
  10. frame.getContentPane().setBackground(new Color(74, 74, 74));
  11. frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
  12. frame.setLocationRelativeTo(null);
  13. frame.setVisible(true);
  14. frame.setLayout(null);
  15. }
  16.  
  17. public void makeButtons() {
  18. gomb1 = new JButton("Indítás");
  19. gomb1.setBounds(350, 300, 100, 30);
  20. gomb1.setBackground(new Color(127, 127, 127));
  21. frame.getContentPane().add(gomb1);
  22. gomb1.addActionListener(this);
  23.  
  24. gomb2 = new JButton("Stop");
  25. gomb2.setBounds(550, 300, 100, 30);
  26. gomb2.setBackground(new Color(127, 127, 127));
  27. frame.getContentPane().add(gomb2);
  28.  
  29. }
  30.  
  31. public void actionPerformed(ActionEvent event) {
  32. if (event.getSource() == button1) {
  33.  
  34. }
  35. }
  36.  
  37.  
  38.  
  39. @Override
  40. public void run() {
  41. try {
  42. go();
  43. } catch (InterruptedException ex) {
  44. Logger.getLogger(server.class.getName()).log(Level.SEVERE, null, ex);
  45. }
  46. }
  47.  
  48.  
  49. public void go() throws InterruptedException {
  50. doMore();
  51. }
  52.  
  53. public void doMore() throws InterruptedException {
  54.  
  55. for (int i = 0; i < 20; i++) {
  56. System.out.println("Fut a thread" + i);
  57.  
  58. }
  59.  
  60. }
  61. }
  62.  
  63. class Test {
  64.  
  65. public static void main(String[] args) {
  66. server t = new server();
  67. t.makeFrame();
  68. t.makeButtons();
  69. Runnable r = new server();
  70. Thread szal = new Thread(r);
  71. Thread szal2 = new Thread(r);
  72.  
  73. szal.start();
  74. szal2.start();
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement