Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5.  
  6. class Button {
  7. static JButton button1 = new JButton("iuo"); }
  8.  
  9. class ButtonListener1 extends Button implements ActionListener {
  10. @Override
  11. public void actionPerformed(ActionEvent e) {
  12. button1.setText("Привет");
  13. Font BigFontTR = new Font("TimesRoman", Font.BOLD, 100);
  14. button1.setFont(BigFontTR);
  15. } }
  16.  
  17.  
  18. class SomeThing extends ButtonListener1 implements Runnable {
  19. public void run() {
  20. // Как сделать так, чтобы поток ждал нажатия на кнопку?
  21. }
  22. }
  23.  
  24.  
  25. public class Jitik extends SomeThing {
  26. public static void main(String[] args) throws InterruptedException {
  27. JFrame frame = new JFrame("Jitik");
  28. frame.setSize(800, 1000);
  29. frame.setLocationRelativeTo(null);
  30. JPanel panel = new JPanel(new GridLayout(2, 1, 5, 5));
  31. frame.add(panel);
  32. panel.add(button1);
  33. button1.addActionListener(new ButtonListener1());
  34. frame.setVisible(true);
  35.  
  36. SomeThing mThing = new SomeThing();
  37. Thread myThready = new Thread(mThing);
  38. myThready.start();
  39. myThready.join();
  40.  
  41. String s = button1.getText();
  42. System.out.println(s);
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement