有一小段html代码,存在一个字符串中,我想用一个swing组件显示出来,这个功能如何实现呢?有现成的swing组件吗?

解决方案 »

  1.   

    显示出来?JLable.setText()就可以swing组件本身就可以用html代码显示,上次那个有回车的JButton就是这样
      

  2.   

    我想用一个swing组件显示出来这个显示是啥?显示的是html的内容吗?用JTextField,JTextArea
      

  3.   

    html为字符串,随便哪个组件,只要能用setText的,基本上就满足你的要求了.
      

  4.   

    private JEditorPane $genInfoPane;
    $genInfoPane = new JEditorPane("text/html", "<html>");
    $genInfoPane.setEditable(false);
    LookAndFeelTweaks.htmlize($genInfoPane);
    add(new JScrollPane($genInfoPane));直接用StringBuffer或者StringBuilder写噢
                    StringBuffer temp = new StringBuffer("");
    temp.append("<html><body>");
    temp.append("<b>XML Definition Version: </b>");
    temp.append($data.getXMLDefinitionVersion().toString());
    temp.append("<br>");
                    temp.append("</body></html>");
    $genInfoPane.setText(temp.toString());