Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

change button text java

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 change text java

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

change button text by id click java

<input type="button" value="Button Text" id="myButton1"></input> 
Comment

PREVIOUS NEXT
Code Example
Java :: print double without decimal java 
Java :: java.util.HashMap has generic type parameters, please use GenericTypeIndicator instead 
Java :: centos 8 install java 16 
Java :: do statement java 
Java :: enum values to string array 
Java :: java how to create an array 
Java :: phone number format java 
Java :: what is jvm jdk and jre 
Java :: java math ceil 
Java :: how to get elements of a list in java 
Java :: java concatenate strings 
Java :: how to name loops in java 
Java :: android studio remove button onclick 
Java :: read qr code from image java 
Java :: regex double quote java 
Java :: arraylist 
Java :: on item click listener for recyclerview adapter 
Java :: java get enum by ordinal 
Java :: android view set padding programmatically 
Java :: selection sort linked list java 
Java :: java string equal 
Java :: color class android 
Java :: what is constructor in java 
Java :: Android Number Picker format JAVA 
Java :: System.out.println("j= 6"); 
Java :: variable is multiple of 3 
Java :: Java display form 
Java :: Java system load from resources 
Java :: change attributes of player spigot 
Java :: java bogo sort 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =