Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Blatt7;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- public class ButtonAction extends JFrame {
- public ButtonAction() {
- setSize(300,100);
- getContentPane().setLayout(new FlowLayout());
- JButton okButton=new JButton("OK");
- add (okButton);
- okButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent a) {
- System.out.println("OK");
- }
- }
- );
- JButton okButton2=new JButton("OK2");
- add (okButton2);
- okButton2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent a) {
- for (int i=0; i<5; i++)
- System.out.print("*");
- System.out.println();
- }
- }
- );
- setVisible(true);
- }
- public static void main(String s[]) {
- new ButtonAction();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement