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

Java中可以锁住键盘吗??

楼主NoWant(NoWant)2001-11-05 22:17:53 在 Java / J2SE / 基础类 提问

请问   有   API   吗   ? 问题点数:50、回复次数:4Top

1 楼NoWant(NoWant)回复于 2001-11-06 08:43:04 得分 0

???Top

2 楼skyyoung(路人甲)回复于 2001-11-06 09:03:08 得分 50

屏幕的,要吗  
  Have   an   on-screen   clock  
   
  import   java.applet.*;  
  import   java.awt.*;  
  import   java.util.*;  
  import   java.text.*;  
   
  public   class   MyClock   extends   Applet   {  
      MyPanel   mp;  
      public   void   init()   {  
          mp   =   new   MyPanel(getParameter("format"));  
          add(mp);  
          }  
      }  
   
  class   MyPanel   extends   Panel   {  
      MyThread   tm;  
      Color   b,   f;  
      SimpleDateFormat   formatter;    
      String   previousDateText   =   "";  
      String   dateText;  
   
      MyPanel(String   df)   {  
          super();  
          formatter   =   new   SimpleDateFormat(df);  
          validate();  
          setBackground(new   Color(0).black);  
          setForeground(new   Color(0).yellow);  
          b   =   this.getBackground();      
          f   =   this.getForeground();      
          tm   =   new   MyThread(this);    
          tm.start();  
          }  
       
      public   Dimension   getPreferredSize()   {  
          return   new   Dimension  
            (this.getFontMetrics(this.getFont()).stringWidth(getNow())   +   25,   30);  
          }  
   
      public   void   paint(Graphics   g)   {  
          if   (g   !=   null)   {  
                g.setColor(b);  
                g.drawString(previousDateText,10,15);          
                g.setColor(f);  
                dateText   =   getNow();  
                g.drawString(dateText,10,15);  
                previousDateText   =   dateText;  
                }  
          }  
   
      public   String   getNow()   {      
          return   formatter.format(new   Date());  
          }  
  }  
     
  class   MyThread   extends   Thread   {  
      MyPanel   mp;  
   
      public   MyThread(MyPanel   a)   {    
          mp   =   a;  
          }  
   
    public   void   run()   {  
        while   (true)   {  
            try   {  
                mp.repaint();  
                this.sleep(1000);  
                }  
            catch(InterruptedException   e)   {   }  
            }  
        }  
  }  
     
   
   
  <HTML><HEAD></HEAD><BODY>  
  <APPLET   CODE="MyClock.class"      
                  HEIGHT=25   WIDTH=200>  
  <PARAM   NAME="format"   VALUE="yyyy-MM-dd   hh:mm:ss">                
  </APPLET><P>  
  <APPLET   CODE="MyClock.class"      
                  HEIGHT=25   WIDTH=200>  
  <PARAM   NAME="format"   VALUE="h:mm   a">                  
  </APPLET><P>  
  <APPLET   CODE="MyClock.class"      
                  HEIGHT=25   WIDTH=200>  
  <PARAM   NAME="format"   VALUE="yyyy.MMMMM.dd   GGG   hh:mm   aaa">                
  </APPLET><P>  
  <APPLET   CODE="MyClock.class"      
                  HEIGHT=25   WIDTH=200>  
  <PARAM   NAME="format"   VALUE="H:mm:ss:SSS">  
  </APPLET><P>  
  </BODY></HTML>  
     
  Top

3 楼skyyoung(路人甲)回复于 2001-11-06 09:04:48 得分 0

Set   the   computer   clock  
   
   
   
  Define   the   following   prototype   in   the   header   file   JNIEXPORT   void   JNICALL   Java_JavaHowTo_setSystemTime  
      (JNIEnv   *,   jobject,   jshort,   jshort);  
   
     
   
   
  the   JNI   function   JNIEXPORT   void   JNICALL   Java_JavaHowTo_setSystemTime  
      (JNIEnv   *env,   jobject   obj,   jshort   hour,   jshort   minutes)   {  
           
          SYSTEMTIME   st;  
   
          GetLocalTime(&st);      
          st.wHour   =   hour;              
          st.wMinute   =   minutes;      
          SetLocalTime(&st);        
  }  
     
   
   
  The   Java   JNI   wrapper   would   be   class   JavaHowTo   {  
      public   native   void   setSystemTime(   short   hour,   short   minutes);  
      static   {  
          System.loadLibrary("javahowto");    
      }  
  }  
     
   
   
  And   finally,   to   use   it   public   class   JNIJavaHowTo   {  
      public   static   void   main(String[]   args)   {  
          short   hour   =   10;  
          short   minutes   =   21;  
           
          //   this   example   will   set   the   system   at   10h21   using   the   Windows   API  
          //   SetLocalTime.    
       
          JavaHowTo   jht   =   new   JavaHowTo();  
          //   set   the   time   at   10h21  
          jht.setSystemTime(hour,   minutes);    
          }  
  }  
     
  Top

4 楼NoWant(NoWant)回复于 2001-11-06 19:41:02 得分 0

goodTop

相关问题

  • UltraEdit中 键盘被锁住了
  • 如何完全锁住键盘?
  • ~~请问,如何锁住键盘???~~
  • 您好! 请问如何锁住键盘??
  • 如何锁住电脑键盘
  • vc实现锁住键盘鼠标
  • 怎么可以锁住键盘,开启键盘!
  • 在NT/win2000下如何锁住键盘鼠标?急!
  • 我想做个锁屏的东东,怎么锁住键盘阿?
  • java中如何锁住一个文件不让其他程序修改?

关键词

得分解答快速导航

  • 帖主:NoWant
  • skyyoung

相关链接

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

广告也精彩

反馈

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