01: /*
02: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
07: *
08: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
09: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
10: * the license for the specific language governing your rights and limitations.
11: *
12: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
13: */
14: package org.pentaho.reportdesigner.crm.report;
15:
16: import org.jetbrains.annotations.NotNull;
17:
18: import javax.swing.*;
19: import java.awt.*;
20: import java.awt.event.MouseAdapter;
21: import java.awt.event.MouseEvent;
22:
23: /**
24: * User: Martin
25: * Date: 25.01.2006
26: * Time: 20:55:17
27: */
28: public class GrabberComponent extends JComponent {
29: private boolean mouseIsPressed;
30: private boolean mouseInside;
31:
32: public GrabberComponent() {
33: setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
34:
35: addMouseListener(new MouseAdapter() {
36: public void mousePressed(@NotNull
37: MouseEvent e) {
38: mouseIsPressed = true;
39: repaint();
40: }
41:
42: public void mouseReleased(@NotNull
43: MouseEvent e) {
44: mouseIsPressed = false;
45: repaint();
46: }
47:
48: public void mouseEntered(@NotNull
49: MouseEvent e) {
50: mouseInside = true;
51: repaint();
52: }
53:
54: public void mouseExited(@NotNull
55: MouseEvent e) {
56: mouseInside = false;
57: repaint();
58: }
59: });
60:
61: }
62:
63: protected void paintComponent(@NotNull
64: Graphics g) {
65: super .paintComponent(g);
66: if (mouseInside || mouseIsPressed) {
67: g.setColor(new Color(183, 203, 255));
68: g.fillRect(0, 0, getWidth(), getHeight());
69: g.setColor(new Color(132, 166, 255));
70: g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
71: } else {
72: g.setColor(Color.WHITE);
73: g.fillRect(0, 0, getWidth(), getHeight());
74: g.setColor(Color.LIGHT_GRAY);
75: g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
76: }
77:
78: }
79:
80: }
|