plz tell me

plz tell me

how to get no. of times the 'button' is pressed

View Answers

September 10, 2012 at 11:36 AM

Here is a java swing code that counts the number of times the button clicked.

import javax.swing.*;
import java.awt.event.*;

public class CountButtonClicks extends JFrame{
  public static void main(String[] args){
    new CountButtonClicks();
 }
   JButton button1 = new JButton("Click Me!");
    int clickCount = 0;
    public CountButtonClicks(){
    this.setSize(275, 100);
    JPanel panel1 = new JPanel();

    button1.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e) {
        clickCount++;
          button1.setText("clicked " + clickCount + " times!");
    }
    });
    panel1.add(button1);
    this.add(panel1);
    this.setVisible(true);
  }
}









Related Tutorials/Questions & Answers:
plz tell me
plz tell me  how to get no. of times the 'button' is pressed   Here is a java swing code that counts the number of times the button clicked... CountButtonClicks(); } JButton button1 = new JButton("Click Me!"); int clickCount
plz tell me the code & execution process - Java Beginners
plz tell me the code & execution process  Write a program to download a website from a given URL. It must download all the pages from that website. It should take the depth of retrieval from the user input. All the files/pages
Advertisements
plz tell me the code & execution process - Java Beginners
plz tell me the code & execution process  Write a program to download a website from a given URL. It must download all the pages from that website. It should take the depth of retrieval from the user input. All the files/pages
plz plz plz inform me as soon as possible
plz plz plz inform me as soon as possible  ``by using c programs how to type
plz give me answer plz
plz give me answer plz  writw a programme to find rank from an array using doubledimmensionalarray
Tell me - Struts
Directory Structure for Struts  Tell me the Directory Structure for Struts
Pls anyboby tell me...
Pls anyboby tell me...  which book easy to learn spring
Tell me - Struts
Struts tutorial to learn from beginning   Tell me, how can i learn the struts from beginning
Tell me - Struts
Directory Structure with example program Execution  Tell me the Directory Structure with example program Execution
please tell me
please tell me  i have created one table,when i close and again login, table name will be there, but its content not displayed, showing as no rows selected, please tell me the reason
Tell me - Java Beginners
Tell me   how to create a valid.js file please tell me and give the write code Thanks  Hi friend, Please give details for requirement of this "valid.js" file. For read more information http
tell me coding for this
tell me coding for this  Write an application that displays the integer equivalents of the following character...A   Java get Integer value of Character class GetIntValueOfCharacter { public static void main
plz give me answer
plz give me answer   description about string class methods   Java string methods
plz give me answer
plz give me answer   description about string class methods   Java string methods
plz give me answer
plz give me answer   description about string class methods   Java string methods
please tell me
, but its compiled and run successfully, please tell me the reason...please tell me  class Person{ int age; String name; void Person1(String g,int a){ name=g; age=a; } Person(String s,int i){ name=s; age=i; } void
please tell me
(); ^ 1 error tell me the resolution please....   import...please tell me  import java.lang.Thread; class Current{ public static void main(String ar[]){ Thread t = Thread.CurrentThread(); System.out.println
please tell me
: '}' expected ^ 2 errors, i got this error....... please tell me the resolution...please tell me  class Person{ string name; int age; void talk(){ System.out.println("my name is"+name); System.out.println
Help me quickly plz??
Help me quickly plz??  Can you help me to write code quickly this code is a java code take input as double and should use command line arguments and enhanced for statement then find the combine of the numbers plz help quickly
plz give me answer
plz give me answer  Discuss & Give brief description about string class methods   Java string methods
please tell me
)); ^ 1 error please tell me the resolution of this   Hi...please tell me  import java.io.*; class SString{ public static void main(String ar[]) throws IOException{ BufferedReader br = new Bufferedreader
please tell me
(10.6,20.0); ^ 1 error, please tell me the resolution for this...   ...please tell me  class Sample{ private double num1,num2; void sample(double x,double y){ num1=x; num2=y; } void Sum(){ double result=num1+num2
please tell me
please tell me  why we are using http protocol in servlets
please tell me
got error as Inner class connot have static declarations pls tell me...please tell me  class Producer extends Thread { StringBuffer sb; boolean dataprodover = false; Producer(){ sb = new StringBuffer(); } public void
please tell me
; ^ please tell me the resolution   class Reserve...please tell me  class Reserve extends Thread{ int available=1; int wanted; Reserve(int i){ wanted = i; } public static void
please tell me
please tell me  which cmd we use to clear the screen in sql prompt
please tell me
please tell me  why we use public static main(String ar){} in java instead of main
please tell me
please tell me  select * from emp order by 5 desc; in the above what is the meaning of 5, and what its functionality
please tell me
please tell me  Actually i am working on a Project tiitle is JavaMail System, 1)How to configure java mail API and a Demo Program for Sending mail and Receiving using JSP and Servlet
please tell me
please tell me  what are the topics in core and advaced java....   Hi Friend, Please visit the following links: http://www.roseindia.net/ http://www.roseindia.net/java/ Thanks   Hi Friend, Please visit
plz Help me - Java Beginners
plz Help me  Hi, I want learn struts,I dont have any idea about this plz help how can i make a framework.If u have any information then plz send my personal id plz tell me that whose software installed.and give me brief
please tell me
please tell me  class Person{ int age; String name; void talk(){ System.out.println("my name is:"+name); System.out.println("my age is:"+age); } } class Hash{ public static void main(String ar[]){ Person raju=new Person
please tell me
please tell me   <tr> <td><html:hidden property="tid" value="${user.id}"/></td> <td><bean:write name="user" property="emp_name"/>
plz help me for this question
plz help me for this question  Apply simplex procedure to solve the L.P.P. maximize z = 3x1 + 4x2 subject to 5x1 + 4x2 â?¤ 200; 3x1 + 5x2 â?¤ 150; 5x1 + 4x2 â?¥ 100; 8x1 + 4x2 â?­â?¥ 80, x1 â?¥ 0, x2 â?¥ 0
please tell me
please tell me  Blockquote Blockquote> BlockquoteBlockquote how to get images from ms access databases to jsp pagesBlockquote   Jsp get image from ms access database Create a table named user(id,name,address,image
please tell me
please tell me  what is the source code if user give wrong user name password the explorer will show incorrect username password   <% String vlname=request.getParameter("lname"); String vpwd=request.getParameter
Software graduates please tell me,
Software graduates please tell me,  How to view image on Frame in swing(or)awt in Java
Software graduates please tell me,
Software graduates please tell me,  How to view image on Frame in swing(or)awt in Java
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
plz help me - Java Beginners
plz help me  Deepak I can write a sessioon code plz help me admin_home.jsp page is display but data is not disply plz help me what is wrong
Plz Help Me
Plz Help Me  Write a program for traffic light tool to manage time giving between Main-Street and sub-Street. firstly, give green light for 40 seconds of the Main Street and then gives 15 second for the sub-street taking
Plz Plz reply Me - JSP-Servlet
Plz Plz reply Me  Respected Sir/madam, I am R.Ragavendran.. Actually I got your coding.. But This code is not enabling the user to click and change the image.. I request you to remember the code which you have provided for me
plz help me - Java Beginners
plz help me  Hi, I want to search all field from database using name, and display in text box, then data is update and delete. i want to search name using alphabets a-z, plz reply fast. plz help me this is very urgent
Plz give me code for this question
Plz give me code for this question  Program to find depth of the file in a directory and list all files those are having more number of parent directories
Plz send me answer quckly
Plz send me answer quckly  Respected Sir, myself is pavan shrivastava.i want ask a question that is ( we can't create object of interface then how would possible to create object
plz help me - Java Beginners
plz help me  Thanks deepak continue response..i face some problem i... is true...but i very confuse that how it is not displayed admin page plz any one give me reponse my persinal given id  Hi ragni, i am sending
facing problem plz help me out - Framework
Facing problem plz help me out  hi i am new to servlet i deployed... the web.xml file too parallel to the classes folder now i am facing this problem.plz tell me what to do... error:The requested resource (Servlet servlet
plz help me!!!!!!!! - JSP-Servlet
plz help me!!!!!!!!  i`ve set the environment varaibles for tomcat as well as jdk.. but i`m not understanding where i`ve to save my servlet..i.e.... there are compilation errors.. plz do help me.   make sure that you did
plz help me today plz plz - Java Interview Questions
plz help me today plz plz  2.) Suppose list is an array of six elements of type int. What is stored in list after the following java code executes? . for (i = 0; i < 5; i++) { list[i] = 2 * i + 5
ModuleNotFoundError: No module named 'tell-me-your-secrets'
ModuleNotFoundError: No module named 'tell-me-your-secrets'  Hi...: No module named 'tell-me-your-secrets' How to remove the ModuleNotFoundError: No module named 'tell-me-your-secrets' error? Thanks   Hi

Ads