Skip to content

Commit b081bda

Browse files
author
atarw
committed
fixed jbutton icon issue
1 parent 3e953ff commit b081bda

File tree

7 files changed

+61
-62
lines changed

7 files changed

+61
-62
lines changed

.idea/workspace.xml

Lines changed: 45 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/MaterialUISwingDemo.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import mdlaf.MaterialLookAndFeel;
22
import mdlaf.animation.MaterialUIMovement;
33
import mdlaf.utils.MaterialColors;
4+
import mdlaf.utils.MaterialImages;
45

56
import javax.swing.AbstractAction;
67
import javax.swing.Action;
8+
import javax.swing.ImageIcon;
79
import javax.swing.JButton;
810
import javax.swing.JCheckBox;
911
import javax.swing.JCheckBoxMenuItem;
@@ -103,7 +105,7 @@ public static void main (String[] args) {
103105
// the animation will take 5 * 1000 / 30 = 166.666... milliseconds to complete
104106
MaterialUIMovement.add (button, MaterialColors.LIGHT_BLUE_500, 5, 1000 / 30);
105107

106-
//
108+
// other components
107109
content.add (new JCheckBox ("checkbox"));
108110
content.add (new JComboBox<String> (new String[]{"a", "b", "c"}));
109111
content.add (new JLabel ("label"));
@@ -117,15 +119,13 @@ public static void main (String[] args) {
117119

118120
JToolBar tb = new JToolBar ("toolbar");
119121
JButton button1 = new JButton ("f");
120-
class ActionTest extends AbstractAction {
121122

122-
public ActionTest () {
123+
button1.setAction (new AbstractAction () {
124+
@Override
125+
public void actionPerformed (ActionEvent e) {
123126
putValue (Action.NAME, "f");
124127
putValue (Action.SHORT_DESCRIPTION, "Test tool tip");
125-
}
126128

127-
@Override
128-
public void actionPerformed (ActionEvent e) {
129129
JDialog dialog = new JDialog ();
130130
JPanel jPanel = new JPanel ();
131131
jPanel.add (new JColorChooser ());
@@ -134,8 +134,8 @@ public void actionPerformed (ActionEvent e) {
134134
dialog.setVisible (true);
135135
dialog.pack ();
136136
}
137-
}
138-
button1.setAction (new ActionTest ());
137+
});
138+
139139
JButton button2 = new JButton ("e");
140140
button1.setBackground (MaterialColors.LIGHT_BLUE_400);
141141
button1.setForeground (Color.WHITE);
@@ -158,8 +158,8 @@ public void actionPerformed (ActionEvent e) {
158158

159159
JPanel pn = new JPanel ();
160160
JTabbedPane tp = new JTabbedPane ();
161-
tp.addTab ("bleh1", pn);
162161
tp.addTab ("bleh", sp);
162+
tp.addTab ("bleh2", pn);
163163

164164
frame.add (tp, BorderLayout.CENTER);
165165

src/main/java/mdlaf/MaterialLookAndFeel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected void initComponentDefaults (UIDefaults table) {
136136
super.initComponentDefaults (table);
137137

138138
table.put ("Button.highlight", MaterialColors.GRAY_200);
139-
table.put ("Button.opaque", false);
139+
table.put ("Button.opaque", true);
140140
table.put ("Button.border", BorderFactory.createEmptyBorder (7, 17, 7, 17));
141141
table.put ("Button.background", MaterialColors.WHITE);
142142
table.put ("Button.foreground", Color.BLACK);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ public void installUI (JComponent c) {
3131
public void paint (Graphics g, JComponent c) {
3232
AbstractButton b = (AbstractButton) c;
3333
g = MaterialDrawingUtils.getAliasedGraphics (g);
34-
paintBackground (g, b);
34+
35+
if (b.isContentAreaFilled ()) {
36+
paintBackground (g, b);
37+
}
38+
3539
super.paint (g, c);
3640
}
3741

src/main/java/mdlaf/utils/MaterialImages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class MaterialImages {
2727
public static final BufferedImage LIST = loadImg ("/imgs/list.png");
2828
public static final BufferedImage NEW_FOLDER = loadImg ("/imgs/new_folder.png");
2929
public static final BufferedImage DETAILS = loadImg ("/imgs/details.png");
30+
public static final BufferedImage TEST = loadImg ("/imgs/test.png");
3031

3132
private MaterialImages () {}
3233

target/classes/imgs/test.png

5.23 KB
Loading

target/classes/material-ui-swing.jar

5.43 KB
Binary file not shown.

0 commit comments

Comments
 (0)