Created
April 19, 2018 17:05
-
-
Save max-l/89fea9a1d8260b26c8b2038748286925 to your computer and use it in GitHub Desktop.
DotingBeautifulCustomers created by max_l - https://repl.it/@max_l/DotingBeautifulCustomers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.BorderLayout; | |
import java.awt.Dimension; | |
import java.awt.GridLayout; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import javax.swing.JButton; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
import javax.swing.JPanel; | |
class Main { | |
public static void main(String[] args) { | |
new ScoreBoard(); | |
} | |
} | |
class ScoreBoard extends JFrame { | |
private int scoreTeamA = 0; | |
private int scoreTeamB = 0; | |
private JPanel centerPanel = new JPanel(new GridLayout(3,2)); | |
private JButton teamAButton = new JButton("Team A Scores"); | |
private JButton teamBButton = new JButton("Team B Scores"); | |
private JButton resetButton = new JButton("reset"); | |
private JLabel displayScoreOfTeamALabel = new JLabel(); | |
private JLabel displayScoreOfTeamBLabel = new JLabel(); | |
private JLabel endOfGameLabel = new JLabel("game in progress..."); | |
public ScoreBoard() { | |
JPanel frameRootPanel = new JPanel(new BorderLayout()); | |
this.setContentPane(frameRootPanel); | |
frameRootPanel.setPreferredSize(new Dimension(500,200)); | |
populateRootPanel(frameRootPanel); | |
this.pack(); | |
this.setVisible(true); | |
} | |
protected void displayScores() { | |
displayScoreOfTeamALabel.setText("Score A: "+ scoreTeamA); | |
displayScoreOfTeamBLabel.setText("Score B: "+ scoreTeamB); | |
} | |
protected void populateRootPanel(JPanel frameRootPanel) { | |
frameRootPanel.add(centerPanel); | |
centerPanel.add(teamAButton); | |
centerPanel.add(teamBButton); | |
centerPanel.add(displayScoreOfTeamALabel); | |
centerPanel.add(displayScoreOfTeamBLabel); | |
centerPanel.add(endOfGameLabel); | |
centerPanel.add(resetButton); | |
displayScores(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment