Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Updates a JLabel when a button is clicked.
# cheerpj/demo/LabelUpdate.java
import javax.swing.*;
import java.awt.event.*;
public class LabelUpdate {
public static void main(String[] args) {
JFrame frame = new JFrame("Label Update");
JLabel label = new JLabel("Initial Text");
JButton button = new JButton("Update");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
label.setText("Updated Text");
}
});
frame.setLayout(new java.awt.FlowLayout());
frame.add(label);
frame.add(button);
frame.setSize(300,100);
frame.setVisible(true);
}
}CheerpJ is a WebAssembly-based Java-to-JavaScript/WebAssembly compiler and runtime that allows running unmodified Java applications directly inside the browser without plugins. It converts Java bytecode into WebAssembly + JavaScript, enabling full client-side execution of existing JVM applications, applets, and libraries.
Origin & Creator
CheerpJ is developed by Leaning Technologies, known for compiling traditional languages to modern web targets like WebAssembly.
Industrial Note
CheerpJ is heavily used by enterprises wanting to preserve legacy Java Swing/AWT applications or Java applets and make them run in modern browsers without rewriting them.