Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java onclick event

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

public class JButtonExample
{
  public static void main(String[] args) 
  {
    JFrame frame = new JFrame("ActionListener Example");
    JButton btn = new JButton("Click here");
    btn.setBounds(70,80,100,30);
    //Change button text on click
    btn.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent ae) {
                      btn.setText("OK");
       }
    });
    frame.add(btn);
    frame.setSize(250,250);
    frame.setLayout(null);
    frame.setVisible(true);  
  }
}
Comment

button onclick java

public void actionPerformed(ActionEvent e) {
  
if(e.getSource()==button)  {
    button.setText("Button Clicked!");
  
}}
Comment

PREVIOUS NEXT
Code Example
Java :: button change text java 
Java :: button getsource 
Java :: commenting in java 
Java :: check if user has internet connection in kotlin 
Java :: java timeout 
Java :: breadth first search bst java 
Java :: throw and throws keyword in java 
Java :: java check if property exists in class 
Java :: read file from resources java 
Java :: java how to print out a string in uppercase 
Java :: java string vs stringbuilder 
Java :: java list last element 
Java :: java boucle for 
Java :: regular expression java 
Java :: static class java 
Java :: If you are using the git profile, you need to set a Git URI in your configuration. If you have set spring.cloud.config.server.bootstrap=true, you need to use a composite configuration. 
Java :: program to check if the given date is in in the format dd/mm/yyyy java 
Java :: main method in java 
Java :: get all enum values java 
Java :: spring security logging 
Java :: final vs static keyword in java 
Java :: check if char is letter or digit 
Java :: java break and continue 
Java :: How to implement the A* shortest path algorithm, in Java? 
Java :: generate random number in java within a range without repeating with android studio 
Java :: encoding utf 
Java :: Button loginButton = new Button(this); loginButton.setText("Login"); Button register Button = new Button(this); register Button .gettext("Register"); 
Java :: get SecretKey from String 
Java :: compress a directory in java 
Java :: jmeter set var jsr 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =