Saturday, 17 December 2022

Write a program to count the number of clicks performed by the user in a frame window

 

Write a program to count the number of clicks performed by the user in a frame window  This program run on  Eclipse IDE.



package com.javaguides.javaswing.login;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;


class CounterTest extends JFrame implements ActionListener {

    private int count = 0;

    JLabel lblData;

    CounterTest () 

    {setLayout(new FlowLayout());

        lblData = new JLabel("button clicked a times");

        JButton btn = new JButton("Click me");

        btn.addActionListener((ActionListener) this);

        add(lblData);

        add(btn);


    }

    public void actionPerformed(ActionEvent e) {

        count++;

        lblData.setText(" Button clicked " + count + "times");


    }







No comments:

Post a Comment

GitHub Most Imp Command For Every Developer Learn:

 Top Command for GitHub:  1) git clone 2) git init and git status   3) git add file name  or git add .  4) git commit -m message  5) git rem...