关于JEditPane的使用问题

liuchuan 2003-10-23 09:07:07
源程序如下:

// JEditorPane.java

import javax.swing.text.*;
import javax.swing.*;
import java.io.*;
import java.awt.*;

public class JEditorPane {

public static void main(String[] args) {

JEditorPane jep = new JEditorPane();
jep.setEditable(false);

try {
jep.setPage("http://www.sina.com.cn");
}
catch (IOException e) {
jep.setContentType("text/html");
jep.setText("<html>Could not load http://www.sina.com.cn </html>");
}

JScrollPane scrollPane = new JScrollPane(jep);
JFrame f = new JFrame("www.sina.com.cn - 新浪");
f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
f.setContentPane(scrollPane);
f.setSize(512,342);
f.show();
}
}

编译时关于JEditPane的方法(setEditable(),setPage()等)都说找不到,我明明已经引入了javax.swing.text.*了,而且也没有说找不到JEditPane,那为什么找不到方法?
...全文
54 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuchuan 2003-10-24
  • 打赏
  • 举报
回复
不知怎么回事又能运行了,呵呵,谢谢!
liuchuan 2003-10-24
  • 打赏
  • 举报
回复
我把类名改成JEditorPaneTest,声明也改为javax.swing.text.JEditorPane jep = new JEditorPane(),不过提示一个错误,
"cannot resolve symbol
symbol: class JEditorPane
location: package text

继续求救!
iamwls 2003-10-23
  • 打赏
  • 举报
回复
JEditorPane 和你的类名重复了,如果需要引用,可以这样声明

public static void main(String[] args) {

javax.swing.text.JEditorPane jep = new JEditorPane();
jep.setEditable(false);

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧