一些化学方程式会用到,请大家帮忙!

解决方案 »

  1.   

    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.主要的是对这几个类的操作。
      

  2.   

    可以在程序当中嵌入HTML脚本语言,通过脚本语言实现上下标,以前我看过资料,可惜并没有太在意.
      

  3.   

    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);

    getContentPane().add(jb);
    setSize(450,500);
    setVisible(true);

    }
    public static void main(String[] args)
    {
    T app = new T();
    app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    }
      

  4.   

    如果公式很长的话,或者很复杂的话,建议用HTML完成,然后嵌入,否则一旦修改起来,你就完了