我想的是使用TOOLBAR做的浏览器的地址拦~
我想在地址拦上输入网址,然后在JEditorPane里显示相应的网页~
但是怎么我回车后没反映啊??
JEditorPane类有没有刷新的方法啊?
急.....
高手帮下忙!!!
下面编译没错~我扩展的TOOLBAR类~JEditorPane当参数传过来的~~帮忙看下哈~
public class Toolbar1 extends JToolBar implements ActionListener{
JComboBox dzhi;
JLabel l1;
JEditorPane ep;
Toolbar1(JEditorPane ep){
this.ep=ep;
l1=new JLabel("地址(D): ");
dzhi=new JComboBox();
dzhi.setEditable(true);
dzhi.addActionListener(this);
add(l1);add(dzhi);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==dzhi)
{
try {
ep.setPage("http://www.163.com");
}
catch (IOException el)
{
ep.setContentType("text/html");
ep.setText("找不到该网页");
}
catch (IllegalArgumentException ie) {}
}
}
}
我想在地址拦上输入网址,然后在JEditorPane里显示相应的网页~
但是怎么我回车后没反映啊??
JEditorPane类有没有刷新的方法啊?
急.....
高手帮下忙!!!
下面编译没错~我扩展的TOOLBAR类~JEditorPane当参数传过来的~~帮忙看下哈~
public class Toolbar1 extends JToolBar implements ActionListener{
JComboBox dzhi;
JLabel l1;
JEditorPane ep;
Toolbar1(JEditorPane ep){
this.ep=ep;
l1=new JLabel("地址(D): ");
dzhi=new JComboBox();
dzhi.setEditable(true);
dzhi.addActionListener(this);
add(l1);add(dzhi);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==dzhi)
{
try {
ep.setPage("http://www.163.com");
}
catch (IOException el)
{
ep.setContentType("text/html");
ep.setText("找不到该网页");
}
catch (IllegalArgumentException ie) {}
}
}
}
解决方案 »
- standard deviation
- 一道小题
- JavaMail乱码问题
- 对象序列化(Object Serializable)的困局
- 有关JAVA 的
- 菜鸟问题:三层循环问题请教!!!!
- 有关用纯java进行小型项目的开发的问题
- 急急急!!!!!!! 如何在 JFrame 或者 应用程序 里播放声音?????麻烦了
- 菜鸟求教!用jcreator调试java程序是不是还必须装jsdk?
- 听说微软的asp.net可以取代java,真的吗?
- 下面是一个玩骰游戏!!!能通过,但是不能出现结果!!请高手来帮忙解答。
- java中能不能直接调用windows下使用的DLL?要用JNI的话就要改动DLL的源码吗?
import java.awt.event.*;
import java.awt.event.ActionListener;
import javax.swing.SwingConstants;class Toolbar1 extends JToolBar implements ActionListener{
JComboBox dzhi;
JLabel l1;
JEditorPane ep;
Toolbar1(JEditorPane ep){
this.ep=ep;
l1=new JLabel("地址(D): ");
dzhi=new JComboBox();
dzhi.setEditable(true);
dzhi.addActionListener(this);
add(l1);add(dzhi);
add(ep); // 添加此句
}
public void actionPerformed(ActionEvent e)
{
//if(e.getSource()==dzhi)
//{
try {
ep.setPage("http://www.163.com");
}catch (IOException el){
ep.setContentType("text/html");
ep.setText("找不到该网页");
}catch (IllegalArgumentException ie) {}
//}
}
}