📄 fonthandle.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
public class FontHandle implements ActionListener{
MyNotePad nt;
public FontHandle(MyNotePad nt)
{
this.nt=nt;
}
public void actionPerformed(ActionEvent e)
{
FontDialog fd=new FontDialog(nt);
fd.setVisible(true);
SimpleAttributeSet attr = new SimpleAttributeSet();
StyleConstants.setFontFamily(attr,fd.getFontName());
StyleConstants.setFontSize(attr,fd.getFontSize());
StyleConstants.setForeground(attr,fd.getColor());
nt.tp.setCharacterAttributes(attr,false);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -