working with buttons in applet java
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class AnAppletWithButtons extends Applet implements ActionListener {
public void init() {
button1 = new Button("Button 1");
add(button1);
button1.addActionListener(this);
button2 = new Button("Button 2");
add(button2);
button2.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == button1)
System.out.println("Button 1 was pressed");
else
System.out.println("Button 2 was pressed");
}
Button button1, button2;
}
Also in Java:
- how to set frame colo in java
- how to add element to arraylist
- generate all prime number less than n java
- what is java plug-in
- funzione random in java
- java string to integer
- HOW TO SUPRESS sonar warning in java code
- formatting an integer in java
- tolowercase java
- append to arraylist by index java
- reverse string using recursion java with explanation
- java file path linux
- how to make a list java
- even or odd in java
- java character for end of file
- java identifiers
- how to open a webpage with java
- how to check type of primitive value in java
- java make arraylist
- foreach java
- how to create a button in java
- check last character of string java
- java initialize array in one line
- java replace element in list