01: /*
02: * Copyright 2005 Patrick Gotthardt
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package com.pagosoft.plaf;
17:
18: import javax.swing.*;
19: import javax.swing.plaf.basic.*;
20: import java.awt.event.*;
21:
22: /**
23: * @author Patrick Gotthardt
24: */
25: public class RolloverButtonListener extends BasicButtonListener {
26: public RolloverButtonListener(AbstractButton b) {
27: super (b);
28: b.setRolloverEnabled(true);
29: }
30:
31: public void mouseEntered(MouseEvent e) {
32: super .mouseEntered(e);
33: AbstractButton b = (AbstractButton) e.getSource();
34: ButtonModel model = b.getModel();
35: if (b.isRolloverEnabled()
36: && !SwingUtilities.isLeftMouseButton(e)) {
37: model.setRollover(true);
38: }
39: if (model.isPressed()) {
40: model.setArmed(true);
41: }
42: b.repaint();
43: }
44:
45: public void mouseExited(MouseEvent e) {
46: super .mouseExited(e);
47: AbstractButton b = (AbstractButton) e.getSource();
48: ButtonModel model = b.getModel();
49: if (b.isRolloverEnabled()) {
50: model.setRollover(false);
51: }
52: if (model.isPressed()) {
53: model.setArmed(false);
54: }
55: b.repaint();
56: }
57: }
|