commit 2ded05b9e8956094544fad6beb0509d1c0969627
parent f3faca66da5684dc22079cbf230e440b3b1fa0f2
Author: Michael Neuper <michael@michaelneuper.com>
Date: Sun, 30 Apr 2023 22:21:54 +0200
Display blank card image
Diffstat:
6 files changed, 246 insertions(+), 96 deletions(-)
diff --git a/src/controller/Controller.java b/src/controller/Controller.java
@@ -276,5 +276,13 @@ public class Controller {
public String displayDealerFirstCardValue() {
return DEALER.printFirstCardValue();
}
+
+ public String getDealerCardFilePath(int i) {
+ return DEALER.printFilePath(i);
+ }
+
+ public String getPlayerCardFilePath(int i) {
+ return PLAYER.printFilePath(i);
+ }
}
diff --git a/src/controller/Hand.java b/src/controller/Hand.java
@@ -71,6 +71,11 @@ public class Hand {
public Card getCard(int i) {
return HAND.get(i);
}
+
+ public String getCardFilePath(int i) {
+ System.out.println("/assets/cards/" + HAND.get(i).getFilename());
+ return "/assets/cards/" + HAND.get(i).getFilename();
+ }
/**
* Discards the current hand and adds its cards to the specified discard
diff --git a/src/model/Card.java b/src/model/Card.java
@@ -137,6 +137,10 @@ public class Card {
public Rank getRank() {
return rank;
}
+
+ public String getFilename() {
+ return rank.toString().toLowerCase() + "_of_" + suit.toString().toLowerCase() + ".png";
+ }
/**
* Returns a String representation of the Card object, including the rank
diff --git a/src/model/Person.java b/src/model/Person.java
@@ -81,6 +81,10 @@ public abstract class Person {
public String printHand() {
return this.hand + "";
}
+
+ public String printFilePath(int i) {
+ return hand.getCardFilePath(i);
+ }
/**
* Draws a card from the deck and adds it to the person's hand. If the deck
diff --git a/src/view/MainUI.form b/src/view/MainUI.form
@@ -22,7 +22,7 @@
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
- <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-69,0,0,3,-125"/>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-22,0,0,3,-76"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
@@ -43,7 +43,7 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
- <EmptySpace pref="339" max="32767" attributes="0"/>
+ <EmptySpace pref="388" max="32767" attributes="0"/>
<Component id="jLabelResult" min="-2" pref="300" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="260" max="-2" attributes="0"/>
</Group>
@@ -65,9 +65,7 @@
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Segoe UI" size="48" style="0"/>
</Property>
- <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
- <Connection code="game.checkWhoWins()" type="code"/>
- </Property>
+ <Property name="text" type="java.lang.String" value="WELCOME"/>
</Properties>
</Component>
</SubComponents>
@@ -115,7 +113,7 @@
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jButtonSurrender" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
- <Component id="jButtonDeal" pref="203" max="32767" attributes="0"/>
+ <Component id="jButtonDeal" pref="250" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@@ -229,7 +227,7 @@
<Component id="jLabelCurrentBet" min="-2" max="-2" attributes="0"/>
<Component id="jLabelBalance" min="-2" max="-2" attributes="0"/>
</Group>
- <EmptySpace pref="25" max="32767" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -244,7 +242,7 @@
<Component id="jLabelCurrentBetAmount" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="jButtonChangeBet" min="-2" max="-2" attributes="0"/>
- <EmptySpace pref="270" max="32767" attributes="0"/>
+ <EmptySpace pref="317" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -261,7 +259,9 @@
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="ff" red="ff" type="rgb"/>
</Property>
- <Property name="text" type="java.lang.String" value="R 1000"/>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code=""R" + game.getBalance()" type="code"/>
+ </Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabelCurrentBet">
@@ -342,21 +342,14 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
- <Component id="jPanelDealerText" alignment="0" max="32767" attributes="0"/>
- <Group type="102" alignment="0" attributes="0">
- <EmptySpace min="-2" pref="54" max="-2" attributes="0"/>
- <Component id="jLabelDealerHand" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="32767" attributes="0"/>
- </Group>
+ <Component id="jPanelDealerText" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jPanelDealerText" min="-2" max="-2" attributes="0"/>
- <EmptySpace min="-2" pref="49" max="-2" attributes="0"/>
- <Component id="jLabelDealerHand" min="-2" max="-2" attributes="0"/>
- <EmptySpace min="0" pref="114" max="32767" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -372,10 +365,21 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
+ <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
- <Component id="jLabelDealer" min="-2" max="-2" attributes="0"/>
- <EmptySpace pref="411" max="32767" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jLabelDealer" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="jLabelDealerCard1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Component id="jLabelDealerCard2" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Component id="jLabelDealerCard3" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Component id="jLabelDealerCard4" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -384,7 +388,14 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabelDealer" min="-2" max="-2" attributes="0"/>
- <EmptySpace pref="52" max="32767" attributes="0"/>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jLabelDealerCard1" min="-2" max="-2" attributes="0"/>
+ <Component id="jLabelDealerCard2" min="-2" max="-2" attributes="0"/>
+ <Component id="jLabelDealerCard3" min="-2" max="-2" attributes="0"/>
+ <Component id="jLabelDealerCard4" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -395,16 +406,39 @@
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Segoe UI" size="30" style="0"/>
</Property>
- <Property name="text" type="java.lang.String" value="Dealer: 13"/>
+ <Property name="text" type="java.lang.String" value="Dealer"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabelDealerCard1">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/assets/cards/back.png"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabelDealerCard2">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/assets/cards/back.png"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabelDealerCard3">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/assets/cards/back.png"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabelDealerCard4">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/assets/cards/back.png"/>
+ </Property>
</Properties>
</Component>
</SubComponents>
</Container>
- <Component class="javax.swing.JLabel" name="jLabelDealerHand">
- <Properties>
- <Property name="text" type="java.lang.String" value="jLabel1"/>
- </Properties>
- </Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanelPlayer">
@@ -417,21 +451,40 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
- <Component id="jPanelPlayerText" alignment="0" max="32767" attributes="0"/>
- <Group type="102" alignment="0" attributes="0">
- <EmptySpace min="-2" pref="54" max="-2" attributes="0"/>
- <Component id="jLabelPlayerHand" min="-2" max="-2" attributes="0"/>
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jLabelPlayer" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="jLabelPlayerCard2" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Component id="jLabelPlayerCard1" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Component id="jLabelPlayerCard3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
+ <Component id="jPanelPlayerText" max="32767" attributes="0"/>
+ <EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
- <Group type="102" alignment="0" attributes="0">
+ <Group type="102" attributes="0">
<Component id="jPanelPlayerText" min="-2" max="-2" attributes="0"/>
- <EmptySpace min="-2" pref="61" max="-2" attributes="0"/>
- <Component id="jLabelPlayerHand" min="-2" max="-2" attributes="0"/>
- <EmptySpace min="0" pref="163" max="32767" attributes="0"/>
+ <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="jLabelPlayer" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jLabelPlayerCard2" min="-2" max="-2" attributes="0"/>
+ <Component id="jLabelPlayerCard1" min="-2" max="-2" attributes="0"/>
+ <Component id="jLabelPlayerCard3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -448,36 +501,61 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
- <EmptySpace max="-2" attributes="0"/>
- <Component id="jLabelPlayer" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="32767" attributes="0"/>
+ <EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
+ <Component id="jLabelPlayerCard4" min="-2" max="-2" attributes="0"/>
+ <EmptySpace pref="119" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
- <EmptySpace max="-2" attributes="0"/>
- <Component id="jLabelPlayer" min="-2" max="-2" attributes="0"/>
- <EmptySpace pref="43" max="32767" attributes="0"/>
+ <EmptySpace min="-2" pref="64" max="-2" attributes="0"/>
+ <Component id="jLabelPlayerCard4" min="-2" max="-2" attributes="0"/>
+ <EmptySpace pref="264" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
- <Component class="javax.swing.JLabel" name="jLabelPlayer">
+ <Component class="javax.swing.JLabel" name="jLabelPlayerCard4">
<Properties>
- <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
- <Font name="Segoe UI" size="30" style="0"/>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/assets/cards/back.png"/>
</Property>
- <Property name="text" type="java.lang.String" value="Player: 13"/>
+ <Property name="text" type="java.lang.String" value=" "/>
</Properties>
</Component>
</SubComponents>
</Container>
- <Component class="javax.swing.JLabel" name="jLabelPlayerHand">
+ <Component class="javax.swing.JLabel" name="jLabelPlayer">
+ <Properties>
+ <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+ <Font name="Segoe UI" size="30" style="0"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="You"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabelPlayerCard2">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/assets/cards/back.png"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabelPlayerCard1">
<Properties>
- <Property name="text" type="java.lang.String" value="jLabel2"/>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/assets/cards/back.png"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value=""/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabelPlayerCard3">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/assets/cards/back.png"/>
+ </Property>
</Properties>
</Component>
</SubComponents>
diff --git a/src/view/MainUI.java b/src/view/MainUI.java
@@ -2,6 +2,7 @@ package view;
import com.formdev.flatlaf.FlatDarkLaf;
import controller.Controller;
+import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
@@ -49,11 +50,17 @@ public class MainUI extends javax.swing.JFrame {
jPanelDealer = new javax.swing.JPanel();
jPanelDealerText = new javax.swing.JPanel();
jLabelDealer = new javax.swing.JLabel();
- jLabelDealerHand = new javax.swing.JLabel();
+ jLabelDealerCard1 = new javax.swing.JLabel();
+ jLabelDealerCard2 = new javax.swing.JLabel();
+ jLabelDealerCard3 = new javax.swing.JLabel();
+ jLabelDealerCard4 = new javax.swing.JLabel();
jPanelPlayer = new javax.swing.JPanel();
jPanelPlayerText = new javax.swing.JPanel();
+ jLabelPlayerCard4 = new javax.swing.JLabel();
jLabelPlayer = new javax.swing.JLabel();
- jLabelPlayerHand = new javax.swing.JLabel();
+ jLabelPlayerCard2 = new javax.swing.JLabel();
+ jLabelPlayerCard1 = new javax.swing.JLabel();
+ jLabelPlayerCard3 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("librejack");
@@ -62,14 +69,14 @@ public class MainUI extends javax.swing.JFrame {
jPanelNorth.setBackground(new java.awt.Color(0, 102, 51));
jLabelResult.setFont(new java.awt.Font("Segoe UI", 0, 48)); // NOI18N
- jLabelResult.setText(game.checkWhoWins());
+ jLabelResult.setText("WELCOME");
javax.swing.GroupLayout jPanelNorthLayout = new javax.swing.GroupLayout(jPanelNorth);
jPanelNorth.setLayout(jPanelNorthLayout);
jPanelNorthLayout.setHorizontalGroup(
jPanelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelNorthLayout.createSequentialGroup()
- .addContainerGap(339, Short.MAX_VALUE)
+ .addContainerGap(388, Short.MAX_VALUE)
.addComponent(jLabelResult, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(260, 260, 260))
);
@@ -159,7 +166,7 @@ public class MainUI extends javax.swing.JFrame {
.addGap(18, 18, 18)
.addComponent(jButtonSurrender)
.addGap(18, 18, 18)
- .addComponent(jButtonDeal, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)
+ .addComponent(jButtonDeal, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addContainerGap())
);
@@ -172,7 +179,7 @@ public class MainUI extends javax.swing.JFrame {
jLabelBalance.setBackground(new java.awt.Color(102, 102, 0));
jLabelBalance.setFont(new java.awt.Font("Segoe UI", 0, 24)); // NOI18N
jLabelBalance.setForeground(new java.awt.Color(255, 255, 0));
- jLabelBalance.setText("R 1000");
+ jLabelBalance.setText("R" + game.getBalance());
jLabelCurrentBet.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
jLabelCurrentBet.setText("Current Bet:");
@@ -201,7 +208,7 @@ public class MainUI extends javax.swing.JFrame {
.addComponent(jLabelCurrentBetAmount)
.addComponent(jLabelCurrentBet)
.addComponent(jLabelBalance))
- .addContainerGap(25, Short.MAX_VALUE))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanelWestLayout.setVerticalGroup(
jPanelWestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -214,7 +221,7 @@ public class MainUI extends javax.swing.JFrame {
.addComponent(jLabelCurrentBetAmount)
.addGap(32, 32, 32)
.addComponent(jButtonChangeBet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(270, Short.MAX_VALUE))
+ .addContainerGap(317, Short.MAX_VALUE))
);
getContentPane().add(jPanelWest, java.awt.BorderLayout.WEST);
@@ -227,7 +234,15 @@ public class MainUI extends javax.swing.JFrame {
jPanelDealerText.setBackground(new java.awt.Color(0, 102, 51));
jLabelDealer.setFont(new java.awt.Font("Segoe UI", 0, 30)); // NOI18N
- jLabelDealer.setText("Dealer: 13");
+ jLabelDealer.setText("Dealer");
+
+ jLabelDealerCard1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/cards/back.png"))); // NOI18N
+
+ jLabelDealerCard2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/cards/back.png"))); // NOI18N
+
+ jLabelDealerCard3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/cards/back.png"))); // NOI18N
+
+ jLabelDealerCard4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/cards/back.png"))); // NOI18N
javax.swing.GroupLayout jPanelDealerTextLayout = new javax.swing.GroupLayout(jPanelDealerText);
jPanelDealerText.setLayout(jPanelDealerTextLayout);
@@ -235,81 +250,111 @@ public class MainUI extends javax.swing.JFrame {
jPanelDealerTextLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelDealerTextLayout.createSequentialGroup()
.addContainerGap()
- .addComponent(jLabelDealer)
- .addContainerGap(411, Short.MAX_VALUE))
+ .addGroup(jPanelDealerTextLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabelDealer)
+ .addGroup(jPanelDealerTextLayout.createSequentialGroup()
+ .addComponent(jLabelDealerCard1)
+ .addGap(18, 18, 18)
+ .addComponent(jLabelDealerCard2)
+ .addGap(18, 18, 18)
+ .addComponent(jLabelDealerCard3)
+ .addGap(18, 18, 18)
+ .addComponent(jLabelDealerCard4)))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanelDealerTextLayout.setVerticalGroup(
jPanelDealerTextLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelDealerTextLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabelDealer)
- .addContainerGap(52, Short.MAX_VALUE))
+ .addGap(18, 18, 18)
+ .addGroup(jPanelDealerTextLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabelDealerCard1)
+ .addComponent(jLabelDealerCard2)
+ .addComponent(jLabelDealerCard3)
+ .addComponent(jLabelDealerCard4))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
- jLabelDealerHand.setText("jLabel1");
-
javax.swing.GroupLayout jPanelDealerLayout = new javax.swing.GroupLayout(jPanelDealer);
jPanelDealer.setLayout(jPanelDealerLayout);
jPanelDealerLayout.setHorizontalGroup(
jPanelDealerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanelDealerText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(jPanelDealerLayout.createSequentialGroup()
- .addGap(54, 54, 54)
- .addComponent(jLabelDealerHand)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanelDealerLayout.setVerticalGroup(
jPanelDealerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelDealerLayout.createSequentialGroup()
.addComponent(jPanelDealerText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(49, 49, 49)
- .addComponent(jLabelDealerHand)
- .addGap(0, 114, Short.MAX_VALUE))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanelPlayer.setBackground(new java.awt.Color(0, 102, 51));
jPanelPlayerText.setBackground(new java.awt.Color(0, 102, 51));
- jLabelPlayer.setFont(new java.awt.Font("Segoe UI", 0, 30)); // NOI18N
- jLabelPlayer.setText("Player: 13");
+ jLabelPlayerCard4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/cards/back.png"))); // NOI18N
+ jLabelPlayerCard4.setText(" ");
javax.swing.GroupLayout jPanelPlayerTextLayout = new javax.swing.GroupLayout(jPanelPlayerText);
jPanelPlayerText.setLayout(jPanelPlayerTextLayout);
jPanelPlayerTextLayout.setHorizontalGroup(
jPanelPlayerTextLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelPlayerTextLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabelPlayer)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGap(14, 14, 14)
+ .addComponent(jLabelPlayerCard4)
+ .addContainerGap(119, Short.MAX_VALUE))
);
jPanelPlayerTextLayout.setVerticalGroup(
jPanelPlayerTextLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelPlayerTextLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabelPlayer)
- .addContainerGap(43, Short.MAX_VALUE))
+ .addGap(64, 64, 64)
+ .addComponent(jLabelPlayerCard4)
+ .addContainerGap(264, Short.MAX_VALUE))
);
- jLabelPlayerHand.setText("jLabel2");
+ jLabelPlayer.setFont(new java.awt.Font("Segoe UI", 0, 30)); // NOI18N
+ jLabelPlayer.setText("You");
+
+ jLabelPlayerCard2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/cards/back.png"))); // NOI18N
+
+ jLabelPlayerCard1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/cards/back.png"))); // NOI18N
+ jLabelPlayerCard1.setToolTipText("");
+
+ jLabelPlayerCard3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/assets/cards/back.png"))); // NOI18N
javax.swing.GroupLayout jPanelPlayerLayout = new javax.swing.GroupLayout(jPanelPlayer);
jPanelPlayer.setLayout(jPanelPlayerLayout);
jPanelPlayerLayout.setHorizontalGroup(
jPanelPlayerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanelPlayerText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanelPlayerLayout.createSequentialGroup()
- .addGap(54, 54, 54)
- .addComponent(jLabelPlayerHand)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addContainerGap()
+ .addGroup(jPanelPlayerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabelPlayer)
+ .addGroup(jPanelPlayerLayout.createSequentialGroup()
+ .addComponent(jLabelPlayerCard2)
+ .addGap(18, 18, 18)
+ .addComponent(jLabelPlayerCard1)))
+ .addGap(18, 18, 18)
+ .addComponent(jLabelPlayerCard3)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jPanelPlayerText, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGap(30, 30, 30))
);
jPanelPlayerLayout.setVerticalGroup(
jPanelPlayerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelPlayerLayout.createSequentialGroup()
.addComponent(jPanelPlayerText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(61, 61, 61)
- .addComponent(jLabelPlayerHand)
- .addGap(0, 163, Short.MAX_VALUE))
+ .addGap(0, 0, Short.MAX_VALUE))
+ .addGroup(jPanelPlayerLayout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jLabelPlayer)
+ .addGap(18, 18, 18)
+ .addGroup(jPanelPlayerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabelPlayerCard2)
+ .addComponent(jLabelPlayerCard1)
+ .addComponent(jLabelPlayerCard3))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout jPanelCenterLayout = new javax.swing.GroupLayout(jPanelCenter);
@@ -347,8 +392,8 @@ public class MainUI extends javax.swing.JFrame {
jLabelResult.setText(""); // clear the last result
jLabelBalance.setText(game.getBalance() + ""); // update the balance
game.startRound();
- jLabelDealerHand.setText(game.displayDealerFirstCard());
- jLabelDealer.setText(game.displayDealerFirstCardValue());
+// jLabelDealerCard1.setText(game.displayDealerFirstCard());
+ jLabelDealer.setText("Dealer: " + game.displayDealerFirstCardValue());
printPlayerHand();
}//GEN-LAST:event_jButtonDealActionPerformed
@@ -356,7 +401,7 @@ public class MainUI extends javax.swing.JFrame {
printDealerHand();
jLabelResult.setText(game.checkWhoWins());
printDealerHand();
- jLabelBalance.setText(game.getBalance() + ""); // update the balance
+ jLabelBalance.setText("R " + game.getBalance()); // update the balance
}//GEN-LAST:event_jButtonStandActionPerformed
private void jButtonHitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHitActionPerformed
@@ -366,7 +411,7 @@ public class MainUI extends javax.swing.JFrame {
private void jButtonChangeBetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonChangeBetActionPerformed
game.setBet(Double.parseDouble(JOptionPane.showInputDialog("Enter the bet amount")));
- jLabelCurrentBet.setText(Double.toString(game.getBet()));
+ jLabelCurrentBetAmount.setText("R " + Double.toString(game.getBet()));
}//GEN-LAST:event_jButtonChangeBetActionPerformed
/**
@@ -389,17 +434,17 @@ public class MainUI extends javax.swing.JFrame {
printPlayerHand();
printDealerHand();
jLabelResult.setText(game.checkWhoWins());
- jLabelBalance.setText(game.getBalance() + ""); // update the balance
+ jLabelBalance.setText("R " + game.getBalance()); // update the balance
}
private void printDealerHand() {
- jLabelDealerHand.setText(game.displayDealerHand());
- jLabelDealer.setText(game.displayDealerHandValue());
+// jLabelDealerCard1.setText(game.displayDealerHand());
+ jLabelDealer.setText("Dealer: " + game.displayDealerHandValue());
}
private void printPlayerHand() {
- jLabelPlayerHand.setText(game.displayPlayerHand());
- jLabelPlayer.setText(game.displayPlayerHandValue());
+// jLabelPlayerCard1.setText(game.displayPlayerHand());
+ jLabelPlayer.setText("You: " + game.displayPlayerHandValue());
}
// Variables declaration - do not modify//GEN-BEGIN:variables
@@ -413,9 +458,15 @@ public class MainUI extends javax.swing.JFrame {
private javax.swing.JLabel jLabelCurrentBet;
private javax.swing.JLabel jLabelCurrentBetAmount;
private javax.swing.JLabel jLabelDealer;
- private javax.swing.JLabel jLabelDealerHand;
+ private javax.swing.JLabel jLabelDealerCard1;
+ private javax.swing.JLabel jLabelDealerCard2;
+ private javax.swing.JLabel jLabelDealerCard3;
+ private javax.swing.JLabel jLabelDealerCard4;
private javax.swing.JLabel jLabelPlayer;
- private javax.swing.JLabel jLabelPlayerHand;
+ private javax.swing.JLabel jLabelPlayerCard1;
+ private javax.swing.JLabel jLabelPlayerCard2;
+ private javax.swing.JLabel jLabelPlayerCard3;
+ private javax.swing.JLabel jLabelPlayerCard4;
private javax.swing.JLabel jLabelResult;
private javax.swing.JPanel jPanelCenter;
private javax.swing.JPanel jPanelDealer;