CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Java >  J2SE / 基础类

能在applet的菜单里做个超连接吗?

楼主oldchief(不会)2001-11-23 11:36:49 在 Java / J2SE / 基础类 提问

问题点数:20、回复次数:7Top

1 楼javanew(我是java新手)回复于 2001-11-23 11:41:06 得分 0

我想肯定可以的   Top

2 楼oldchief(不会)回复于 2001-11-23 11:47:57 得分 0

呵呵,答案呢   ?给你分Top

3 楼oldchief(不会)回复于 2001-11-23 13:05:22 得分 0

那位知道啊,指点一下,一定给分!Top

4 楼jeagle(欢乐英雄)回复于 2001-11-23 13:54:54 得分 10

给我分吧,前几天我刚做了一个  
  getAppletContext().showDocument(new   URL(urlstring),   "window");  
  而且成功了  
  快给分Top

5 楼vince_xu(我是菜鸟我怕谁)回复于 2001-11-23 14:06:36 得分 0

liuzhuTop

6 楼skyyoung(路人甲)回复于 2001-11-23 14:42:02 得分 10

Goto   to   a   new   URL   from   an   Applet  
  You   have   to   use   getAppletContext().showDocument  
            (new   URL("http://www.whatever.com"));  
     
   
   
  or  
  getAppletContext().showDocument  
            (new   URL("http://www.whatever.com"),"HTML   frame   ID");  
     
   
   
  NOTE:   If   "HTML   frame   ID"   do   not   exists   then   a   new   browser   window   will   be   opened.  
   
  For   example,   we   want   to   display   lowres.html   page   if   resolution   is   640x480   else   the   hires.html   is   used.  
  import   java.applet.*;          
  import   java.awt.*;  
  import   java.net.*;  
   
  public   class   whatres   extends   Applet   {  
      public   void   init()   {  
          Dimension   dim   =   Toolkit.getDefaultToolkit().getScreenSize();  
          if   (dim.width==640   &&   dim.height==480)   {  
                try   {  
                    getAppletContext().showDocument  
                        (new   URL(getCodeBase()+"lowres.html"),"_top");  
                    }  
                catch   (Exception   ex)   {}  
              }  
          else   {  
                try   {  
                    getAppletContext().showDocument  
                        (new   URL(getCodeBase()+"hires.html"),"_top");  
                    }  
                catch   (Exception   ex)   {}  
              }  
      }  
  }  
     
   
   
   
  NOTE:   The   previous   example   works   only   so   long   as   the   document   was   retrieved   without   specifying   an   actual   document   name,   since   getDocumentBase()   returns   the   full   URL   including   the   name   of   the   document.   If   the   document   name   was   specified,   you   should   try   something   like   this   or   specify   the   complete   URL   (thanks   to   Rob   Judd):   :  
   
      try   {  
          String   docString   =   getDocumentBase().toString();  
          if   (docString.endsWith("/"))   {  
              getAppletContext().showDocument  
                  (new   URL(getDocumentBase()+"lowres.html"),   "_top");  
                  }    
          else   {  
              getAppletContext().showDocument  
                  (new   URL(getDocumentBase()+"/../lowres.html"),   "_top");  
                  }  
          }    
          catch   (Exception   e)   {}  
   
     
   
   
  Another   example,   type   a   new   URL   in   a   textfield,   and   press   a   button   to   go   to   that   page.  
  import   java.applet.*;  
  import   java.awt.*;  
  import   java.awt.event.*;  
  import   java.net.*;  
   
  public   class   GotoURLButton   extends   Applet   implements  
          ActionListener   {  
      Button   b;  
      TextField   t;  
       
      public   void   init()   {  
            t   =   new   TextField(20);  
            add(t);  
            b   =   new   Button("Go   to   this   URL");  
            add(b);  
            b.addActionListener(this);  
            }  
       
      public   void   actionPerformed(ActionEvent   ae)   {  
            if   (ae.getSource()   ==   b)   {  
                try   {  
                    getAppletContext().showDocument(new   URL(t.getText()));  
                    }  
                catch   (Exception   e)   {  
                    e.printStackTrace();  
                    }  
                }  
            }  
      }  
   
     
   
  Top

7 楼oldchief(不会)回复于 2001-11-23 16:01:16 得分 0

我按照上面的方法作了,但怎么出现错误,说是class   URL没有被发现Top

相关问题

  • 我想用一个超连接菜单,不知道怎样写?
  • 在applet中实现文字超连接
  • 系统菜单连接问题?
  • 怎样在applet中实现文字超连接
  • applet连接sqlserver出错?
  • 超连接与SQL
  • SQL 连接超时,连接池…………
  • 如何在网页中,点击某个连接,弹出菜单?
  • IE的右键菜单里怎么没有连接属性?
  • SolpartMenu菜单连接定向问题(在线等)

关键词

  • .net
  • html
  • showdocument
  • getappletcontext
  • applet
  • dim
  • new url
  • import java

得分解答快速导航

  • 帖主:oldchief
  • jeagle
  • skyyoung

相关链接

  • CSDN Java频道
  • Java类图书
  • Java类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo