-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.java
More file actions
51 lines (48 loc) · 1.63 KB
/
Button.java
File metadata and controls
51 lines (48 loc) · 1.63 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
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import java.io.*;
import java.awt.image.BufferedImage;
// Class that creates and places the arrows.
public class Button {
BufferedImage imgLeft = null;
BufferedImage imgRight = null;
// Method to return left arrow image as a JLabel.
public static JLabel getLeftArrow(){
BufferedImage imageLeft = null;
try
{
InputStream is = Roadrunner.class.getResourceAsStream("/leftArrow.png");
imageLeft = ImageIO.read(is);
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
ImageIcon imageLeftIcon = new ImageIcon(imageLeft);
JLabel jLabelLeft = new JLabel();
jLabelLeft.setIcon(imageLeftIcon);
jLabelLeft.setBounds(80, 650, imageLeftIcon.getIconWidth(), imageLeftIcon.getIconHeight());
return jLabelLeft;
}
// Method to return right arrow image as a JLabel.
public static JLabel getRightArrow(){
BufferedImage imageRight = null;
try
{
InputStream isR = Roadrunner.class.getResourceAsStream("/rightArrow.png");
imageRight = ImageIO.read(isR);
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
ImageIcon imageRightIcon = new ImageIcon(imageRight);
JLabel jLabelRight = new JLabel();
jLabelRight.setIcon(imageRightIcon);
jLabelRight.setBounds(750, 650, imageRightIcon.getIconWidth(), imageRightIcon.getIconHeight());
return jLabelRight;
}
}