誰かが特定の長方形の領域にカーソルを合わせたときにスライド効果を得るためにaJPanelを使用して aの境界を変更していますが、これは期待どおりに機能しています。Timerにはボタンがあり、動作JPanelが異なりMouseEventます。しかし、時々遅れたり、スライドが非常に遅くなったりします。毎回うまく機能するように、誰かが私に何ができるかを提案できますか?
編集:
その中buttonsPanelにbuttonある。として境界を持つbuttonsPanela に追加されます。JLayeredPane または JButtonの場合、マウスイベントがトリガーされます。次に、マウス イベントによってタイマーがトリガーされ、ビューが表示されます。JLayeredPanerectbuttonhoveredslide the buttonsPanel
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;
            buttonsPanel.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);
            buttonsPanel.setVisible(true);
        } else if (!buttonsPanel.isVisible()) {
            buttonsPanel.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())) {
            buttonsPanel.setVisible(false);
            buttonsPanel.setBounds(0, 0, hidden_width, frameHeight);
        }
    }
}