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 :: how to iterate a queue in java 
Java :: java convert string to int array 
Java :: randomize 2d array java 
Java :: arraylist java 
Java :: java delete directory with files 
Java :: java file system append new line 
Java :: how to make a string lowercase in java 
Java :: string remove last character 
Java :: add stringarrays to string list java 
Java :: date format android 
Java :: java load image 
Java :: how to send get request in java 
Java :: association in java 
Java :: java detect new line in string 
Java :: how to get int from string java 
Java :: factorial program in java 
Java :: how to make a copy of an array java 
Java :: Validation failed for query for method public abstract java.util.List 
Java :: android list[i] 
Java :: java zip file 
Java :: double quotes in string java 
Java :: android add activity parent manifest 
Java :: set size button java 
Java :: max int in java 
Java :: java while loop example 
Java :: date format in java 
Java :: how to instance a calendar in java 
Java :: java median of list 
Java :: fill two dimensional array java 
Java :: min max heap java 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =