Advertisement
xlrnxnlx

SButton

Jul 4th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. // joga no git depois, vlw :D
  2. package view.external;
  3.  
  4. import java.awt.Color;
  5. import java.awt.event.MouseEvent;
  6. import java.awt.event.MouseListener;
  7. import javax.swing.JButton;
  8. import javax.swing.border.LineBorder;
  9.  
  10.  
  11. public class SButton extends JButton implements MouseListener {
  12.    
  13.     private Color border;
  14.     private Color hBorder;
  15.    
  16.     public SButton(String title, Color border, Color hBorder){
  17.         super(title);
  18.         this.border = border;
  19.         this.hBorder = hBorder;
  20.         setBorder(new LineBorder(border, 1, false));
  21.         setContentAreaFilled(false);
  22.         setFocusable(false);
  23.         addMouseListener(this);
  24.     }
  25.    
  26.     @Override
  27.     public void mouseEntered(MouseEvent e) {
  28.         if(e.getSource() == this && isEnabled())
  29.             setBorder(new LineBorder(hBorder, 1, false));
  30.     }
  31.  
  32.     @Override
  33.     public void mouseExited(MouseEvent e) {
  34.         if(e.getSource() == this)
  35.             setBorder(new LineBorder(border, 1, false));
  36.     }
  37.    
  38.     @Override public void mouseClicked(MouseEvent e) {}
  39.     @Override public void mousePressed(MouseEvent e) {}
  40.     @Override public void mouseReleased(MouseEvent e) {}
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement