Skip to content

Commit

Permalink
fixed jbutton icon issue
Browse files Browse the repository at this point in the history
  • Loading branch information
atarw committed Aug 29, 2018
1 parent 3e953ff commit b081bda
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 62 deletions.
96 changes: 45 additions & 51 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/main/java/MaterialUISwingDemo.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import mdlaf.MaterialLookAndFeel;
import mdlaf.animation.MaterialUIMovement;
import mdlaf.utils.MaterialColors;
import mdlaf.utils.MaterialImages;

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

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

JToolBar tb = new JToolBar ("toolbar");
JButton button1 = new JButton ("f");
class ActionTest extends AbstractAction {

public ActionTest () {
button1.setAction (new AbstractAction () {
@Override
public void actionPerformed (ActionEvent e) {
putValue (Action.NAME, "f");
putValue (Action.SHORT_DESCRIPTION, "Test tool tip");
}

@Override
public void actionPerformed (ActionEvent e) {
JDialog dialog = new JDialog ();
JPanel jPanel = new JPanel ();
jPanel.add (new JColorChooser ());
Expand All @@ -134,8 +134,8 @@ public void actionPerformed (ActionEvent e) {
dialog.setVisible (true);
dialog.pack ();
}
}
button1.setAction (new ActionTest ());
});

JButton button2 = new JButton ("e");
button1.setBackground (MaterialColors.LIGHT_BLUE_400);
button1.setForeground (Color.WHITE);
Expand All @@ -158,8 +158,8 @@ public void actionPerformed (ActionEvent e) {

JPanel pn = new JPanel ();
JTabbedPane tp = new JTabbedPane ();
tp.addTab ("bleh1", pn);
tp.addTab ("bleh", sp);
tp.addTab ("bleh2", pn);

frame.add (tp, BorderLayout.CENTER);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mdlaf/MaterialLookAndFeel.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected void initComponentDefaults (UIDefaults table) {
super.initComponentDefaults (table);

table.put ("Button.highlight", MaterialColors.GRAY_200);
table.put ("Button.opaque", false);
table.put ("Button.opaque", true);
table.put ("Button.border", BorderFactory.createEmptyBorder (7, 17, 7, 17));
table.put ("Button.background", MaterialColors.WHITE);
table.put ("Button.foreground", Color.BLACK);
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/mdlaf/components/button/MaterialButtonUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public void installUI (JComponent c) {
public void paint (Graphics g, JComponent c) {
AbstractButton b = (AbstractButton) c;
g = MaterialDrawingUtils.getAliasedGraphics (g);
paintBackground (g, b);

if (b.isContentAreaFilled ()) {
paintBackground (g, b);
}

super.paint (g, c);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/mdlaf/utils/MaterialImages.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class MaterialImages {
public static final BufferedImage LIST = loadImg ("/imgs/list.png");
public static final BufferedImage NEW_FOLDER = loadImg ("/imgs/new_folder.png");
public static final BufferedImage DETAILS = loadImg ("/imgs/details.png");
public static final BufferedImage TEST = loadImg ("/imgs/test.png");

private MaterialImages () {}

Expand Down
Binary file added target/classes/imgs/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified target/classes/material-ui-swing.jar
Binary file not shown.

0 comments on commit b081bda

Please sign in to comment.