//: c14:HTMLButton.java
// Umieszczanie tekstu HTML w komponentach Swing.
// <applet code=HTMLButton width=250 height=500></applet>
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import com.bruceeckel.swing.*;
public class HTMLButton extends JApplet {
private JButton b = new JButton(
"<html><b><font size=+2>" +
"<center>Witam!<br><i>Naci¶nij mnie!");
public void init() {
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
getContentPane().add(new JLabel("<html>" +
"<i><font size=+4>Łubudu!"));
// Wymu¶ ponowne rozmieszczenie
// aby uwzględnić now± etykietę:
validate();
}
});
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
cp.add(b);
}
public static void main(String[] args) {
Console.run(new HTMLButton(), 200, 500);
}
} ///:~