import java.awt.*;
import javax.swing.*;
/**
* 字体格式设置对话框
*/
public class FontFormat extends Dialog {
private JLabel nameLb;
private JLabel styleLb;
private JLabel sizeLb;
private JTextField nameTx;
private JTextField styleTx;
private JTextField sizeTx;
private JList nameLt;
private JList styleLt;
private JList sizeLt;
private JScrollPane jScrollPane1;
private JScrollPane jScrollPane2;
private JScrollPane jScrollPane3;
private JButton approve;
private JButton cancel;
private JFrame frame;
public Font font;
//字体‘逻辑名’集
private String[] fontNameSet = new String[]
{"Arial","Arial Black","Arial Narrow","Book Antiqua","Bookman Old Style",
"Bookshelf Symbol 7","Century Gothic","Comic Sans Ms","Courier New",
"Dialog","DialogInput","Dotum","DotumChe","FangSong_GB2312",
"Franklin Gothic Medium","FZShuTi","FZYaoTi","Garamond","Georgia",
"Gulim","GulimChe","Haettenschweiler","Impact","KaiTi_GB2312",
"Kingsoft Phonetic Plain","LiSu","Lucida Bright","Lucida Console",
"Lucida Sans","Lucida Sans Typewriter","Lucida Sans Unicode","Marlett",
"Microsoft Sans Serif","MingLiU","Monospaced","Monotype Corsiva",
"MS Gothic","MS PGothic","MS Reference Sans Serif","MS Reference Specialty",
"MS UI Gothic","MV Boli","NSimSun","Palatino Linotype","PMingLiU",
"SansSerif","Serif","SimHei","SimSun","Simsun (Founder Extended)",
"Simsun-PUA","STCaiyun","STFangsong","STXihei","TXingkai","STXinwei",
"STZhongsong","Symbol","Tahoma","Times New Roman","Trebuchet MS","Verdana",
"Webdings","Wingdings","Wingdings 2","Wingdings 3","YouYuan"};
//字体‘样式’集的字符串数组
private String[] fontStyleSet =
{"Plain","Italic","Bold","Bold Italic"};
//字体‘样式’集的常量数组
private Integer[] fontCon = {Font.PLAIN,Font.ITALIC,Font.BOLD,Font.BOLD|Font.ITALIC};
//字体‘大小’集
private String[] fontSizeSet =
{"6","7","8","9","10","11","12","14","16",
"18","20","22","24","26","28","36","48","72"};
/**
* 无参构造器
*/
public FontFormat() {
initGUI();
}
/**
* 传入父窗口引用的带参构造器
*/
public FontFormat(JFrame frame){
this.frame = frame; //父窗口中必须有一个public的Font对象
initGUI();
}
/**
* 字体格式选择器的界面初始化
*/
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setTitle("字体格式");
getContentPane().setLayout(null);
{
nameLb = new JLabel();
getContentPane().add(nameLb);
nameLb.setText("字体:");
nameLb.setBounds(34, 24, 90, 26);
nameLb.setFont(new java.awt.Font("SimSun",1,14));
}
{
styleLb = new JLabel();
getContentPane().add(styleLb);
styleLb.setText("字型:");
styleLb.setBounds(160, 24, 82, 23);
styleLb.setFont(new java.awt.Font("SimSun",1,14));
}
{
sizeLb = new JLabel();
getContentPane().add(sizeLb);
sizeLb.setText("大小:");
sizeLb.setBounds(273, 23, 54, 24);
sizeLb.setFont(new java.awt.Font("SimSun",1,14));
}
{
nameTx = new JTextField();
getContentPane().add(nameTx);
nameTx.setBounds(34, 54, 90, 22);
}
{
styleTx = new JTextField();
getContentPane().add(styleTx);
styleTx.setBounds(160, 54, 70, 21);
}
{
sizeTx = new JTextField();
getContentPane().add(sizeTx)