933d00ad
rlentieu
add JPaint
|
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
|
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
/**
* ToolIcon is an extension of JButton. When the button is clicked then
* the toolSelected is switched to its corresponding tool. Each command has
* an id.
**/
public class ToolIcon extends JButton implements MouseListener
{
private int commandInt;
/** Creates a default ToolIcon. **/
public ToolIcon(){}
/** Creates a ToolIcon that takes in a string and a command integer. **/
public ToolIcon(String iconPath, int commandInt)
{
// createa JButton with an image with the path and sets the command id
super(new ImageIcon(iconPath));
this.commandInt = commandInt;
addMouseListener(this);
}
/**
* If mouse is clicked then it is selected and the others arent and checks
* if there is a special panel for this tool.
**/
public void mouseClicked(MouseEvent e)
{
ToolBox.tools[ToolBox.toolSelected].setEnabled(true);
setEnabled(!isEnabled());
ToolBox.toolSelected = commandInt;
ControlClass.sBox.choosePanel();
}
/** Invoked when the mouse is released. **/
public void mouseReleased(MouseEvent e){}
/** Invoked when the mouse is pressed. **/
public void mousePressed(MouseEvent e){}
/** Invoked when the mouse enters a component. **/
public void mouseEntered(MouseEvent e){}
/** Invoked when the mouse exits a component. **/
public void mouseExited(MouseEvent e){}
}
|