Advertisement
thenewboston

Java Programming Tutorial - 62 - JButton

Aug 22nd, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. public class apples {
  2.    public static void main(String[] args){
  3.      
  4.    }
  5.  
  6. }
  7.  
  8. import java.awt.FlowLayout;
  9. import java.awt.event.ActionListener;
  10. import java.awt.event.ActionEvent;
  11. import javax.swing.JFrame;
  12. import javax.swing.JButton;
  13. import javax.swing.Icon;
  14. import javax.swing.ImageIcon;
  15. import javax.swing.JOptionPane;
  16.  
  17. public class Gui extends JFrame{
  18.    
  19.    private JButton reg;
  20.    private JButton custom;
  21.    
  22.    public Gui(){
  23.       super("The title");
  24.       setLayout(new FlowLayout());
  25.      
  26.       reg = new JButton("reg Button");
  27.       add(reg);
  28.      
  29.       Icon b = new ImageIcon(getClass().getResource("a.png"));
  30.       Icon x = new ImageIcon(getClass().getResource("x.png"));
  31.       custom = new JButton("Custom", b);
  32.       custom.setRolloverIcon(x);
  33.       add(custom);
  34.    }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement