📄 linespace.java
字号:
/* * linespace.java * * Created on 2005年11月22日, 下午12:50 */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 linespace extends JFrame implements ActionListener{ float linespace; JLabel lb=new JLabel("请输入行距"); JTextField number=new JTextField(5); JRadioButton line=new JRadioButton("行(单位)"); JRadioButton pels=new JRadioButton("象素(单位)"); JButton OK=new JButton("确定"); ButtonGroup group=new ButtonGroup(); AttributeSet normal=new SimpleAttributeSet(); MutableAttributeSet Mutable_normal=new SimpleAttributeSet(); JTextPane temp=new JTextPane(); ///////////////////////////////////////////////////////////////////// public linespace(JTextPane textPane) { Container cp=getContentPane(); cp.setLayout(new FlowLayout()); cp.add(lb); cp.add(number); cp.add(line); cp.add(pels); cp.add(OK); group.add(line); group.add(pels); setSize(200,150); setLocation(500,300); temp=textPane; line.addActionListener(this); pels.addActionListener(this); OK.addActionListener(this); } ///////////////////////////////////////////////////////////// public void actionPerformed(ActionEvent e) { Object eventSource=e.getSource(); if(eventSource==OK) { if(line.isSelected()){ linespace=Integer.valueOf(number.getText()); Mutable_normal = new SimpleAttributeSet(); //行间距设置 StyleConstants.setLineSpacing(Mutable_normal, linespace); temp.setParagraphAttributes(Mutable_normal,false); } if(pels.isSelected() ){ linespace=Integer.valueOf(number.getText()); normal=temp.getCharacterAttributes(); linespace=linespace/StyleConstants.getFontSize(normal); StyleConstants.setLineSpacing(Mutable_normal, linespace); //行间距设置 temp.setParagraphAttributes(Mutable_normal,false); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -