当前位置:编程学习 > JAVA >>

番茄时间管理 - java Swing版

番茄时间管理法(Pomodoro Technique):一个番茄是如何让你工作更有效率的
 
如果你经常读一些关于提高工作效率或时间管理类的博客,一定听说过番茄时间管理法(Pomodoro Technique)。这是一种极好的帮助你集中注意力、获得更高工作效率的方法。
 
基本上,它的实施方法是这样的:
 
确定你想要做什么(例如:翻译一篇外文)。
设定一个25分钟的定时器。
工作,直到定时器时间到:这就是一个“番茄钟”。
休息5分钟,继续下一个番茄钟
每4个番茄钟做一次长时间的休息。
大多数人都会对其做一些细微调整来适应自己:例如,你可以选择每两个番茄钟——而不是四个,做一次长时间的休息。这特别是你刚开始应用这种方法时。
 
 
 
 
 
软件使用到的方法:
 
界面圆角实现代码:
 
 
[java]  
//圆角  
        AWTUtilities.setWindowShape(this,  
                new RoundRectangle2D.Double( 0.0D, 0.0D,  
                        getWidth(),  
                        getHeight(), 26.0D, 26.0D));  
 
隐藏Frame标题代码:
 
[java]  
setUndecorated(true);  
 
自己实现的标题,标题是一个panel,给标题增加了鼠标点击移动的事件:
 
[java]  
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);   
    }  
      
}  
 
上面代码使用方法如下:
[java]  
MouseMoveListener mouseMoveListener = new MouseMoveListener();  
        mouseMoveListener.install(this, titlePanel);  
 
install参数第一个是当前的窗体,第二个是可以点击移动的对象。
 
系统托盘图标实现如下:
 
[java]  
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
补充:移动开发 , IOS ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,