各位,别大意啊package Test2;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;import javax.swing.*;class Jie2 extends JFrame
{
JPanel contentPane;
long startTime;
public Jie2()
{
contentPane = new JPanel();
this.setContentPane(contentPane);
this.setBounds(30,30,200,200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.addWindowListener(new WindowAdapter(){
@Override
public void windowOpened(WindowEvent e)
{
startTime = System.currentTimeMillis();
do_this_showInfo();
}
});
}
public void do_this_showInfo()
{
while(true)
{
long nowTime = System.currentTimeMillis();
this.setTitle("窗体运行了 "+(nowTime-startTime)/1000+" s");
}
}
}
public class Demo2
{ /**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
try {
// TODO Auto-generated method stub
UIManager
.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
Jie2 jie2 = new Jie2();
jie2.setVisible(true);
} });
}
}呵呵,笑死我了!
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;import javax.swing.*;class Jie2 extends JFrame
{
JPanel contentPane;
long startTime;
public Jie2()
{
contentPane = new JPanel();
this.setContentPane(contentPane);
this.setBounds(30,30,200,200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.addWindowListener(new WindowAdapter(){
@Override
public void windowOpened(WindowEvent e)
{
startTime = System.currentTimeMillis();
do_this_showInfo();
}
});
}
public void do_this_showInfo()
{
while(true)
{
long nowTime = System.currentTimeMillis();
this.setTitle("窗体运行了 "+(nowTime-startTime)/1000+" s");
}
}
}
public class Demo2
{ /**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
try {
// TODO Auto-generated method stub
UIManager
.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
Jie2 jie2 = new Jie2();
jie2.setVisible(true);
} });
}
}呵呵,笑死我了!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货