Mega Code Archive

 
Categories / Java / Swing JFC
 

Changing the Label of a JButton Component

import javax.swing.JButton; public class Main {   public static void main(String[] argv) throws Exception {     JButton button = new JButton();     // Change the label     button.setText("New Label");     // Remove the label; this is useful for a button with only an icon     button.setText(null);   } }