// Set up the quiz window Quiz() { initializeData(); setTitle("FOSS Quiz App"); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(440, 400); setLocation(300, 100); setResizable(true); Container cont = getContentPane(); cont.setLayout(null); cont.setBackground(Color.WHITE); bg = new ButtonGroup(); choice1 = new JRadioButton("Choice1", true); choice2 = new JRadioButton("Choice2", false); choice3 = new JRadioButton("Choice3", false); choice4 = new JRadioButton("Choice4", false); bg.add(choice1); bg.add(choice2); bg.add(choice3); bg.add(choice4); lblmess = new JLabel("Choose a correct anwswer"); lblmess.setForeground(Color.BLACK); lblmess.setFont(new Font("Sans_Serif", Font.BOLD, 15)); btnext = new JButton("Next"); btnext.setForeground(Color.WHITE); btnext.setFont(new Font("Sans_Serif", Font.BOLD, 17)); btnext.setBackground(Color.DARK_GRAY); btnext.addActionListener(this); panel = new JPanel(); panel.setBackground(Color.WHITE); panel.setLocation(10, 60); panel.setSize(400, 300); panel.setLayout(new GridLayout(0, 1)); title = new JPanel(); title.setBackground(Color.WHITE); title.setLocation(10, 10); title.setSize(1000, 50); title.setLayout(new GridLayout(1, 0)); title.add(lblmess); panel.add(choice1); panel.add(choice2); panel.add(choice3); panel.add(choice4); panel.add(btnext); cont.add(title); cont.add(panel); setVisible(true); quizAnswerID = 0; readQuestionAnswer(quizAnswerID); }
public void testModelDimensionDpConversion() { TestComponent testComponent = new TestComponent(); MyRoot nativeComponent = new MyRoot(2.0); JPanel panel = new JPanel(); panel.add(nativeComponent); nativeComponent.setLocation(15, 20); JPanel other = new JPanel(); panel.add(other); other.setLocation(5, 5); testComponent.setNativeComponent(nativeComponent); assertEquals( new Dimension(300, 400), testComponent.toModelDp(160, nativeComponent, new Dimension(300, 400))); assertEquals( new Dimension(300, 400), testComponent.toModelDp(160, panel, new Dimension(300 * 2, 400 * 2))); assertEquals( new Dimension(300, 400), testComponent.toModelDp(160, other, new Dimension(300 * 2, 400 * 2))); assertEquals( new Dimension(300 / 2, 400 / 2), testComponent.toModelDp(2 * 160, nativeComponent, new Dimension(300, 400))); assertEquals( new Dimension(300 / 2, 400 / 2), testComponent.toModelDp(2 * 160, panel, new Dimension(300 * 2, 400 * 2))); assertEquals( new Dimension(300 / 2, 400 / 2), testComponent.toModelDp(2 * 160, other, new Dimension(300 * 2, 400 * 2))); }
public void testModelPointDpConversion() { TestComponent testComponent = new TestComponent(); MyRoot nativeComponent = new MyRoot(2.0); JPanel panel = new JPanel(); panel.add(nativeComponent); nativeComponent.setLocation(15, 20); JPanel other = new JPanel(); panel.add(other); other.setLocation(5, 5); testComponent.setNativeComponent(nativeComponent); assertEquals( new Point(100, 110), testComponent.toModelDp(160, nativeComponent, new Point(100, 110))); assertEquals( new Point(100, 110), testComponent.toModelDp(160, panel, new Point(100 * 2 + 15, 110 * 2 + 20))); assertEquals( new Point(100, 110), testComponent.toModelDp(160, other, new Point(100 * 2 + 15 - 5, 110 * 2 + 20 - 5))); assertEquals( new Point(100 / 2, 110 / 2), testComponent.toModelDp(2 * 160, nativeComponent, new Point(100, 110))); assertEquals( new Point(100 / 2, 110 / 2), testComponent.toModelDp(2 * 160, panel, new Point(100 * 2 + 15, 110 * 2 + 20))); assertEquals( new Point(100 / 2, 110 / 2), testComponent.toModelDp(2 * 160, other, new Point(100 * 2 + 15 - 5, 110 * 2 + 20 - 5))); }
/** @param panel The panel containing the light box components (e.g. a wizard) */ public LightBoxPanel(JPanel panel) { Preconditions.checkNotNull(panel, "'panel' must be present"); Preconditions.checkState(panel.getWidth() > 0, "'width' must be greater than zero"); Preconditions.checkState(panel.getHeight() > 0, "'height' must be greater than zero"); this.panel = panel; // Ensure we set the opacity (platform dependent) this.setOpaque(false); // Ensure this panel covers all the available screen area and force a repaint this.setSize(Toolkit.getDefaultToolkit().getScreenSize()); // Prevent mouse events reaching through the darkened border this.addMouseListener(new ModalMouseListener()); // Add this panel to the frame's layered panel as the palette layer (directly above the default) Panels.frame.getLayeredPane().add(this, JLayeredPane.PALETTE_LAYER); // Center the light box panel in the frame int x = (Panels.frame.getWidth() - panel.getWidth()) / 2; int y = (Panels.frame.getHeight() - panel.getHeight()) / 2; panel.setLocation(x, y); // Add the light box panel to the frame as the popup layer (over everything except a drag/drop // layer) Panels.frame.getLayeredPane().add(panel, JLayeredPane.POPUP_LAYER); }
// Paints JPanel in the center of the screen private void paintPanel() { // center the dialog panel1.setLocation( (screen.getWidth() - panel1.getWidth()) / 2, (screen.getHeight() - panel1.getHeight()) / 2); // add the dialog to the "modal dialog" layer of the // screen's layered pane. Container contentPane = screen.getContentPane(); contentPane.add(panel1); }
void setupGUI() { taDictionary = new TextArea(); taDictionary.setLocation(0, 0); taDictionary.setSize(106, 567); taDictionary.setBackground(new Color(-1)); taDictionary.setText(""); taDictionary.setRows(5); taDictionary.setColumns(1); getContentPane().add(taDictionary); tfSourc = new TextField(); tfSourc.setLocation(224, 90); tfSourc.setSize(266, 25); tfSourc.setBackground(new Color(-1)); tfSourc.setText(""); tfSourc.setColumns(10); getContentPane().add(tfSourc); lblSourc = new Label(); lblSourc.setLocation(106, 90); lblSourc.setSize(119, 25); lblSourc.setText("Source Word:"); getContentPane().add(lblSourc); /* lblDestinatio = new Label(); lblDestinatio.setLocation(106,97); lblDestinatio.setSize(119,25); lblDestinatio.setText("Destination Wor"); getContentPane().add(lblDestinatio); */ lblDestinatio = new Label(); lblDestinatio.setLocation(106, 120); lblDestinatio.setSize(119, 25); lblDestinatio.setText("Destination Word:"); getContentPane().add(lblDestinatio); lblWordSize = new Label(); lblWordSize.setLocation(106, 27); // 106,120 lblWordSize.setSize(119, 25); lblWordSize.setText("Word Size:"); getContentPane().add(lblWordSize); tfWordSize = new TextField(); tfWordSize.setLocation(224, 27); // 224,120 tfWordSize.setSize(263, 25); tfWordSize.setBackground(new Color(-1)); tfWordSize.setText("5"); tfWordSize.setColumns(10); getContentPane().add(tfWordSize); tfSourc_6 = new TextField(); tfSourc_6.setLocation(226, 120); tfSourc_6.setSize(263, 25); tfSourc_6.setBackground(new Color(-1)); tfSourc_6.setText(""); tfSourc_6.setColumns(10); getContentPane().add(tfSourc_6); lblFileNam = new Label(); lblFileNam.setLocation(104, 0); lblFileNam.setSize(119, 25); lblFileNam.setText("FilePath:"); getContentPane().add(lblFileNam); tfFilePat = new TextField(); tfFilePat.setLocation(224, 0); tfFilePat.setSize(266, 25); tfFilePat.setBackground(new Color(-1)); // OS Detection if (System.getProperty("os.name").startsWith("Windows")) { // includes: Windows 2000, Windows 95, Windows 98, Windows NT, Windows Vista, Windows XP tfFilePat.setText("c:\\ics340\\words.txt"); System.out.println("Detected Windows: " + System.getProperty("os.name")); } else { tfFilePat.setText("/Users/jasonedstrom/ics340/d1.txt"); System.out.println("Detected Mac OS X: " + System.getProperty("os.name")); } tfFilePat.setColumns(10); getContentPane().add(tfFilePat); btLoadTextFiel = new JButton(); btLoadTextFiel.setLocation(108, 50); // 108,27 btLoadTextFiel.setSize(198, 32); btLoadTextFiel.setText("Load Words from Text Field"); getContentPane().add(btLoadTextFiel); btLoadFil = new JButton(); btLoadFil.setLocation(306, 50); // 306,27 btLoadFil.setSize(183, 32); btLoadFil.setText("Load Words from File"); getContentPane().add(btLoadFil); btFindPat = new JButton(); btFindPat.setLocation(106, 160); btFindPat.setSize(384, 38); btFindPat.setText("Find Path"); getContentPane().add(btFindPat); lblDictCoun = new JLabel(); lblDictCoun.setLocation(108, 513); lblDictCoun.setSize(300, 27); lblDictCoun.setForeground(new Color(-65536)); lblDictCoun.setText("Words in Dictionary = 0 words"); getContentPane().add(lblDictCoun); lblIndexing1 = new JLabel(); lblIndexing1.setLocation(107, 454); lblIndexing1.setSize(130, 27); lblIndexing1.setForeground(new Color(-16777216)); lblIndexing1.setText(""); getContentPane().add(lblIndexing1); lblFindPat = new JLabel(); lblFindPat.setLocation(108, 540); lblFindPat.setSize(250, 27); lblFindPat.setForeground(new Color(-14646771)); lblFindPat.setText("Time to find Path: 0 milliseconds"); getContentPane().add(lblFindPat); lblCos = new JLabel(); lblCos.setLocation(360, 540); lblCos.setSize(175, 27); lblCos.setForeground(new Color(-16777216)); lblCos.setText("Cost of Path: 0.0"); getContentPane().add(lblCos); lblProgres = new JLabel(); lblProgres.setLocation(108, 484); lblProgres.setSize(371, 26); lblProgres.setForeground(new Color(-14646771)); lblProgres.setText("Time to Build Graph: 0 milliseconds"); getContentPane().add(lblProgres); testpanel = new JPanel(); testpanel.setLocation(106, 200); testpanel.setSize(350, 200); testpanel.setForeground(new Color(-14646771)); // testpanel.setText("Test Location"); getContentPane().add(testpanel); btClear = new JButton(); btClear.setLocation(355, 513); btClear.setSize(125, 25); btClear.setText("Clear Results"); getContentPane().add(btClear); // add actionlisteners to buttons btFindPat.addActionListener(this); btLoadTextFiel.addActionListener(this); btLoadFil.addActionListener(this); btClear.addActionListener(this); setTitle("WordLadderGUI"); setSize(500, 600); setVisible(true); setResizable(false); }
/** * setupNoLandPermPanel. * * @param p a {@link javax.swing.JPanel} object. * @param list a {@link java.util.ArrayList} object. * @param stack a boolean. */ private static void setupNoLandPermPanel(JPanel p, ArrayList<Card> list, boolean stack) { int maxY = 0; int maxX = 0; Card c; if (stack) { // add all Cards in list to the GUI, add arrows to Local Enchantments ArrayList<Card> planeswalkers = getPlaneswalkers(list); ArrayList<Card> equippedEnchantedCreatures = getEquippedEnchantedCreatures( list); // this will also fetch the equipment and/or enchantment ArrayList<Card> nonTokenCreatures = getNonTokenCreatures(list); ArrayList<Card> tokenCreatures = getTokenCreatures(list); // sort tokenCreatures by name (TODO: fix the warning message somehow) Collections.sort( tokenCreatures, new Comparator<Card>() { public int compare(Card c1, Card c2) { return c1.getName().compareTo(c2.getName()); } }); ArrayList<Card> artifacts = getNonCreatureArtifacts(list); ArrayList<Card> enchantments = getGlobalEnchantments(list); // ArrayList<Card> nonBasics = getNonBasics(list); list = new ArrayList<Card>(); list.addAll(planeswalkers); list.addAll(equippedEnchantedCreatures); list.addAll(nonTokenCreatures); list.addAll(tokenCreatures); list.addAll(artifacts); list.addAll(enchantments); int atInStack = 0; int marginX = 5; int marginY = 5; int x = marginX; int cardOffset = Constant.Runtime.stackOffset[0]; String color = ""; ArrayList<JPanel> cards = new ArrayList<JPanel>(); ArrayList<CardPanel> connectedCards = new ArrayList<CardPanel>(); boolean nextEquippedEnchanted = false; int nextXIfNotStacked = 0; Card prevCard = null; for (int i = 0; i < list.size(); i++) { JPanel addPanel; c = list.get(i); addPanel = new CardPanel(c); boolean startANewStack = false; if (!isStackable(c)) { startANewStack = true; } else { String newColor = c.getName(); // CardUtil.getColor(c); if (!newColor.equals(color)) { startANewStack = true; color = newColor; } } if (i == 0) { startANewStack = false; } if (!startANewStack && atInStack == Constant.Runtime.stackSize[0]) { startANewStack = true; } if ((c.isEquipment() || c.isAura()) && (c.isEquipping() || c.isEnchanting()) && !nextEquippedEnchanted) startANewStack = false; else if ((c.isEquipment() || c.isAura()) && (c.isEquipping() || c.isEnchanting())) { startANewStack = true; nextEquippedEnchanted = false; } if (c.isCreature() && (c.isEquipped() || c.isEnchanted())) { startANewStack = false; nextEquippedEnchanted = true; } // very hacky, but this is to ensure equipment stacking occurs correctly when a token is // equipped/enchanted, and there are more tokens of that same name else if ((prevCard != null && c.isCreature() && prevCard.isCreature() && (prevCard.isEquipped() || prevCard.isEnchanted()) && prevCard.getName().equals(c.getName()))) startANewStack = true; else if (prevCard != null && c.isCreature() && prevCard.isCreature() && !prevCard.getName().equals(c.getName())) startANewStack = true; if (((c.isAura() && c.isEnchanting()) || (c.isEquipment() && c.isEquipping())) && prevCard != null && prevCard.isPlaneswalker()) startANewStack = true; if (startANewStack) { setupConnectedCards(connectedCards); connectedCards.clear(); // Fixed distance if last was a stack, looks a bit nicer if (atInStack > 1) { x += Math.max(addPanel.getPreferredSize().width, addPanel.getPreferredSize().height) + marginX; } else { x = nextXIfNotStacked; } atInStack = 0; } else { if (i != 0) { x += cardOffset; } } nextXIfNotStacked = x + marginX + addPanel.getPreferredSize().width; int xLoc = x; int yLoc = marginY; yLoc += atInStack * cardOffset; addPanel.setLocation(new Point(xLoc, yLoc)); addPanel.setSize(addPanel.getPreferredSize()); cards.add(addPanel); connectedCards.add((CardPanel) addPanel); atInStack++; prevCard = c; } setupConnectedCards(connectedCards); connectedCards.clear(); for (int i = cards.size() - 1; i >= 0; i--) { JPanel card = cards.get(i); // maxX = Math.max(maxX, card.getLocation().x + card.getSize().width + marginX); maxY = Math.max(maxY, card.getLocation().y + card.getSize().height + marginY); p.add(card); } maxX = nextXIfNotStacked; if (maxX > 0 && maxY > 0) { // p.getSize().width || maxY > p.getSize().height) { p.setPreferredSize(new Dimension(maxX, maxY)); } } else { JPanel addPanel; for (int i = 0; i < list.size(); i++) { c = list.get(i); addPanel = new CardPanel(c); p.add(addPanel); } } } // setupPanel()
/** * setupPanel. * * @param p a {@link javax.swing.JPanel} object. * @param list a {@link java.util.ArrayList} object. * @param stack a boolean. */ private static void setupPanel(JPanel p, ArrayList<Card> list, boolean stack) { int maxY = 0; int maxX = 0; // remove all local enchantments Card c; /* for(int i = 0; i < list.size(); i++) { c = (Card)list.get(i); if(c.isLocalEnchantment()) list.remove(i); } //add local enchantments to the permanents //put local enchantments "next to" the permanent they are enchanting //the inner for loop is backward so permanents with more than one local enchantments are in the right order Card ca[]; for(int i = 0; i < list.size(); i++) { c = (Card)list.get(i); if(c.hasAttachedCards()) { ca = c.getAttachedCards(); for(int inner = ca.length - 1; 0 <= inner; inner--) list.add(i + 1, ca[inner]); } } */ if (stack) { // add all Cards in list to the GUI, add arrows to Local Enchantments ArrayList<Card> manaPools = getManaPools(list); ArrayList<Card> enchantedLands = getEnchantedLands(list); ArrayList<Card> basicBlues = getBasics(list, Constant.Color.Blue); ArrayList<Card> basicReds = getBasics(list, Constant.Color.Red); ArrayList<Card> basicBlacks = getBasics(list, Constant.Color.Black); ArrayList<Card> basicGreens = getBasics(list, Constant.Color.Green); ArrayList<Card> basicWhites = getBasics(list, Constant.Color.White); ArrayList<Card> badlands = getNonBasicLand(list, "Badlands"); ArrayList<Card> bayou = getNonBasicLand(list, "Bayou"); ArrayList<Card> plateau = getNonBasicLand(list, "Plateau"); ArrayList<Card> scrubland = getNonBasicLand(list, "Scrubland"); ArrayList<Card> savannah = getNonBasicLand(list, "Savannah"); ArrayList<Card> taiga = getNonBasicLand(list, "Taiga"); ArrayList<Card> tropicalIsland = getNonBasicLand(list, "Tropical Island"); ArrayList<Card> tundra = getNonBasicLand(list, "Tundra"); ArrayList<Card> undergroundSea = getNonBasicLand(list, "Underground Sea"); ArrayList<Card> volcanicIsland = getNonBasicLand(list, "Volcanic Island"); ArrayList<Card> nonBasics = getNonBasics(list); ArrayList<Card> moxEmerald = getMoxen(list, "Mox Emerald"); ArrayList<Card> moxJet = getMoxen(list, "Mox Jet"); ArrayList<Card> moxPearl = getMoxen(list, "Mox Pearl"); ArrayList<Card> moxRuby = getMoxen(list, "Mox Ruby"); ArrayList<Card> moxSapphire = getMoxen(list, "Mox Sapphire"); // ArrayList<Card> moxDiamond = getMoxen(list, "Mox Diamond"); list = new ArrayList<Card>(); list.addAll(manaPools); list.addAll(enchantedLands); list.addAll(basicBlues); list.addAll(basicReds); list.addAll(basicBlacks); list.addAll(basicGreens); list.addAll(basicWhites); list.addAll(badlands); list.addAll(bayou); list.addAll(plateau); list.addAll(scrubland); list.addAll(savannah); list.addAll(taiga); list.addAll(tropicalIsland); list.addAll(tundra); list.addAll(undergroundSea); list.addAll(volcanicIsland); list.addAll(nonBasics); list.addAll(moxEmerald); list.addAll(moxJet); list.addAll(moxPearl); list.addAll(moxRuby); list.addAll(moxSapphire); // list.addAll(moxDiamond); int atInStack = 0; int marginX = 5; int marginY = 5; int x = marginX; int cardOffset = Constant.Runtime.stackOffset[0]; String color = ""; ArrayList<JPanel> cards = new ArrayList<JPanel>(); ArrayList<CardPanel> connectedCards = new ArrayList<CardPanel>(); boolean nextEnchanted = false; Card prevCard = null; int nextXIfNotStacked = 0; for (int i = 0; i < list.size(); i++) { JPanel addPanel; c = list.get(i); addPanel = new CardPanel(c); boolean startANewStack = false; if (!isStackable(c)) { startANewStack = true; } else { String newColor = c.getName(); // CardUtil.getColor(c); if (!newColor.equals(color)) { startANewStack = true; color = newColor; } } if (i == 0) { startANewStack = false; } if (!startANewStack && atInStack == Constant.Runtime.stackSize[0]) { startANewStack = true; } if (c.isAura() && c.isEnchanting() && !nextEnchanted) startANewStack = false; else if (c.isAura() && c.isEnchanting()) { startANewStack = true; nextEnchanted = false; } if (c.isLand() && c.isEnchanted()) { startANewStack = false; nextEnchanted = true; } // very hacky, but this is to ensure enchantment stacking occurs correctly when a land is // enchanted, and there are more lands of that same name else if ((prevCard != null && c.isLand() && prevCard.isLand() && prevCard.isEnchanted() && prevCard.getName().equals(c.getName()))) startANewStack = true; else if (prevCard != null && c.isLand() && prevCard.isLand() && !prevCard.getName().equals(c.getName())) startANewStack = true; /* if (c.getName().equals("Squirrel Nest")) { startANewStack = true; System.out.println("startANewStack: " + startANewStack); } */ if (c.isAura() && c.isEnchanting() && prevCard != null && prevCard instanceof ManaPool) startANewStack = true; if (c instanceof ManaPool && prevCard instanceof ManaPool && prevCard.isSnow()) startANewStack = false; if (startANewStack) { setupConnectedCards(connectedCards); connectedCards.clear(); // Fixed distance if last was a stack, looks a bit nicer if (atInStack > 1) { x += Math.max(addPanel.getPreferredSize().width, addPanel.getPreferredSize().height) + marginX; } else { x = nextXIfNotStacked; } atInStack = 0; } else { if (i != 0) { x += cardOffset; } } nextXIfNotStacked = x + marginX + addPanel.getPreferredSize().width; int xLoc = x; int yLoc = marginY; yLoc += atInStack * cardOffset; addPanel.setLocation(new Point(xLoc, yLoc)); addPanel.setSize(addPanel.getPreferredSize()); cards.add(addPanel); connectedCards.add((CardPanel) addPanel); atInStack++; prevCard = c; } setupConnectedCards(connectedCards); connectedCards.clear(); for (int i = cards.size() - 1; i >= 0; i--) { JPanel card = cards.get(i); // maxX = Math.max(maxX, card.getLocation().x + card.getSize().width + marginX); maxY = Math.max(maxY, card.getLocation().y + card.getSize().height + marginY); p.add(card); } maxX = nextXIfNotStacked; // System.out.println("x:" + maxX + ", y:" + maxY); if (maxX > 0 && maxY > 0) { // p.getSize().width || maxY > p.getSize().height) { // p.setSize(new Dimension(maxX, maxY)); p.setPreferredSize(new Dimension(maxX, maxY)); } } else { // add all Cards in list to the GUI, add arrows to Local Enchantments JPanel addPanel; for (int i = 0; i < list.size(); i++) { c = list.get(i); /*if(c.isLocalEnchantment()) addPanel = getCardPanel(c, "<< " +c.getName()); else addPanel = getCardPanel(c); */ addPanel = new CardPanel(c); p.add(addPanel); } } } // setupPanel()
/** * This method creates the content pane that will be a part of the frame, including the JLabels, * JPanels and the JButtons INPUT (parameters): none OUTOUT (return): the main JPanel object that * includes everything */ public JPanel createContentPane() { JPanel totalGUI = new JPanel(); // the main panel totalGUI.setBackground(Color.BLACK); totalGUI.setLayout(null); printInstructions(); startNum = In.getInt(); if (startNum == 1) startGame = true; else startGame = false; while (!startGame) { System.out.println("Please enter 1 to start the game"); startNum = In.getInt(); if (startNum == 1) startGame = true; else startGame = false; } if (startGame) { titlePanel = new JPanel(); // a panel where the title will be displayed titlePanel.setLayout(null); titlePanel.setLocation(0, 0); titlePanel.setSize(1600, 150); Color titlePanelColor = new Color(238, 130, 238); titlePanel.setBackground(titlePanelColor); totalGUI.add(titlePanel); // this panel is added to the main panel gamePanel = new JPanel(); // game panel (where the cards will be displayed) gamePanel.setLayout(null); gamePanel.setLocation(0, 150); gamePanel.setSize(950, 650); gamePanel.setBackground(Color.BLACK); totalGUI.add(gamePanel); newGameButton = new JButton("Start"); // a button to start the game newGameButton.setLocation(800, 155); newGameButton.setSize(120, 30); newGameButton.addActionListener(this); gamePanel.add(newGameButton); // this button is added to the game panel endGameButton = new JButton("End Game"); // a button to end the game endGameButton.setLocation(800, 195); endGameButton.setSize(120, 30); endGameButton.addActionListener(this); gamePanel.add(endGameButton); hitButton = new JButton("Hit! (Player)"); // a hit button for the player hitButton.setLocation(800, 235); hitButton.setSize(120, 30); hitButton.addActionListener(this); gamePanel.add(hitButton); hitButton2 = new JButton("Hit! (Dealer)"); // a hit button for the dealer hitButton2.setLocation(800, 275); hitButton2.setSize(120, 30); hitButton2.addActionListener(this); gamePanel.add(hitButton2); standButton = new JButton("Stand (Player)"); // a stand button for the player standButton.setLocation(800, 315); standButton.setSize(120, 30); standButton.addActionListener(this); gamePanel.add(standButton); standButton2 = new JButton("Stand (Dealer)"); // a stand button for the dealer standButton2.setLocation(800, 355); standButton2.setSize(120, 30); standButton2.addActionListener(this); gamePanel.add(standButton2); playerTitle = new JLabel( "Player"); // label that displays the word "Player" on the screen playerTitle.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); Color playerTitleColor = new Color(0, 250, 154); playerTitle.setForeground(playerTitleColor); playerTitle.setLocation(550, 150); playerTitle.setSize(100, 30); gamePanel.add(playerTitle); dealerTitle = new JLabel("Dealer"); // label that displays the word "Dealer" on the screen dealerTitle.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); Color dealerTitleColor = new Color(0, 250, 154); dealerTitle.setForeground(dealerTitleColor); dealerTitle.setLocation(550, 350); dealerTitle.setSize(100, 30); gamePanel.add(dealerTitle); scoreLabel = new JLabel(""); // label that displays the score scoreLabel.setFont(new Font("Comic Sans MS", Font.BOLD, 30)); Color scoreLabelColor = new Color(255, 20, 147); scoreLabel.setForeground(scoreLabelColor); scoreLabel.setLocation(200, 130); scoreLabel.setSize(400, 300); gamePanel.add(scoreLabel); turnLabel = new JLabel(""); // label that informs the users whose turn it is turnLabel.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); Color turnLabelColor = new Color(255, 127, 80); turnLabel.setForeground(turnLabelColor); turnLabel.setLocation(250, 200); turnLabel.setSize(300, 100); gamePanel.add(turnLabel); score1 = new JLabel(""); score1.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); Color score1Color = new Color(255, 127, 80); score1.setForeground(score1Color); score1.setLocation(660, 135); score1.setSize(100, 60); gamePanel.add(score1); score2 = new JLabel(""); score2.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); Color score2Color = new Color(255, 127, 80); score2.setForeground(score2Color); score2.setLocation(660, 335); score2.setSize(100, 60); gamePanel.add(score2); ImageIcon titleIcon1 = new ImageIcon("BlackJack.jpg"); titlePics = new JLabel(titleIcon1); // an image for decor titlePics.setLocation(0, 0); titlePics.setSize(150, 150); titlePanel.add(titlePics); // image added to title label welcomeLabel = new JLabel("Welcome To Casino Royale!"); welcomeLabel.setFont(new Font("Monotype Corsiva", Font.BOLD, 40)); Color titleColor = new Color(0, 255, 255); // title welcomeLabel.setForeground(titleColor); welcomeLabel.setLocation(245, 0); welcomeLabel.setSize(700, 100); titlePanel.add(welcomeLabel); commandLabel = new JLabel("Please press \"Start\" to start a game of Black Jack!"); commandLabel.setFont(new Font("Comic Sans MS", Font.BOLD, 16)); Color commandColor = new Color(0, 0, 0); commandLabel.setForeground(commandColor); // instruction to user on how to start the game commandLabel.setLocation(250, 101); commandLabel.setSize(700, 44); titlePanel.add(commandLabel); ImageIcon titleIcon3 = new ImageIcon("Swirl.jpg"); titlePics = new JLabel(titleIcon3); // an image for decor titlePics.setLocation(783, 0); titlePics.setSize(150, 150); titlePanel.add(titlePics); totalGUI.setOpaque(true); return totalGUI; // return the final JPanel } return totalGUI; }