java番茄钟_番茄时间管理 – java Swing版

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

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

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

确定你想要做什么(例如:翻译一篇外文)。

设定一个25分钟的定时器。

工作,直到定时器时间到:这就是一个“番茄钟”。

休息5分钟,继续下一个番茄钟

每4个番茄钟做一次长时间的休息。

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

软件使用到的方法:

界面圆角实现代码:

//圆角

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(), “u756au8304u65f6u95f4u7ba1u7406”, 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中

使用说明:

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

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

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

文章知识点与官方知识档案匹配,可进一步学习相关知识Java技能树首页概览92131 人正在系统学习中 相关资源:番茄助手2017破解_vs2017番茄助手-C++工具类资源-CSDN文库

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年1月23日
下一篇 2021年1月23日

相关推荐