您的位置:首页 > 其它

提醒软件【送给她】——如果工作时间长了,提醒一下,该休息一下了,休息时长可设置,单位是秒

2013-05-07 19:29 295 查看


这是一个工作时长提醒软件,仅仅是实现了提醒的部分,单该程序启动时,就会出现一个很大的背景,覆盖整个桌面,并进行计时操作,提醒您,该休息了,休息的时长可进行设置,在config.properties中设置,单位是秒。当提醒时间到了的时候,关闭按钮就被出发,此时可以关闭。

当然像这种东西,你真要关闭,什么软件都起不了作用,你懂得。

仅仅作为一种善意的提醒,作用是相对的,没有绝对的。



这个软件需要你优先安装JDK,并进行正确的配置,然后在windows中设置计划任务,你可以设置1个小时运行一次,或者几个小时运行一次,根据自身情况而定。

http://article.pchome.net/content-1495102.html

http://blog.csdn.net/usherhll/article/details/6681205

根据以上内容进行计划任务设置。

主体代码如下:

package love;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;

import javax.swing.*;

public class MainFrame {

private static JFrame frame = new JFrame("");

private static JLabel info = new JLabel("", JLabel.CENTER);

private static int width = (int) (Toolkit.getDefaultToolkit()
.getScreenSize().getWidth());

private static int height = (int) (Toolkit.getDefaultToolkit()
.getScreenSize().getHeight());

private static Font font = new Font("黑体", Font.BOLD, 60);

private static JButton button = new JButton("关闭");

private static JLabel time = new JLabel("",JLabel.CENTER);

public static void run() {
// TODO Auto-generated method stub
frame.setLayout(new GridLayout(3, 1));
// 隐藏标题栏
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
info.setForeground(Color.RED);
info.setText(Util.showNow(new Date()));
info.setFont(font);
time.setForeground(Color.RED);
time.setFont(font);
button.setFont(font);
button.setBorderPainted(false);
button.setBorder(BorderFactory.createRaisedBevelBorder());
Dimension preferredSize = new Dimension(100, 50);// 设置尺寸
button.setPreferredSize(preferredSize);

frame.add(info);
frame.add(time);
frame.add(button);
button.setEnabled(false);
int count = Integer.parseInt(Util.get("resttime"));
frame.setVisible(true);
frame.setLocation(0, 0);
frame.setSize(width, height);
frame.setResizable(false);
int i=0;
while (count >= 0) {
if (count % 5 == 0) {
info.setText("现在北京时间:"+Util.showNow(new Date()));
}
try {
Thread.sleep(1000);
count--;
i++;
time.setText(i+" 秒过去了");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (count <= 0) {
button.setEnabled(true);
time.setText(Util.get("resttime")+" 秒的休息时间结束了,你可以选择工作了!O(∩_∩)O");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.exit(0);
}
});
}
}
}


谢谢支持!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐