private JPanel getContentPanel() { JPanel contentPanel1 = new JPanel(); summaryPanel = new JPanel(); resultPanel = new JPanel(); jPanel1 = new javax.swing.JPanel(); createFilesButton = new JButton(); showFilesButton = new JButton(); contentPanel1.setLayout(new java.awt.BorderLayout()); jPanel1.setLayout(new MigLayout("wrap 1")); /* Summary */ summaryPanel.setLayout(new MigLayout("wrap 1,w 400")); summaryPanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Summary", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Courier", Font.BOLD, 14))); summaryField = new JTextArea("", 10, 30); summaryField.setLineWrap(true); summaryField.setWrapStyleWord(true); summaryField.setEditable(false); JScrollPane summaryScrollPane = new JScrollPane(summaryField); summaryScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS & JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); summaryPanel.add(summaryScrollPane); createFilesButton.setText("Create Data Loader CLI Files"); createFilesButton.setActionCommand(CREATE_FILES_ACTION_COMMAND); summaryPanel.add(createFilesButton, ""); jPanel1.add(summaryPanel); /* Results */ resultPanel.setLayout(new MigLayout("wrap 1,w 400")); resultPanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Results", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Courier", Font.BOLD, 14))); statusField = new JTextArea("", 6, 30); statusField.setLineWrap(true); statusField.setWrapStyleWord(true); statusField.setEditable(false); JScrollPane messageScrollPane = new JScrollPane(statusField); messageScrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS & JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); resultPanel.add(messageScrollPane); /* Not supported by Java 1.5 showFilesButton.setText("Show Files"); showFilesButton.setActionCommand(SHOW_FILES_ACTION_COMMAND); showFilesButton.setEnabled(false); resultPanel.add(showFilesButton,""); */ jPanel1.add(resultPanel); /* End */ contentPanel1.add(jPanel1, java.awt.BorderLayout.CENTER); return contentPanel1; }
public void setEnabledShowFiles(boolean b) { showFilesButton.setEnabled(b); }
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"); }