Java Reference
In-Depth Information
ch18/choice/FontViewer.Java
1
import
javax.swing.JFrame;
2
3 /**
4
This program allows the user to view font
effects.
5 */
6
public class
FontViewer
7 {
8
public static void
main(String[] args)
9 {
10 JFrame frame =
new
FontViewerFrame();
11 frame.setDefaultCloseOperation(JFrame.EXIT_ON
12 frame.setTitle(
ÐFontViewerÑ
);
13 frame.setVisible(
true
);
14 }
15 }
794
795
ch18/choice/FontViewerFrame.java
1
import
java.awt.BorderLayout;
2
import
java.awt.Font;
3
import
java.awt.GridLayout;
4
import
java.awt.event.ActionEvent;
5
import
java.awt.event.ActionListener;
6
import
javax.swing.ButtonGroup;
7
import
javax.swing.JButton;
8
import
javax.swing.JCheckBox;
9
import
javax.swing.JComboBox;
10
import
javax.swing.JFrame;
11
import
javax.swing.JLabel;
12
import
javax.swing.JPanel;
13
import
javax.swing.JRadioButton;
14
import
javax.swing.border.EtchedBorder;
15
import
javax.swing.border.TitledBorder;
16
17 /**
18
This frame contains a text field and a
control panel
19
to change the font of the text.