不懂,请高手过来看下!!急!!!

kuan_ren kuan_ren 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.text.*;
import java.text.SimpleDateFormat;


public class NewFrame extends JFrame
{
JLabel lab1=new JLabel("设置日期:");
JLabel lab2=new JLabel("设置时间:");
JLabel lab3=new JLabel(" 标题:");
JTextField tf1=new JTextField();
JTextField tf2=new JTextField();
JTextField tf3=new JTextField();
JTextArea ta=new JTextArea();
JButton btnQue=new JButton("确定");
JButton btnCancle=new JButton("取消");
JLabel lab4=new JLabel(" ");
JLabel labCue = new JLabel("");


public NewFrame()
{
super();
setSize(500,600);
Container conn=getContentPane();
conn.setBounds(0,0,450,450);


lab1.setFont(new Font("宋体",Font.BOLD,15));
lab2.setFont(new Font("宋体",Font.BOLD,15));
lab3.setFont(new Font("宋体",Font.BOLD,15));

lab1.setBounds(20,20,90,20);
lab2.setBounds(20,60,90,20);
lab3.setBounds(20,100,90,20);
tf1.setBounds(100,20,200,20);
tf2.setBounds(100,60,200,20);
tf3.setBounds(100,100,200,20);
conn.add(lab1);
conn.add(tf1);
conn.add(lab2);
conn.add(tf2);
conn.add(lab3);
conn.add(tf3);
JScrollPane scroll=new JScrollPane(ta);
scroll.setBounds(20,150,400,200);
conn.add(scroll);
btnQue.setBounds(20,400,90,20);

ButtonHandler handler = new ButtonHandler();
btnQue.addActionListener(handler);
conn.add(btnQue);


btnCancle.setBounds(130,400,90,20);


conn.add(btnCancle);

conn.add(labCue);
labCue.setBounds(20,430,240,30);

lab4.setBounds(20,480,150,20);
conn.add(lab4);





SimpleDateFormat dateformatD=new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat dateformatT=new SimpleDateFormat("HH:mm:ss");
Date date=new Date();
String now=(dateformatD.format(date)).toString();
String now1=(dateformatT.format(date)).toString();
tf1.setText(now);
tf2.setText(now1);

btnCancle.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{

System.exit(0);
}
});
}
private class ButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btnQue)
{

String sql=" ";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
JOptionPane.showMessageDialog(new Frame(),"确定");
String source="jdbc:odbc:xie";
Connection con=DriverManager.getConnection(source);
con.setAutoCommit(true);
Statement stmt=con.createStatement();

tf1.getText();
tf2.getText();
tf3.getText();
sql="INSERT INTO Table1(date, time, lab, thing) VALUES ('"+tf1.getText()+"', '"+tf2.getText()+"', '"+tf3.getText()+"', '"+ta.getText()+"')";
stmt.executeUpdate(sql);
labCue.setForeground(Color.green);
labCue.setText("数据插入成功");

long oldTime = System.currentTimeMillis();//现记录当前程序启动时的时间,然后启动线程
CountTime ct = new CountTime( oldTime );
//System.out.println( oldTime );
ct.start();



}catch(Exception ew)
{
labCue.setForeground(Color.RED);
labCue.setText("数据插入失败");
}
}
}
}


public void rePaint()
{
tf3.setText(" ");
ta.setText(" ");
}
public static void main(String[] args)
{
NewFrame newframe=new NewFrame();
newframe.setVisible(true);
}




class CountTime extends Thread
{
long oldTime = 0;

CountTime( long oldTime )
{
this.oldTime = oldTime;
}

public void run()
{
while(true)
{
//get recent system time
long newTime = System.currentTimeMillis();
//System.out.println( newTime );

if( newTime== Double.parseDouble(tf2.getText()))
{
JOptionPane.showMessageDialog( new Frame(), "TIME OUT" );
System.exit( 0 );
}
}
}
}

}
帮忙看下这段代码中的Thread类有没有写错?我要实现的功能是从tf2中得到要弹出提醒的时间,然后和系统当前时间对比,若相等则弹出提醒,帮忙!急用!!!
...全文

相关推荐

可以按键控制豆子吃!!!WSAD四个键控制前后左右吃豆!!空格可以控制停止吃豆!!吃豆子

可以按键控制豆子吃!!!WSAD四个键控制前后左右吃豆!!空格可以控制停止吃豆!!可以按键控制豆子吃!!!WSAD四个键控制前后左右吃豆!!空格可以控制停止吃豆!!可以按键控制豆子吃!!!WSAD四个

w739144851

MIKE水动力笔记9_大潮小潮对应的涨急落急时刻流场图

本博文主要讲解如何确定大潮日、小潮日,及分别对应的涨急、落急时刻。

晏长街

急采购物品请购单DOC

**内容结构**:一份完整的急采购物品请购单可能包括请购人、部门、物品描述、数量、单价、总价、紧急程度、预计到货日期、审批流程等相关字段。6.

weixin_38697940

图像处理软件(1) 几款打包 必下!!!绝对实用!!网上工具很多都不能用!!这几款功能强大!!极力推荐!!因为只能上传15M以内的文件 所以分几次!有的大文件不能上传!请谅解!

图像处理软件 几款打包 必下!!!绝对实用!!网上工具很多都不能用!!这几款功能强大!!极力推荐!!因为只能上传图像处理软件 几款打包 必下!!!绝对实用!!网上工具很多都不能用!!这几款

Sam·

ubuntu20.04环境下cmake安装说明(转载请注明出处,谢谢!!!)

ubuntu20.04环境下cmake安装说明(转载请注明出处,谢谢!!!)

滁州千丝万缕
评论 2
收藏 已收藏
分享
返回顶部
kuan_ren
Java SE 62,620 成员 307,251 内容