Mercurial > hg > ristipolku
annotate game/IDMButton.java @ 195:ad336d22c3e8
Adjust board position against background.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 23 Apr 2019 15:43:37 +0300 |
parents | 8dbaa093c562 |
children | b88440f4431a |
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 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 if (metrics == null) |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 metrics = g.getFontMetrics(font); |
134
4c0dec72e2f0
Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
117 |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 int textWidth = metrics.stringWidth(text); |
169
32b1c41e194a
Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents:
163
diff
changeset
|
119 g.drawImage(img, getScaledX() + xoffs, getScaledY() + yoffs, null); |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 g.setFont(font); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
121 g.setPaint(Color.black); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 g.drawString(text, |
75 | 123 getScaledX() + xoffs + (getScaledWidth() - textWidth) / 2, |
124 getScaledY() + yoffs + getScaledHeight() / 2); | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
125 } |
134
4c0dec72e2f0
Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
126 |
4c0dec72e2f0
Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
127 |
75 | 128 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
|
129 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 state = State.PRESSED; |
50 | 131 active = true; |
75 | 132 return true; |
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 |
75 | 135 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
|
136 { |
75 | 137 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
|
138 super.mouseReleased(e); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 state = State.NORMAL; |
50 | 140 active = false; |
75 | 141 return oldActive; |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
142 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 |
75 | 144 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
|
145 { |
50 | 146 if (active) |
75 | 147 { |
50 | 148 state = State.PRESSED; |
75 | 149 return true; |
150 } | |
151 else | |
152 return false; | |
50 | 153 } |
154 | |
75 | 155 public boolean mouseExited(MouseEvent e) |
50 | 156 { |
51 | 157 if (active) |
75 | 158 { |
51 | 159 state = State.NORMAL; |
75 | 160 return true; |
161 } | |
162 else | |
163 return false; | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 } |