public void mouseClicked(MouseEvent me) { if(zoomLevel + 0.04 < maxZoomLevel) { zoomLevel += 0.04; view.setZoomLevel(zoomLevel); } else { zoomLevel = maxZoomLevel; view.setZoomLevel(zoomLevel); } }
    public ZoomButtonPanel(BrowserView embeddedView)    {        currentTimer = new Timer();        BrowserEnvironment env = BrowserEnvironment.getInstance();        manager = env.getIconManager();                JButton zoomOutButton =            new JButton(manager.getSmallIcon(IconManager.ZOOM_OUT));        // adjust percent format to not display fractional zoom        percentFormat.setMaximumFractionDigits(0);        this.view = embeddedView;                    zoomOutButton.addMouseListener(new MouseAdapter()        {            public void mousePressed(MouseEvent me)            {                running = true;                view.setZoomToScale(false);                currentTimerTask = new TimerTask()                {                    public void run()                    {                        if(!running) running = true;                        if(zoomLevel == minZoomLevel)                        {                            running = false;                            cancel();                        }                        else if(zoomLevel - 0.04 > minZoomLevel)                        {                            zoomLevel -= 0.04;                            view.setZoomLevel(zoomLevel);                        }                        else                        {                            running = false;                            zoomLevel = minZoomLevel;                            view.setZoomLevel(zoomLevel);                            cancel();                        }                    }                };                                currentTimer.schedule(currentTimerTask,200,50);            }                        public void mouseReleased(MouseEvent me)            {                if(running)                {                    currentTimerTask.cancel();                    running = false;                }             }        });                zoomTextField = new JTextField(5);        zoomTextField.addActionListener(new ActionListener()        {            public void actionPerformed(ActionEvent ae)            {                getZoomFromText();            }        });                zoomTextField.addFocusListener(new FocusAdapter()        {            public void focusLost(FocusEvent fe)            {                getZoomFromText();            }        });                JButton zoomInButton =            new JButton(manager.getSmallIcon(IconManager.ZOOM_IN));                zoomInButton.addMouseListener(new MouseAdapter()        {            public void mousePressed(MouseEvent me)            {                running = true;                view.setZoomToScale(false);                currentTimerTask = new TimerTask()                {                    public void run()                    {                        if(!running) running = true;                        if(zoomLevel == maxZoomLevel)                        {                            running = false;                            cancel();                        }                        else if(zoomLevel + 0.04 < maxZoomLevel)                        {                            zoomLevel += 0.04;                            view.setZoomLevel(zoomLevel);                            view.repaint();                        }                        else                        {                            running = false;                            zoomLevel = maxZoomLevel;                            view.setZoomLevel(zoomLevel);                            view.repaint();                            cancel();                        }                    }                };                currentTimer.schedule(currentTimerTask,200,50);            }                                    public void mouseReleased(MouseEvent me)            {                if(running)                 {                    running = false;                    currentTimerTask.cancel();                }             }        });                JButton zoomFitButton =            new JButton(manager.getSmallIcon(IconManager.ZOOM_FIT));                zoomFitButton.addActionListener(new ActionListener()        {            public void actionPerformed(ActionEvent ae)            {                view.setZoomToScale(true);            }        });                view.addZoomParamListener(new ZoomParamListener()        {            public void minZoomLevelChanged(double level)            {                minZoomLevel = level;            }                        public void maxZoomLevelChanged(double level)            {                maxZoomLevel = level;            }                        public void zoomLevelChanged(double level)            {                if(!running) {                    zoomLevel = level;                }                zoomTextField.setText(percentFormat.format(level));            }        });                setLayout(new FlowLayout());        add(zoomOutButton);        add(zoomTextField);        add(zoomInButton);        add(zoomFitButton);        zoomOutButton.setToolTipText("Zoom Out");        zoomInButton.setToolTipText("Zoom In");        zoomFitButton.setToolTipText("Zoom to Fit");    }