Skip to content

Commit

Permalink
Refactoring code
Browse files Browse the repository at this point in the history
  • Loading branch information
shrianshChari committed Feb 5, 2021
1 parent 1679a1a commit f6d8cd5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public static void main(String[] args) {
fw.prepareXML("scores.xml");

ScoreboardMenu menu = new ScoreboardMenu();
menu.setVisible(true);
}
}
19 changes: 12 additions & 7 deletions src/ScoreboardMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ScoreboardMenu implements ActionListener
private final int SCORE_TEXTFIELD_HEIGHT = 100;

private final int SCORE_BUTTON_WIDTH = SCORE_TEXTFIELD_WIDTH;
private final int SCORE_BUTTON_HEIGHT = SCORE_TEXTFIELD_HEIGHT;
private final int SCORE_BUTTON_HEIGHT = SCORE_TEXTFIELD_HEIGHT / 2;
private final int SWPL_BUTTON_WIDTH = TEXTFIELD_WIDTH;

private Font prefixfont = new Font("Dialog", Font.PLAIN, 12);
Expand Down Expand Up @@ -107,12 +107,12 @@ public ScoreboardMenu() {

p1scoreup = new JButton("P1 +");
p1scoreup.setBounds(p1score.getX() - SCORE_TEXTFIELD_WIDTH, p1score.getY(),
SCORE_TEXTFIELD_WIDTH, p1score.getHeight() / 2);
SCORE_BUTTON_WIDTH, SCORE_BUTTON_HEIGHT);
panel.add(p1scoreup);

p1scoredown = new JButton("P1 -");
p1scoredown.setBounds(p1scoreup.getX(), p1scoreup.getY() + p1scoreup.getHeight(),
SCORE_TEXTFIELD_WIDTH, p1score.getHeight() / 2);
SCORE_BUTTON_WIDTH, SCORE_BUTTON_HEIGHT);
panel.add(p1scoredown);

p2prefix_label = new JLabel("Player 2 Prefix");
Expand Down Expand Up @@ -145,12 +145,12 @@ public ScoreboardMenu() {

p2scoreup = new JButton("P2 +");
p2scoreup.setBounds(p2score.getX() + SCORE_TEXTFIELD_WIDTH, p2score.getY(),
SCORE_TEXTFIELD_WIDTH, p2score.getHeight() / 2);
SCORE_BUTTON_WIDTH, SCORE_BUTTON_HEIGHT);
panel.add(p2scoreup);

p2scoredown = new JButton("P2 -");
p2scoredown.setBounds(p2scoreup.getX(), p2scoreup.getY() + p2scoreup.getHeight(),
SCORE_TEXTFIELD_WIDTH, p2score.getHeight() / 2);
SCORE_BUTTON_WIDTH, SCORE_BUTTON_HEIGHT);
panel.add(p2scoredown);

update = new JButton("Update");
Expand Down Expand Up @@ -194,8 +194,13 @@ public ScoreboardMenu() {
p2scoreup.addActionListener(this);
p2scoredown.addActionListener(this);
switchplayers.addActionListener(this);

frame.setVisible(true);
}

/*
* Shows or hides the frame
*/
public void setVisible(boolean b) {
frame.setVisible(b);
}

/*
Expand Down

0 comments on commit f6d8cd5

Please sign in to comment.