《Java2图形设计卷II:Swing》配套光盘源码
源代码在线查看: test.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JApplet {
public Test() {
Container contentPane = getContentPane();
Icon icon = new ImageIcon("beach_umbrella.gif");
JToggleButton button_1 = new JToggleButton(),
button_2 = new JToggleButton(icon),
button_3 = new JToggleButton(icon, true),
button_4 = new JToggleButton("beach"),
button_5 = new JToggleButton("beach",true),
button_6 = new JToggleButton("beach",icon),
button_7 = new JToggleButton("beach",icon,
true);
contentPane.setLayout(new FlowLayout());
contentPane.add(button_1);
contentPane.add(button_2);
contentPane.add(button_3);
contentPane.add(button_4);
contentPane.add(button_5);
contentPane.add(button_6);
contentPane.add(button_7);
}
}