-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.java
More file actions
45 lines (40 loc) · 1.1 KB
/
Copy pathCard.java
File metadata and controls
45 lines (40 loc) · 1.1 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
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
public class Card extends JLabel{
int number;
String suit;
public Card(int n, String s){
super(n + s);
number = n;
suit = s;
if(number == 11){
setText("J"+ suit);
}
if(number == 12){
setText("Q"+ suit);
}
if(number == 13){
setText("K"+ suit);
}
if(number == 1){
setText("A"+ suit);
}
if(suit.equals("♥") || suit.equals("♦")){
setForeground(Color.RED);
}
Font f = new Font("SansSerif", Font.BOLD, 32);
Border b = BorderFactory.createLineBorder(Color.black);
setBorder(b);
setFont(f);
setBackground(Color.WHITE);
setOpaque(true);
setVerticalAlignment(SwingConstants.CENTER);
setHorizontalAlignment(SwingConstants.CENTER);
}
}