Skip to content

Commit ac51094

Browse files
button: fixes when the button should paint the border in focus mode
Changelog-Fixed: button: fixes when the button should paint the border in focus mode Reported-By: Zoya @zanderson9 Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
1 parent 38c4ec9 commit ac51094

File tree

3 files changed

+9
-32
lines changed

3 files changed

+9
-32
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GROUP_ID=io.github.vincenzopalazzo
22
ARTIFACT_ID=material-ui-swing
33
#VERSION=1.1.2-rc2-SNAPSHOT
4-
VERSION=1.1.3-rc1-SNAPSHOT
4+
VERSION=1.1.3-rc2-SNAPSHOT
55
MODULE_NAME=io.github.vincenzopalazzo.materialuiswing
66
RELEASE_ENABLE=true
77

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>io.github.vincenzopalazzo</groupId>
66
<artifactId>material-ui-swing</artifactId>
7-
<version>1.1.3-rc1-SNAPSHOT</version>
7+
<version>1.1.3-rc2-SNAPSHOT</version>
88
<inceptionYear>2020</inceptionYear>
99
<licenses>
1010
<license>

src/main/java/mdlaf/components/button/MaterialButtonUI.java

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,6 @@ protected void paintFocus(
215215
Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
216216
if (!button.isEnabled()) return;
217217
paintFocusRing(g, (JButton) b);
218-
// paintFocusBorder(g, (JButton) b);
219-
}
220-
221-
@Override
222-
public void update(Graphics g, JComponent c) {
223-
super.update(g, c);
224-
if (!button.isFocusOwner()) paintBorderButton(g, c);
225218
}
226219

227220
@Override
@@ -277,37 +270,21 @@ protected void paintFocusRing(Graphics g, JButton b) {
277270
g2.dispose();
278271
}
279272

280-
@Deprecated
281-
protected void paintFocusBorder(Graphics graphics, JButton b) {
282-
if (!b.isEnabled() || !borderEnabled) {
283-
return;
284-
}
285-
Color color;
286-
if (defaultButton != null && defaultButton) {
287-
color = UIManager.getColor("Button[Default][focus].color");
288-
} else {
289-
color = UIManager.getColor("Button[focus].color");
290-
}
291-
Graphics2D graphics2D = (Graphics2D) graphics.create();
292-
graphics2D.setStroke(new BasicStroke(2f));
293-
294-
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
295-
int w = b.getWidth() - 1;
296-
int h = b.getHeight() - 1;
297-
298-
graphics2D.setColor(color);
299-
graphics2D.drawRoundRect(0, 0, w, h, arch + 2, arch + 2);
300-
graphics2D.dispose();
301-
}
302-
303273
protected void paintBorderButton(Graphics graphics, JComponent b) {
274+
// the button is disabled or the user don't want the borders
275+
// enables on your hand
304276
if (!b.isEnabled() || !borderEnabled) {
305277
return;
306278
} else if (!buttonBorderToAll && ((JButton) b).getIcon() != null) {
279+
// If the user don't want the border on all the buttons, we
280+
// don't set the border on the button with an icon
307281
return;
308282
} else if (this.isDefaultButton() && !buttonBorderToAll) {
283+
// if a button is a default button, and the user don't want
284+
// the border on all the buttons we avoid set it on default buttons
309285
return;
310286
}
287+
// otherwise, we set the border to the buttons
311288
Graphics2D graphics2D = (Graphics2D) graphics.create();
312289
graphics2D.setStroke(new BasicStroke(2f));
313290

0 commit comments

Comments
 (0)