OnJava8-Examples/gui/HTMLButton.java

25 lines
657 B
Java
Raw Normal View History

2015-04-20 15:36:01 -07:00
//: gui/HTMLButton.java
// Putting HTML text on Swing components.
import javax.swing.*;
import java.awt.*;
import static net.mindview.util.SwingConsole.*;
public class HTMLButton extends JFrame {
private JButton b = new JButton(
"<html><b><font size=+2>" +
"<center>Hello!<br><i>Press me now!");
public HTMLButton() {
2015-05-06 12:09:38 -07:00
b.addActionListener(e -> {
2015-05-05 14:05:39 -07:00
add(new JLabel("<html>" +
"<i><font size=+4>Kapow!"));
// Force a re-layout to include the new label:
validate();
2015-04-20 15:36:01 -07:00
});
setLayout(new FlowLayout());
add(b);
}
public static void main(String[] args) {
run(new HTMLButton(), 200, 500);
}
} ///:~