-
Notifications
You must be signed in to change notification settings - Fork 2
/
Button.java
32 lines (30 loc) · 1.09 KB
/
Button.java
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
import javax.swing.JButton;
import java.awt.Color;
import java.awt.Font;
import java.awt.Dimension;
public class Button extends JButton
{
//constructs a button so I don't have to repeat the same lines of code over and
//over for each button I make
public Button(String text, int fontSize)
{
setText(text);
setFont(new Font(FlightSimulator.FONTSTYLE, Font.PLAIN, fontSize));
setPreferredSize(new Dimension((int)(0.7*fontSize*text.length()), fontSize*2));
setBackground(FlightSimulator.THEME_COLOR);
setForeground(Color.WHITE);
setFocusPainted(false);
setBorderPainted(false);
}
//different constructor if I need to specify width and height
public Button(String text, int fontSize, int width, int height)
{
setText(text);
setFont(new Font(FlightSimulator.FONTSTYLE, Font.PLAIN, fontSize));
setPreferredSize(new Dimension(width, height));
setBackground(FlightSimulator.THEME_COLOR);
setForeground(Color.WHITE);
setFocusPainted(false);
setBorderPainted(false);
}
}