/** Constructor for allocating memory and simple initializing. */ public GameBoard() { dealerPanel = new JPanel(); playerPanel = new JPanel(); controlPanel = new JPanel(); money = new JLabel(); record = new JLabel(); inputImage = new JLabel(new ImageIcon("res/INPUT.gif")); moneyLabel = new JLabel(new ImageIcon("res/MONEY.gif")); betLabel = new JLabel(new ImageIcon("res/MAKE_YOUR_BET.gif")); recordLabel = new JLabel(new ImageIcon("res/BEST_SCORE.gif")); betButton = new JButton(new ImageIcon("res/BET.gif")); resultButton = new JButton(new ImageIcon("res/RESULT.gif")); betInput = new JTextField(); try { recordReader = new BufferedReader(new FileReader("res/record")); bestScore = Integer.parseInt(recordReader.readLine()); recordReader.close(); } catch (Exception e) { e.printStackTrace(); } inputImage.setLayout(new BorderLayout()); controlPanel.setLayout(new FlowLayout()); betInput.setHorizontalAlignment(JTextField.CENTER); betButton.setBorder(BorderFactory.createEmptyBorder()); betButton.setContentAreaFilled(false); resultButton.setBorder(BorderFactory.createEmptyBorder()); resultButton.setContentAreaFilled(false); resultButton.setEnabled(false); betButton.addMouseListener(new BetListener()); resultButton.addMouseListener(new ResultListener()); betInput.setOpaque(false); betInput.setBorder(BorderFactory.createEmptyBorder()); money.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 30)); record.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 30)); setOpaque(false); initGame(); initRound(); }
ShutdownFrame(CryoBay cb) { super("CryoBay Monitor"); cryoB = cb; cmdClose = new JButton("Close") { public JToolTip createToolTip() { return new JToolTip(); } }; cmdClose.setToolTipText("Close program"); cmdClose.addActionListener(this); addWindowListener(this); GridBagConstraints gbc = new GridBagConstraints(); Border loweredbevel = BorderFactory.createLoweredBevelBorder(); lblBStatus = new JLabel("Status: "); lblBHeater = new JLabel("Heater: "); lblBTemp = new JLabel(" Temp: "); lblBCli = new JLabel(" CLI: "); lblStatus = new JTextField(17); lblStatus.setEditable(false); lblStatus.setOpaque(true); lblStatus.setBorder(loweredbevel); lblHeater = new JTextField(17); lblHeater.setEditable(false); lblHeater.setOpaque(true); lblHeater.setBorder(loweredbevel); lblTemp = new JTextField(17); lblTemp.setEditable(false); lblTemp.setOpaque(true); lblTemp.setBorder(loweredbevel); lblCli = new JTextField(17); lblCli.setEditable(false); lblCli.setOpaque(true); lblCli.setBorder(loweredbevel); JPanel lblPanel = new JPanel(); lblPanel.setLayout(new GridBagLayout()); gbc.insets = new Insets(2, 5, 2, 5); setGbc(gbc, 0, 0, 1, 1); lblPanel.add(lblBStatus, gbc); setGbc(gbc, 0, 1, 1, 1); lblPanel.add(lblBHeater, gbc); setGbc(gbc, 0, 2, 1, 1); lblPanel.add(lblBTemp, gbc); setGbc(gbc, 0, 3, 1, 1); lblPanel.add(lblBCli, gbc); JPanel valPanel = new JPanel(); valPanel.setLayout(new GridBagLayout()); gbc.insets = new Insets(2, 5, 2, 5); setGbc(gbc, 0, 0, 1, 1); valPanel.add(lblStatus, gbc); setGbc(gbc, 0, 1, 1, 1); valPanel.add(lblHeater, gbc); setGbc(gbc, 0, 2, 1, 1); valPanel.add(lblTemp, gbc); setGbc(gbc, 0, 3, 1, 1); valPanel.add(lblCli, gbc); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); gbc.anchor = GridBagConstraints.CENTER; setGbc(gbc, 0, 5, 1, 1); buttonPanel.add(cmdClose, gbc); // finally, add the panels to the content pane getContentPane().setLayout(new GridBagLayout()); gbc.insets = new Insets(10, 10, 10, 10); gbc.anchor = GridBagConstraints.CENTER; setGbc(gbc, 0, 0, 1, 4); getContentPane().add(lblPanel, gbc); setGbc(gbc, 1, 0, 1, 4); getContentPane().add(valPanel, gbc); setGbc(gbc, 0, 5, 0, 0); getContentPane().add(buttonPanel, gbc); setSize(300, 220); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setLocation(screenSize.width / 2 - 300, screenSize.height / 2 - 220); setResizable(true); }