-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.java
More file actions
69 lines (58 loc) · 1.72 KB
/
Copy pathButton.java
File metadata and controls
69 lines (58 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.io.File;
import java.awt.Color;
import java.awt.Dimension;
import javax.imageio.ImageIO;
public class Button extends JButton implements MouseListener
{
int w = getWidth();
int h = getHeight();
String filePath = "";
JFrame c;
public Button(JFrame c, ImageIcon img, String filePath)
{
addMouseListener(this);
setVisible(true);
this.filePath = filePath;
this.c = c;
setIcon(img);
setMaximumSize(new Dimension(Container.width, Container.height));
}
public Button(String str)
{
setText(str);
setVisible(true);
addMouseListener(this);
setMaximumSize(new Dimension(Container.width, Container.height));
}
public Button(Color c)
{
setBackground(c);
setVisible(true);
addMouseListener(this);
setMaximumSize(new Dimension(Container.width, Container.height));
}
public void mouseExited(MouseEvent e)
{
try{
setIcon(new ImageIcon(ImageIO.read(new File(System.getProperty("user.dir") + "//Media//" + filePath + ".png"))));
}catch(Exception e2){}
}
public void mouseEntered(MouseEvent e)
{
try{
setIcon(new ImageIcon(ImageIO.read(new File(System.getProperty("user.dir") + "//Media//" + filePath + "Hovered.png"))));
}catch(Exception e2){}
}
public void mouseReleased(MouseEvent e)
{
if(filePath.equals("exit"))
c.dispose();
}
public void mouseClicked(MouseEvent e){}
public void mousePressed(MouseEvent e){}
}