Why, Sliding effect on JPanel sometimes lags?
===

I am changing the bounds of a JPanel using a Timer to get a sliding effect when someone hovers over a particular rectangular area and it is working as expected . There are buttons in that JPanel and they have different MouseEvents behavior. But SOMEIIMES it starts lagging or slides very slow . Can please what suggest what can I do , so that it performs well each time?

    class MyActionListener implements ActionListener {

        private static final int frames = 50;
        int count = 0;
        private final Timer timer = new Timer(1, this);

        public void start() {
            timer.start();
        }

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (count >= frames) {
                timer.stop();
            } else {
                count = count + 1;
                buttons.setBounds(hidden_width - hidden_width * count / frames, 0, hidden_width, frameHeight);
            }
        }
    }

    class MyMouseListener extends MouseAdapter {

        private MyActionListener timerListener;

        @Override
        public void mouseEntered(final MouseEvent event) {

            final Color color = new Color(50, 50, 50);
            if (event.getSource() instanceof JButton) {
                final JButton button = (JButton) event.getSource();
                button.setBackground(color);
                buttons.setVisible(true);
            } else if (!buttons.isVisible()) {
                buttons.setVisible(true);
                timerListener = new MyActionListener();
                timerListener.start();
            }
        }

        @Override
        public void mouseExited(final MouseEvent event) {
            Point point = new Point(0, 0);
            if (event.getSource() instanceof JButton) {
                final JButton button = (JButton) event.getSource();
                point = button.getLocation();
                button.setBackground(Windows8GUI.color);
            }
            Rectangle rect = new Rectangle(0, 0, hidden_width, frameHeight);
            if (!rect.contains(point.x + event.getX(), point.y + event.getY())) {
                buttons.setVisible(false);
                buttons.setBounds(0, 0, hidden_width, frameHeight);
            }
        }
    }