Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

change button text onclick 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 :: split every character in string into array java 
Java :: java string format thousand separator 
Java :: java find last element in array 
Java :: copy to clipboard android studio 
Java :: java check if enum contains value 
Java :: java get last char of string 
Java :: initialize arraylist in 1 line in java 
Java :: java isolate the numbers from string 
Java :: java variables in annotations 
Java :: hashmap key check 
Java :: create stream from array java 
Java :: java replaceall regex 
Java :: bootstrap 4 modal get event related target 
Java :: why are there no destructors in java? 
Java :: convert date to offsetdatetime in java 
Java :: java home mac 
Java :: in java how to throw exception from function 
Java :: changer version java terminal 
Java :: is upper in java 
Java :: java remove duplicates 
Java :: printing arraylist 
Java :: arraylist items into string 
Java :: convert char to string in java 
Java :: java date format with timezone 
Java :: java print array backwards 
Java :: java eclipse console clear 
Java :: compare two times in java 
Java :: how to close a jframe in netbeans 
Java :: fill two dimensional array 
Java :: remove duplicates from sorted array 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =