/** Create the frame. */ public FrmShop(final FrmGameOverview frmOver) { shop = RunningGame.getInstance().getShop(); // ArrayList<Item> derp = shop.getShopDisplay(); actions = new Actions(shop, RunningGame.getInstance().getActorPool()); final FrmShop frmShop = this; setTitle("Shop - The Dice of Death"); setAlwaysOnTop(true); setResizable(false); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setBounds(100, 100, 719, 417); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); textField = new JTextField(); textField.setFont(Constants.font.deriveFont(Font.BOLD, 27)); textField.setEditable(false); textField.setColumns(10); textField.setBounds(10, 11, 228, 59); textField.setText(shop.getShopDisplay().get(0).getStringStat("item")); contentPane.add(textField); JButton button = new JButton("View"); button.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { viewItem(shop.getShopDisplay().get(0)); } }); button.setFont(Constants.font.deriveFont(Font.BOLD, 32)); button.setBounds(242, 11, 91, 59); contentPane.add(button); textField_1 = new JTextField(); textField_1.setFont(Constants.font.deriveFont(Font.BOLD, 27)); textField_1.setEditable(false); textField_1.setColumns(10); textField_1.setBounds(10, 73, 228, 59); textField_1.setText(shop.getShopDisplay().get(1).getStringStat("item")); contentPane.add(textField_1); // String fffffuuuuuu = shop.getShopDisplay().get(1).getStringStat("item"); JButton button_1 = new JButton("View"); button_1.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { viewItem(shop.getShopDisplay().get(1)); } }); button_1.setFont(Constants.font.deriveFont(Font.BOLD, 32)); button_1.setBounds(242, 73, 91, 59); contentPane.add(button_1); JButton button_2 = new JButton("View"); button_2.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { viewItem(shop.getShopDisplay().get(2)); } }); button_2.setFont(Constants.font.deriveFont(Font.BOLD, 32)); button_2.setBounds(242, 135, 91, 59); contentPane.add(button_2); textField_2 = new JTextField(); textField_2.setFont(Constants.font.deriveFont(Font.BOLD, 27)); textField_2.setEditable(false); textField_2.setColumns(10); textField_2.setBounds(10, 135, 228, 59); textField_2.setText(shop.getShopDisplay().get(2).getStringStat("item")); contentPane.add(textField_2); JButton button_3 = new JButton("View"); button_3.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { viewItem(shop.getShopDisplay().get(3)); } }); button_3.setFont(Constants.font.deriveFont(Font.BOLD, 32)); button_3.setBounds(242, 197, 91, 59); contentPane.add(button_3); textField_3 = new JTextField(); textField_3.setFont(Constants.font.deriveFont(Font.BOLD, 27)); textField_3.setEditable(false); textField_3.setColumns(10); textField_3.setBounds(10, 197, 228, 59); textField_3.setText(shop.getShopDisplay().get(3).getStringStat("item")); contentPane.add(textField_3); textField_4 = new JTextField(); textField_4.setFont(Constants.font.deriveFont(Font.BOLD, 27)); textField_4.setEditable(false); textField_4.setColumns(10); textField_4.setBounds(10, 259, 228, 59); textField_4.setText(shop.getShopDisplay().get(4).getStringStat("item")); contentPane.add(textField_4); JButton button_4 = new JButton("View"); button_4.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { viewItem(shop.getShopDisplay().get(4)); } }); button_4.setFont(Constants.font.deriveFont(Font.BOLD, 32)); button_4.setBounds(242, 259, 91, 59); contentPane.add(button_4); textField_5 = new JTextField(); textField_5.setFont(Constants.font.deriveFont(Font.BOLD, 27)); textField_5.setEditable(false); textField_5.setColumns(10); textField_5.setBounds(10, 321, 228, 59); textField_5.setText(shop.getShopDisplay().get(5).getStringStat("item")); contentPane.add(textField_5); // ArrayList<Item> derp2 = shop.getShopDisplay(); JButton button_5 = new JButton("View"); button_5.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { viewItem(shop.getShopDisplay().get(5)); } }); button_5.setFont(Constants.font.deriveFont(Font.BOLD, 32)); button_5.setBounds(242, 321, 91, 59); contentPane.add(button_5); btnBuy = new JButton("Buy"); btnBuy.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { // ArrayList<Item> derp3 = shop.getShopDisplay(); Item boughtItem = shop.getShopDisplay().get(0); int result = actions.buyItem(0); // boughtItem = shop.getShopDisplay().get(0); if (result == 0) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(false); dlgNope.setVisible(true); } else if (result == 1) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(true); dlgNope.setVisible(true); } else { DlgItemBought dlgBought = new DlgItemBought(boughtItem); dlgBought.setVisible(true); frmOver.setItemsAndButtons(); frmOver.refreshGold(RunningGame.getInstance().getActorPool().getCurrentPlayer()); refreshGold(); textField.setText(shop.getShopDisplay().get(0).getStringStat("item")); } } }); btnBuy.setFont(Constants.font.deriveFont(Font.BOLD, 32)); btnBuy.setBounds(336, 11, 91, 59); contentPane.add(btnBuy); btnBuy_1 = new JButton("Buy"); btnBuy_1.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { // ArrayList<Item> derp = shop.getShopDisplay(); Item boughtItem = shop.getShopDisplay().get(1); int result = actions.buyItem(1); if (result == 0) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(false); dlgNope.setVisible(true); } else if (result == 1) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(true); dlgNope.setVisible(true); } else { DlgItemBought dlgBought = new DlgItemBought(boughtItem); dlgBought.setVisible(true); frmOver.setItemsAndButtons(); frmOver.refreshGold(RunningGame.getInstance().getActorPool().getCurrentPlayer()); refreshGold(); textField_1.setText(shop.getShopDisplay().get(1).getStringStat("item")); } } }); btnBuy_1.setFont(Constants.font.deriveFont(Font.BOLD, 32)); btnBuy_1.setBounds(336, 73, 91, 59); contentPane.add(btnBuy_1); btnBuy_2 = new JButton("Buy"); btnBuy_2.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { Item boughtItem = shop.getShopDisplay().get(2); int result = actions.buyItem(2); if (result == 0) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(false); dlgNope.setVisible(true); } else if (result == 1) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(true); dlgNope.setVisible(true); } else { DlgItemBought dlgBought = new DlgItemBought(boughtItem); dlgBought.setVisible(true); frmOver.setItemsAndButtons(); frmOver.refreshGold(RunningGame.getInstance().getActorPool().getCurrentPlayer()); refreshGold(); textField_2.setText(shop.getShopDisplay().get(2).getStringStat("item")); } } }); btnBuy_2.setFont(Constants.font.deriveFont(Font.BOLD, 32)); btnBuy_2.setBounds(336, 135, 91, 59); contentPane.add(btnBuy_2); btnBuy_3 = new JButton("Buy"); btnBuy_3.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { Item boughtItem = shop.getShopDisplay().get(3); int result = actions.buyItem(3); if (result == 0) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(false); dlgNope.setVisible(true); } else if (result == 1) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(true); dlgNope.setVisible(true); } else { DlgItemBought dlgBought = new DlgItemBought(boughtItem); dlgBought.setVisible(true); frmOver.setItemsAndButtons(); frmOver.refreshGold(RunningGame.getInstance().getActorPool().getCurrentPlayer()); refreshGold(); textField_3.setText(shop.getShopDisplay().get(3).getStringStat("item")); } } }); btnBuy_3.setFont(Constants.font.deriveFont(Font.BOLD, 32)); btnBuy_3.setBounds(336, 197, 91, 59); contentPane.add(btnBuy_3); btnBuy_4 = new JButton("Buy"); btnBuy_4.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { Item boughtItem = shop.getShopDisplay().get(4); int result = actions.buyItem(4); if (result == 0) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(false); dlgNope.setVisible(true); } else if (result == 1) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(true); dlgNope.setVisible(true); } else { DlgItemBought dlgBought = new DlgItemBought(boughtItem); dlgBought.setVisible(true); frmOver.setItemsAndButtons(); frmOver.refreshGold(RunningGame.getInstance().getActorPool().getCurrentPlayer()); refreshGold(); textField_4.setText(shop.getShopDisplay().get(4).getStringStat("item")); } } }); btnBuy_4.setFont(Constants.font.deriveFont(Font.BOLD, 32)); btnBuy_4.setBounds(336, 259, 91, 59); contentPane.add(btnBuy_4); btnBuy_5 = new JButton("Buy"); btnBuy_5.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { Item boughtItem = shop.getShopDisplay().get(5); int result = actions.buyItem(5); if (result == 0) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(false); dlgNope.setVisible(true); } else if (result == 1) { DlgUnableToBuy dlgNope = new DlgUnableToBuy(true); dlgNope.setVisible(true); } else { DlgItemBought dlgBought = new DlgItemBought(boughtItem); dlgBought.setVisible(true); frmOver.setItemsAndButtons(); frmOver.refreshGold(RunningGame.getInstance().getActorPool().getCurrentPlayer()); refreshGold(); textField_5.setText(shop.getShopDisplay().get(5).getStringStat("item")); } } }); btnBuy_5.setFont(Constants.font.deriveFont(Font.BOLD, 32)); btnBuy_5.setBounds(336, 321, 91, 59); contentPane.add(btnBuy_5); btnSell = new JButton("Sell"); btnSell.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { DlgSell dlgsell = new DlgSell(frmOver, frmShop); dlgsell.setVisible(true); } }); btnSell.setFont(Constants.font.deriveFont(Font.BOLD, 32)); btnSell.setBounds(553, 11, 150, 59); contentPane.add(btnSell); btnExitShop = new JButton("Exit Shop"); btnExitShop.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { dispose(); } }); btnExitShop.setFont(Constants.font.deriveFont(Font.BOLD, 32)); btnExitShop.setBounds(553, 321, 150, 59); contentPane.add(btnExitShop); lblGold = new JLabel("Gold: ___"); lblGold.setForeground(new Color(255, 215, 0)); lblGold.setHorizontalAlignment(SwingConstants.CENTER); lblGold.setFont(Constants.font.deriveFont(Font.BOLD, 36)); lblGold.setBounds(553, 73, 150, 59); contentPane.add(lblGold); lblBackground = new JLabel(""); lblBackground.setIcon( new ImageIcon( FrmShop.class.getResource("/view/resources/Treasure-Chest-Results_black.jpg"))); lblBackground.setBounds(0, 0, 713, 389); contentPane.add(lblBackground); refreshGold(); }
public void refreshGold() { lblGold.setText( "Gold: " + RunningGame.getInstance().getActorPool().getCurrentPlayer().getIntStat("gold")); }