size.java

来自「一个java记事本程序 包括新建」· Java 代码 · 共 68 行

JAVA
68
字号
/* * 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 + =
减小字号Ctrl + -
显示快捷键?