当然可以的  你难道没有看到WebStart界面上面就有链接吗?

解决方案 »

  1.   

    在Win32程序中,通过Win SDK可以做到,在java程序中通过swing可以实现。
      

  2.   

    用swing怎么实现,能具体一点吗?我从数据库里读数据,原来做的用JTextArea,只能显示文本,想做成超链接的,该用什么?,谢谢
      

  3.   

    显示在jbutton上,用HTML语法就可以,不过要写全。就是要写上<html><body></body></html>.如
    jbutton1.setText("<html><body><a href = http://www.163.com>www.163.com</a></body></html>");
    不过,前些日子,我研究了JEditorPane,可以让其直接显示HTML
    如下:jEditorPane1.setContentType("text/html");
    jEditorPane1.setText("<html><body><a href = http://www.163.com> Dekn </a></body></html>");你可以参考上面的代码。试一试
      

  4.   

    是呀! Java的Swing控件里是支持HTML语法的!
      

  5.   

    其实JEditorPane支持HTML的,editorPane.setPage(你的HTML文件的路径)
      

  6.   

    按照Dekn()的方法能显示出来了, 
    我要的效果是:
    比如鼠标点击Dekn文本,然后我就可以知道它对应的url,调用IE就可以浏览页面了
    怎么判断我鼠标点的文本是什么呢?
      

  7.   

    在类似ie这样的浏览器中,你想通过超连接得到下面网页的地址,也可以用下面的方法
    你只要编写一个类实现HyperlinkListener接口,在类中实现hyperlinkUpdate(HyperlinkEvent event)方法
    public void hyperlinkUpdate(HyperlinkEvent event){
        if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED){
             URL url = event.getURL();
    }
    然后将这个url转成string类型就成了,它就是下一个网页的地址。
      

  8.   

    这样的浏览器用的就是dekn提到的JEditorPane
      

  9.   

    不在JEditorPane中显示网页,是用类似下边的代码在IE中显示网页:  
    String command="c:\\Program Files\\Internet Explorer\\IEXPLORE.exe "+s;
    Runtime.getRuntime().exec(command);
    要得到的就是点击的文本对应的url,
    我用URL url = event.getURL();
    s=url.toString();
    String command="c:\\Program Files\\Internet Explorer\\IEXPLORE.exe "+s;
    Runtime.getRuntime().exec(command);
    不对
      

  10.   

    下面我给你的答案,看你在JAVA开发者上也在问这个问题。要注意以下几点:
    1、想要使JEditorPane支持LINK,必须设置其editable为false
    2、为JEditorPane加上HyperlinkListener,并从中判断其类型。即点击看下面代码:jEditorPane1.addHyperlinkListener(new Frame1_jEditorPane1_hyperlinkAdapter(this));
    contentPane.add(jEditorPane1, BorderLayout.CENTER);jEditorPane1.setContentType("text/html");
    jEditorPane1.setText("<html><body><a href = http://www.163.com> Dekn </a></body></html>");//要想JEditorPane支持链接,必须设置editable为false
    jEditorPane1.setEditable(false);void jEditorPane1_hyperlinkUpdate(HyperlinkEvent e) {
        System.err.println(e.getURL());
        //如果用户点击了link
        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
          try {
            String command="c:\\Program Files\\Internet Explorer\\IEXPLORE.exe "+e.getURL().toString();
            Runtime.getRuntime().exec(command);
          }
          catch (Exception ex) {
            ex.printStackTrace();
            System.err.println("connection error");
          }
        }
      }
    下面是我写这个范例的所有代码。
    package untitled3;import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.lang.Runtime;/**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2003</p>
     * <p>Company: </p>
     * @author Dekn
     * @version 1.0
     */public class Frame1 extends JFrame {
      JPanel contentPane;
      BorderLayout borderLayout1 = new BorderLayout();
      JEditorPane jEditorPane1 = new JEditorPane();  //Construct the frame
      public Frame1() {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      //Component initialization
      private void jbInit() throws Exception  {
        contentPane = (JPanel) this.getContentPane();
        jEditorPane1.setText("jEditorPane1");
        contentPane.setLayout(borderLayout1);
        this.setSize(new Dimension(458, 316));
        this.setTitle("Frame Title");
        jEditorPane1.addHyperlinkListener(new Frame1_jEditorPane1_hyperlinkAdapter(this));
        contentPane.add(jEditorPane1, BorderLayout.CENTER);    jEditorPane1.setContentType("text/html");
        jEditorPane1.setText("<html><body><a href = http://www.163.com> Dekn </a></body></html>");    //要想JEditorPane支持链接,必须设置editable为false
        jEditorPane1.setEditable(false);
      }
      //Overridden so we can exit when window is closed
      protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          System.exit(0);
        }
      }  void jEditorPane1_hyperlinkUpdate(HyperlinkEvent e) {
        System.err.println(e.getURL());    //如果用户点击了link
        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
          try {
            String command="c:\\Program Files\\Internet Explorer\\IEXPLORE.exe "+e.getURL().toString();
            Runtime.getRuntime().exec(command);
          }
          catch (Exception ex) {
            ex.printStackTrace();
            System.err.println("connection error");
          }
        }
      }
    }class Frame1_jEditorPane1_hyperlinkAdapter implements javax.swing.event.HyperlinkListener {
      Frame1 adaptee;  Frame1_jEditorPane1_hyperlinkAdapter(Frame1 adaptee) {
        this.adaptee = adaptee;
      }
      public void hyperlinkUpdate(HyperlinkEvent e) {
        adaptee.jEditorPane1_hyperlinkUpdate(e);
      }
    }