javax.swing.textJEditorPaneDefaultStyledDocumentStyleConstants static void setSubscript(MutableAttributeSet a, boolean b) Sets the subscript attribute. static void setSuperscript(MutableAttributeSet a, boolean b) Sets the superscript attribute.主要的是对这几个类的操作。
可以在程序当中嵌入HTML脚本语言,通过脚本语言实现上下标,以前我看过资料,可惜并没有太在意.
import javax.swing.*; import java.awt.BorderLayout;public class T extends JFrame { public T() { super("上下标测试"); JButton jb = new JButton("<html>C<sub>5</sub><sup>2</sup><html>="+4*5);
static void setSubscript(MutableAttributeSet a, boolean b)
Sets the subscript attribute.
static void setSuperscript(MutableAttributeSet a, boolean b)
Sets the superscript attribute.主要的是对这几个类的操作。
import java.awt.BorderLayout;public class T extends JFrame
{
public T()
{
super("上下标测试");
JButton jb = new JButton("<html>C<sub>5</sub><sup>2</sup><html>="+4*5);
getContentPane().add(jb);
setSize(450,500);
setVisible(true);
}
public static void main(String[] args)
{
T app = new T();
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}