用Swing的Timer类啊,定时30秒,如果按了按钮就停止Timer,时间到了就调用anotherFrame.toFront()

解决方案 »

  1.   

    <html><head><title>歼击机 </title>
    <META HTTP-EQUIV=REFRESH CONTENT='3;URL=http://www.lp622.com.cn/'></head>
    <body bgcolor=017ba9 text=FFFFEE>
    <center><h2>欢迎有空再来。<hr width=400 size=1>You have already logged out from chat room</h2><br></center>
    </body></html>上面是3秒中后自动转移,不知道是不是你要的。
      

  2.   

    我刚学java,不太懂,能否给我解释一下Timer怎么用
      

  3.   

    我用java写的是application,用jb7
      

  4.   

    这个页面跳转的问题,不用服务器端来执行,就用浏览器来执行就行了,可以减轻服务器的负担,用不到timer类,在你的页面用wjmmml(笑着悲伤) 仁兄提供的方法就够了。
      

  5.   

    可以用线程的sleep()方法来实现。
    Thread.sleep(30000);
    if(!isPressed){
      frame2.setVisible(true);//开另一个窗口
      this.dispose();//关闭当前窗口
    }
    如果点了按钮,就在按钮事件中把isPressed设为true。
      

  6.   

    class yourFrame extends JFrame implements ActionListener{
     。
     private  Timer timer = new Timer(30000, this);
     private JButton button;
     ......
     public yourFrame () {    show();
        timer.start();
     } public void actionPerformed(ActionEvent e ) {    if( e.getSource() == button ) {
           timer.stop();
        }else
        if(  e.getSource() == timer) {
           anotherFrame.show() ; // or toFront() according to your logic
        } } }
      

  7.   

    我写的是java的Application,写的图形窗口,像用VC写的MFC程序那样的外观,不在浏览器里执行
      

  8.   

    给你一个timer运用的例子,这个例子一运行会弹出一个msgbox,如果你不点它,那么每隔一秒钟会打印出一句话来.我想根据这个,你适当的改一下,就可以改成你需要的了
    你可以在你的窗体里加入一个按钮,然后这个按钮该做些什么,你应该知道怎么弄了吧
    这样的话,就实现了你要的功能
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.Timer; 
    // to resolve conflict with java.util.Timerpublic class timer
    {  
       public static void main(String[] args)
       {  
          ActionListener listener = new TimePrinter();      // construct a timer that calls the listener
          // once every 1 seconds
          Timer t = new Timer(1000, listener);
          t.start();      JOptionPane.showMessageDialog(null, "Quit program?");
          System.exit(0);
       }
    }class TimePrinter implements ActionListener
    {  
       public void actionPerformed(ActionEvent event)
       {  
          Date now = new Date();
          System.out.println("At the tone, the time is " + now);
          Toolkit.getDefaultToolkit().beep();
       }
    }