Mercurial > hg > ristipolku
annotate game/IDMButton.java @ 198:b88440f4431a
Allow no-text (null text) buttons.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 24 Apr 2019 14:53:27 +0300 |
parents | 8dbaa093c562 |
children |
rev | line source |
---|---|
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * Ristipolku IDM button widget |
189 | 3 * (C) Copyright 2011-2017 Matti 'ccr' Hämäläinen <ccr@tnsp.org> |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 */ |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 package game; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 import java.awt.*; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 import java.awt.event.*; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 import java.awt.image.*; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 import java.awt.geom.*; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 import javax.imageio.*; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 import java.io.*; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 public class IDMButton extends IDMWidget |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 enum State { FOCUSED, PRESSED, NORMAL } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 State state; |
178
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
19 BufferedImage imgOrigUnpressed, imgOrigPressed; |
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
20 BufferedImage imgUnpressed, imgPressed; |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 Font font; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 FontMetrics metrics; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 String text; |
50 | 24 boolean active; |
134
4c0dec72e2f0
Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
25 |
178
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
26 public IDMButton(IDMPoint pos, String prefix, int keyCode, Font font, String text) |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 { |
75 | 28 super(pos); |
178
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
29 loadImages(prefix); |
169
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
30 setSize(imgOrigUnpressed.getWidth(), imgOrigUnpressed.getHeight()); |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
31 setScale(1, 1); |
75 | 32 |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 this.font = font; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 this.keyCode = keyCode; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 this.text = text; |
75 | 36 |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 state = State.NORMAL; |
50 | 38 active = false; |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 } |
134
4c0dec72e2f0
Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
40 |
178
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
41 public IDMButton(IDMPoint pos, int keyCode, Font font, String text) |
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
42 { |
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
43 this(pos, "button1", keyCode, font, text); |
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
44 } |
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
45 |
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
46 public IDMButton(float x, float y, String prefix, int keyCode, Font font, String text) |
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
47 { |
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
48 this(new IDMPoint(x, y), prefix, keyCode, font, text); |
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
49 } |
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
50 |
51 | 51 public IDMButton(float x, float y, int keyCode, Font font, String text) |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 { |
51 | 53 this(new IDMPoint(x, y), keyCode, font, text); |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 } |
134
4c0dec72e2f0
Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
55 |
178
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
56 |
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
57 public void loadImages(String prefix) |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 try |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 { |
178
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
61 ResourceLoader res = new ResourceLoader("graphics/"+ prefix +"_up.png"); |
169
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
62 imgOrigUnpressed = ImageIO.read(res.getStream()); |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 |
178
981a8e20b363
Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
64 res = new ResourceLoader("graphics/"+ prefix +"_down.png"); |
169
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
65 imgOrigPressed = ImageIO.read(res.getStream()); |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 catch (IOException e) |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 { |
192
8dbaa093c562
Improve debug message handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
189
diff
changeset
|
69 G.debug(e.getMessage()); |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 } |
133
881deac2daf8
Some more work on scaling widgets, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
72 |
169
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
73 public BufferedImage scaleImage(BufferedImage src) |
133
881deac2daf8
Some more work on scaling widgets, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
74 { |
169
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
75 BufferedImage dst = new BufferedImage(getScaledWidth(), getScaledHeight(), BufferedImage.TYPE_INT_ARGB); |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
76 Graphics2D gimg = dst.createGraphics(); |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
77 |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
78 gimg.setRenderingHint(RenderingHints.KEY_INTERPOLATION, |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
79 RenderingHints.VALUE_INTERPOLATION_BICUBIC); |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
80 |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
81 gimg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
82 RenderingHints.VALUE_ANTIALIAS_ON); |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
83 |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
84 gimg.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
85 RenderingHints.VALUE_TEXT_ANTIALIAS_ON); |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
86 |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
87 gimg.drawImage(src, 0, 0, getScaledWidth(), getScaledHeight(), null); |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
88 return dst; |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
89 } |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
90 |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
91 public void setScale(IDMPoint scale) |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
92 { |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
93 super.setScale(scale); |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
94 imgPressed = scaleImage(imgOrigPressed); |
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
95 imgUnpressed = scaleImage(imgOrigUnpressed); |
133
881deac2daf8
Some more work on scaling widgets, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
96 } |
134
4c0dec72e2f0
Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
97 |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 public void paint(Graphics2D g) |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 BufferedImage img; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 int xoffs, yoffs; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 if (state == State.PRESSED) |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 img = imgPressed; |
187
c9b743e32567
Improve IDMButton scaled click movement.
Matti Hamalainen <ccr@tnsp.org>
parents:
178
diff
changeset
|
106 xoffs = (int) (3.5f * scale.x); |
c9b743e32567
Improve IDMButton scaled click movement.
Matti Hamalainen <ccr@tnsp.org>
parents:
178
diff
changeset
|
107 yoffs = (int) (3.5f * scale.y); |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 else |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 xoffs = yoffs = 0; |
169
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
112 img = imgUnpressed; |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
114 |
198
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
115 g.drawImage(img, getScaledX() + xoffs, getScaledY() + yoffs, null); |
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
116 |
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
117 if (text != null) |
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
118 { |
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
119 if (metrics == null) |
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
120 metrics = g.getFontMetrics(font); |
134
4c0dec72e2f0
Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
121 |
198
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
122 int textWidth = metrics.stringWidth(text); |
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
123 g.setFont(font); |
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
124 g.setPaint(Color.black); |
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
125 g.drawString(text, |
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
126 getScaledX() + xoffs + (getScaledWidth() - textWidth) / 2, |
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
127 getScaledY() + yoffs + getScaledHeight() / 2); |
b88440f4431a
Allow no-text (null text) buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
192
diff
changeset
|
128 } |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 } |
134
4c0dec72e2f0
Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
130 |
4c0dec72e2f0
Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
131 |
75 | 132 public boolean mousePressed(MouseEvent e) |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 state = State.PRESSED; |
50 | 135 active = true; |
75 | 136 return true; |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
138 |
75 | 139 public boolean mouseReleased(MouseEvent e) |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
140 { |
75 | 141 boolean oldActive = active; |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
142 super.mouseReleased(e); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 state = State.NORMAL; |
50 | 144 active = false; |
75 | 145 return oldActive; |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
146 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
147 |
75 | 148 public boolean mouseEntered(MouseEvent e) |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
149 { |
50 | 150 if (active) |
75 | 151 { |
50 | 152 state = State.PRESSED; |
75 | 153 return true; |
154 } | |
155 else | |
156 return false; | |
50 | 157 } |
158 | |
75 | 159 public boolean mouseExited(MouseEvent e) |
50 | 160 { |
51 | 161 if (active) |
75 | 162 { |
51 | 163 state = State.NORMAL; |
75 | 164 return true; |
165 } | |
166 else | |
167 return false; | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
168 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
169 } |