Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- public class Test extends JFrame
- {
- JLabel j1;
- ButtonListener1 bl1;
- ButtonListener2 bl2 ;
- int count =0;
- public Test()
- {
- Container C = getContentPane();
- C.setTitle ("exemple");
- JLabel j1=new JLabel("0");
- JButton b1 = new JButton ;
- JButton b2 = new JButton ;
- bl2 = new ButtonListener2() ;
- bl1 = new ButtonListener1();
- b1.addActionListener(bl1);
- b2.addActionListener(bl2);
- C.add(b1);
- C.add(b2);
- C.add(j1);
- }
- private class ButtonListener1 implemets ActionListener
- {
- count = count +1 ;
- j1.setText (String.valueOf(count));
- }
- private class ButtonListener2 implemets ActionListener
- {
- count = count -1 ;
- j1.setText (String.valueOf(count));
- }
- public static void main(String[] args) {
- new Test();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement