Skip to content

Commit 6460b30

Browse files
author
Damon Nguyen
committed
8321140: Add comment to note difference in Metal's JButton margins
Reviewed-by: honkar, aivanov
1 parent 3ca359a commit 6460b30

File tree

2 files changed

+42
-13
lines changed

2 files changed

+42
-13
lines changed

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -727,6 +727,8 @@ public Object createValue(UIDefaults table) {
727727
"Button.highlight", controlLtHighlight,
728728
"Button.border", buttonBorder,
729729
"Button.margin", new InsetsUIResource(2, 14, 2, 14),
730+
// The above margin has vastly larger horizontal values when
731+
// compared to other look and feels that don't rely on these values
730732
"Button.textIconGap", 4,
731733
"Button.textShiftOffset", zero,
732734
"Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {

src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,28 +25,53 @@
2525

2626
package javax.swing.plaf.metal;
2727

28-
import java.awt.*;
28+
import java.awt.Color;
29+
import java.awt.Component;
30+
import java.awt.Container;
31+
import java.awt.Frame;
32+
import java.awt.Insets;
33+
import java.awt.Toolkit;
34+
import java.awt.Window;
2935
import java.beans.PropertyChangeEvent;
3036
import java.beans.PropertyChangeListener;
31-
import javax.swing.plaf.*;
32-
import javax.swing.*;
33-
import javax.swing.plaf.basic.*;
34-
import javax.swing.text.DefaultEditorKit;
35-
36-
import java.awt.Color;
3737
import java.lang.ref.ReferenceQueue;
3838
import java.lang.ref.WeakReference;
39-
4039
import java.security.AccessController;
4140

42-
import sun.awt.*;
41+
import javax.swing.ButtonModel;
42+
import javax.swing.DefaultButtonModel;
43+
import javax.swing.Icon;
44+
import javax.swing.ImageIcon;
45+
import javax.swing.JComponent;
46+
import javax.swing.JDialog;
47+
import javax.swing.JFrame;
48+
import javax.swing.JRootPane;
49+
import javax.swing.JTextField;
50+
import javax.swing.JToggleButton;
51+
import javax.swing.LayoutStyle;
52+
import javax.swing.LookAndFeel;
53+
import javax.swing.SwingConstants;
54+
import javax.swing.SwingUtilities;
55+
import javax.swing.UIDefaults;
56+
import javax.swing.UIManager;
57+
import javax.swing.plaf.BorderUIResource;
58+
import javax.swing.plaf.ColorUIResource;
59+
import javax.swing.plaf.FontUIResource;
60+
import javax.swing.plaf.InsetsUIResource;
61+
import javax.swing.plaf.UIResource;
62+
import javax.swing.plaf.basic.BasicLookAndFeel;
63+
import javax.swing.text.DefaultEditorKit;
64+
65+
import sun.awt.AppContext;
66+
import sun.awt.OSInfo;
67+
import sun.awt.SunToolkit;
4368
import sun.security.action.GetPropertyAction;
4469
import sun.swing.DefaultLayoutStyle;
45-
import static javax.swing.UIDefaults.LazyValue;
46-
4770
import sun.swing.SwingAccessor;
4871
import sun.swing.SwingUtilities2;
4972

73+
import static javax.swing.UIDefaults.LazyValue;
74+
5075
/**
5176
* The Java Look and Feel, otherwise known as Metal.
5277
* <p>
@@ -782,6 +807,8 @@ protected void initComponentDefaults(UIDefaults table) {
782807
"SPACE", "pressed",
783808
"released SPACE", "released"
784809
}),
810+
// Button default margin is (2, 14, 2, 14), defined in
811+
// BasicLookAndFeel via "Button.margin" UI property.
785812

786813
"CheckBox.disabledText", inactiveControlTextColor,
787814
"Checkbox.select", controlShadow,

0 commit comments

Comments
 (0)