📄 size.java
字号:
/* * size.java * * Created on 2005年11月21日, 下午9:35 */package examples.mynote;/** * * @author leafyoung */import java.awt.*;import javax.swing.*;import java.awt.event.*;import javax.swing.event.*;import javax.swing.text.*;public class size extends JFrame implements ActionListener{ int size; String sizearr[]={"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24"}; JList lis=new JList(sizearr); JLabel lb=new JLabel(); JButton OK=new JButton("确定"); MutableAttributeSet normal; JTextPane temp=new JTextPane(); /////////////////////////////////////////////// public size(JTextPane textPane) { Container cp=getContentPane(); cp.setLayout(new BorderLayout()); lis.setVisibleRowCount(3); lis.setBorder(BorderFactory.createTitledBorder("请选择字体大小")); cp.add(lb,BorderLayout.NORTH); cp.add(new JScrollPane(lis),BorderLayout.CENTER); cp.add(OK,BorderLayout.SOUTH); setSize(200,300); setLocation(500,300); temp=textPane; OK.addActionListener(this); } //////////////////////////////////////////////////////// public void actionPerformed(ActionEvent e) { Object eventSource=e.getSource(); if(eventSource==OK) { int index=lis.getSelectedIndex(); size=index+1; } normal = new SimpleAttributeSet(); //字体大小设置 StyleConstants.setFontSize(normal, size); temp.setCharacterAttributes(normal,false); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -