Advertisement
Guest User

Untitled

a guest
May 20th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. package Blatt7;
  2. import javax.swing.*;
  3. import java.awt.*;
  4. import java.awt.event.ActionListener;
  5. import java.awt.event.ActionEvent;
  6.  
  7. public class ButtonAction extends JFrame {
  8. public ButtonAction() {
  9. setSize(300,100);
  10. getContentPane().setLayout(new FlowLayout());
  11. JButton okButton=new JButton("OK");
  12. add (okButton);
  13.  
  14. okButton.addActionListener(new ActionListener() {
  15. public void actionPerformed(ActionEvent a) {
  16. System.out.println("OK");
  17. }
  18. }
  19. );
  20. JButton okButton2=new JButton("OK2");
  21. add (okButton2);
  22. okButton2.addActionListener(new ActionListener() {
  23. public void actionPerformed(ActionEvent a) {
  24. for (int i=0; i<5; i++)
  25. System.out.print("*");
  26. System.out.println();
  27.  
  28. }
  29. }
  30. );
  31.  
  32. setVisible(true);
  33. }
  34. public static void main(String s[]) {
  35. new ButtonAction();
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement