番茄时间管理 - java Swing版

介绍番茄时间管理法的原理及具体实施步骤,包括25分钟专注工作、短暂休息等周期循环,有助于提升个人工作效率。

番茄时间管理法(Pomodoro Technique):一个番茄是如何让你工作更有效率的

如果你经常读一些关于提高工作效率或时间管理类的博客,一定听说过番茄时间管理法(Pomodoro Technique)。这是一种极好的帮助你集中注意力、获得更高工作效率的方法。

基本上,它的实施方法是这样的:

  1. 确定你想要做什么(例如:翻译一篇外文)。
  2. 设定一个25分钟的定时器。
  3. 工作,直到定时器时间到:这就是一个“番茄钟”。
  4. 休息5分钟,继续下一个番茄钟
  5. 每4个番茄钟做一次长时间的休息。

大多数人都会对其做一些细微调整来适应自己:例如,你可以选择每两个番茄钟——而不是四个,做一次长时间的休息。这特别是你刚开始应用这种方法时。

更详细的看这里:http://www.aqee.net/pomodoro-technique/


软件使用到的方法:

界面圆角实现代码:

//圆角
		AWTUtilities.setWindowShape(this,
				new RoundRectangle2D.Double( 0.0D, 0.0D,
						getWidth(),
						getHeight(), 26.0D, 26.0D));

隐藏Frame标题代码:

setUndecorated(true);


自己实现的标题,标题是一个panel,给标题增加了鼠标点击移动的事件:

public class MouseMoveListener extends MouseAdapter implements MouseMotionListener {
	private Component parentComponent;
	private Component dragCom;
	private Point offset;

	public synchronized void install(Component comp,Component dragCom) {  
        uninstall();  
        parentComponent = comp;
        this.dragCom = dragCom;  
        dragCom.addMouseListener(this);  
        dragCom.addMouseMotionListener(this);  
    }  
  
    public synchronized void uninstall() {  
        if (dragCom != null) {  
            dragCom.removeMouseListener(this);  
            dragCom.removeMouseMotionListener(this);  
            dragCom = null;  
        }  
    }  
    
	@Override
	public void mousePressed(MouseEvent e) {
		if (e.getSource() == dragCom)  
            offset = e.getPoint();
	}

	@Override
	public void mouseDragged(MouseEvent e) {
		if (e.getSource() != dragCom)  
            return;  
        final int x = parentComponent.getX();  
        final int y = parentComponent.getY();  
        final Point lastAt = e.getPoint();  
        parentComponent.setLocation(x + lastAt.x - offset.x, y + lastAt.y - offset.y); 
	}
	
}

上面代码使用方法如下:

MouseMoveListener mouseMoveListener = new MouseMoveListener();
		mouseMoveListener.install(this, titlePanel);

install参数第一个是当前的窗体,第二个是可以点击移动的对象。


系统托盘图标实现如下:

private void initTrayIcon() {
		PopupMenu popup = new PopupMenu();
		MenuItem showItem = new MenuItem("显示窗体");
		ActionListener listener = new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(true);
				setExtendedState(Frame.NORMAL);
				SystemTray.getSystemTray().remove(trayIcon);
			}
		};
		showItem.addActionListener(listener);
		popup.add(showItem);
		
		MenuItem exitItem = new MenuItem("退出");
		exitItem.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				SystemTray.getSystemTray().remove(trayIcon);
				System.exit(0);
			}
		});
		popup.add(exitItem);
		
		// 根据image、提示、菜单创建TrayIcon
		this.trayIcon = new TrayIcon(Icon.icon16.getImage(), "\u756a\u8304\u65f6\u95f4\u7ba1\u7406", popup);
		// 给TrayIcon添加事件监听器
		this.trayIcon.addActionListener(listener);
	}

	public void minimizeToTray() {
		SystemTray tray = SystemTray.getSystemTray();
		try {
			tray.add(this.trayIcon);
		} catch (AWTException ex) {
			ex.printStackTrace();
		}
	}

在eclipse中运行右键菜单时,如果有 乱码,可以在myeclipse中做如下修改(正常环境一般不会乱码):

在Run configration中


添加:-Dfile.encoding=GB18030


倒计时:使用的timer和timertask


界面布局,多层的jpanel嵌套使用BorderLayout,3个按钮显示的panel使用了CardLayout


运行截图:



使用说明:

界面中间为25分钟的番茄时间,

左侧按钮为5分钟的短时间休息,

右侧为10分钟的长时间休息。


下载地址http://git.oschina.net/free/PomodoroTechnique/repository/archive?ref=master

源码地址http://git.oschina.net/free/PomodoroTechnique

osc开源项目页http://www.oschina.net/p/PomodoroTechnique

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

isea533

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值