JAVA 记事本 设置字体 事件处理

来源:百度知道 编辑:UC知道 时间:2024/05/04 07:13:20
class SetFont extends JDialog implements ItemListener, ActionListener {
Container con;
JPanel j1, j2, j3, j4, j5, j6;
JComboBox bx1, bx2, bx3;
JButton jb1, jb2;
JLabel jl1, jl2, jl3, jl4, jl5;
String fontt1="黑体",str="12",str2;
int i=Font.PLAIN;

public SetFont() {

String[] font1 = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getAvailableFontFamilyNames();
String[] font2 = { "常规", "斜体", "粗体", "粗斜体" };
String[] font3 = { "8", "9", "10", "11", "12", "13", "14", "15",
"16", "17", "18", "19", "20", "22", "24", "26", "28", "30",
"36", "42", "50" };

bx1 = new JComboBox(font1);
bx2

看看我写的一段关于字体的
注意这里:
******************
mode += Font.BOLD;
******************
不懂hi我吧

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class CheckBoxTest {
public static void main(String[] args) {
CheckBoxFrame frame = new CheckBoxFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}

class CheckBoxFrame extends JFrame {

private JLabel label;
private JCheckBox bold;
private JCheckBox italic;
private static final int FONTSIZE = 12;

public CheckBoxFrame() {

setTitle("CheckBoxTest");
setSize(300,200);

label = new JLabel("The quick brown fox jumps over the lazy dog.");
label.setFont(new Font("Serif", Font.PLAIN, FONTSIZE));
add(label, BorderLayout.CENTER);

ActionListener listener = new Act