Created
August 15, 2009 22:38
-
-
Save dejw/168470 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.swing.JButton; | |
| import javax.swing.ImageIcon; | |
| public class GraphicalButtonFactory { | |
| public static JButton createButton(String normal){ | |
| return createButton(new ImageIcon(normal), null, null); | |
| } | |
| public static JButton createButton(String normal, String pressed){ | |
| return createButton(new ImageIcon(normal), new ImageIcon(pressed), null); | |
| } | |
| public static JButton createButton(String normal, String pressed, String disabled){ | |
| return createButton(new ImageIcon(normal), new ImageIcon(pressed), new ImageIcon(disabled)); | |
| } | |
| public static JButton createButton(ImageIcon normal, ImageIcon pressed, ImageIcon disabled){ | |
| JButton button = new JButton(""); | |
| button.setIcon(normal); | |
| if(pressed != null) button.setPressedIcon(pressed); | |
| if(disabled != null) button.setDisabledIcon(disabled); | |
| button.setBorder(null); | |
| return button; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment