public void addCreateFilesActionListener(ActionListener l) { createFilesButton.addActionListener(l); }
public void addShowFilesActionListener(ActionListener l) { showFilesButton.addActionListener(l); }
public SplashScreen() { setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setResizable(false); setTitle("Kahuna - Choose player names"); setSize(400, 400); getContentPane() .setLayout( new MigLayout( "", "[][20px:20px:20px][][150px:150px:150px,grow][][][150px:150px:150px,grow][20px:20px:20px]", "[grow][][][][][][][][][][][][][]")); JLabel splashImagePlaceholderLabel = new JLabel(""); getContentPane().add(splashImagePlaceholderLabel, "cell 3 0 4 1,alignx center"); splashImagePlaceholderLabel.setIcon(new ImageIcon("resources/graphics/SplashImage.jpg")); JLabel whitePlayerLabel = new JLabel("White Player"); getContentPane().add(whitePlayerLabel, "cell 3 1"); whitePlayerTextField = new JTextField(); getContentPane().add(whitePlayerTextField, "cell 6 1,growx"); whitePlayerTextField.setColumns(10); JLabel blackPlayerLabel = new JLabel("Black Player"); getContentPane().add(blackPlayerLabel, "cell 3 2"); blackPlayerTextField = new JTextField(); getContentPane().add(blackPlayerTextField, "cell 6 2,growx"); blackPlayerTextField.setColumns(10); JButton beginGameButton = new JButton("Begin Game"); beginGameButton.setIcon(new ImageIcon("resources/graphics/play.png")); beginGameButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent notUsed) { if (whitePlayerTextField.getText().trim().isEmpty() || blackPlayerTextField.getText().trim().isEmpty()) { JOptionPane.showMessageDialog( SplashScreen.this, "Please enter usernames for both players", "Players usernames", JOptionPane.WARNING_MESSAGE | JOptionPane.OK_OPTION); return; } Player whitePlayer = new Player(whitePlayerTextField.getText().trim(), PlayerColour.WHITE); Player blackPlayer = new Player(blackPlayerTextField.getText().trim(), PlayerColour.BLACK); KahunaMainFrame kahuna = new KahunaMainFrame(whitePlayer, blackPlayer); kahuna.setVisible(true); SplashScreen.this.setVisible(false); } }); getContentPane().add(beginGameButton, "cell 3 7,growx"); JButton exitButton = new JButton("Exit"); exitButton.setIcon(new ImageIcon("resources/graphics/exit.png")); exitButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent notUsed) { System.exit(0); } }); getContentPane().add(exitButton, "cell 6 7,growx"); }