那意思是如果用java就不可能做出ultraEdit或word,
但是star office据说是java做的, 应该可以处理这种事情.
虽然我在star office下看不到几个jar文件, 而且删掉这几个jar文件,star office 也运行的很好.
但是star office据说是java做的, 应该可以处理这种事情.
虽然我在star office下看不到几个jar文件, 而且删掉这几个jar文件,star office 也运行的很好.
我下了个JEdit,也不行.有没有可以用HTML的浏览方式实现先放两天看有没高手出现.
import javax.swing.border.Border;
import javax.swing.text.html.HTMLFrameHyperlinkEvent;
import javax.swing.text.html.HTMLDocument;
import javax.swing.event.HyperlinkListener;
import javax.swing.event.HyperlinkEvent;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
import java.awt.*;/**
* @author xiaoyusong
* User: Administrator
* Date: 2004-5-27
* Time: 11:50:27
*
*/
public class Explore {
public Explore() {
init();
}
protected void init() {
gbc.fill = GridBagConstraints.HORIZONTAL;
//gbc.weightx = 10;
//gbc.weighty = 10;
gbc.ipadx = 5;
gbc.ipady = 5;
rootPanel.setLayout(gbl); setTitle("hello world"); jtp.setContentType("text/html;charset=gb2312");
jtp.setText("导入中,请稍等");
jtp.addHyperlinkListener(new Hyperactive());
//JScrollPane sp = new JScrollPane();
//jtp.setSize(sp.getSize().width, sp.getSize().height);
//sp.add(jtp);
addComponent(jtp,0,0,1,1);
} /**
* 添加组件到顶部的面板中
* @param c 要添加的swing组件
* @param x GridBagLayout的x轴坐标
* @param y GridBagLayout的y轴坐标
* @param w 组件将会占用的宽度
* @param h 组件将会占用的高度
*/
public void addComponent(Component c, int x, int y, int w, int h)
{
gbc.gridx = x;
gbc.gridy = y;
gbc.gridwidth = w;
gbc.gridheight = h;
rootPanel.add(c, gbc);
rootPanel.revalidate();
} /**
* 设置Root面板(JPanel)的标题
* @param title
*/
public void setTitle(String title) {
Border border = BorderFactory.createTitledBorder(title);
rootPanel.setBorder(border);
} public void setEditable(boolean editable) {
jtp.setEditable(editable);
} public void setPage(String url) throws MalformedURLException, IOException {
jtp.setPage(new URL(url));
} public JPanel getRootPanel(){
return rootPanel;
} public static void main(String[] args) throws Exception { Explore el = new Explore();
el.setPage("http://news.sina.com.cn/c/2004-05-27/10033347469.shtml");
el.setEditable(false); JFrame frame = new JFrame();
frame.getContentPane().add(el.getRootPanel());
frame.show();
} class Hyperactive implements HyperlinkListener { public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
JEditorPane pane = (JEditorPane) e.getSource();
if (e instanceof HTMLFrameHyperlinkEvent) {
HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
HTMLDocument doc = (HTMLDocument) pane.getDocument();
doc.processHTMLFrameHyperlinkEvent(evt);
} else {
try {
pane.setPage(e.getURL());
} catch (Throwable t) {
t.printStackTrace();
}
}
}
}
} private JEditorPane jtp = new JEditorPane(); //JTextPane
private JPanel rootPanel = new JPanel();
private GridBagLayout gbl = new GridBagLayout();
private GridBagConstraints gbc = new GridBagConstraints();}
操作系统不支持中文系统的话, 你看到的中文只能是乱码.
java本身是没法调用自己指定的或自己的字体库来显示文本.不知我说的对否, 还请指教