Skip to content

Commit

Permalink
OrefPanel class Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
siqq committed Sep 7, 2014
1 parent 6ac0a23 commit 94f63a3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
44 changes: 22 additions & 22 deletions Java-Missle/src/view/OrefPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,43 +36,43 @@ public OrefPanel() {
.getResource(OREF_IMAGE_PATH)));
add(orefImageLable);

topAlert = new JTextField(" ");
topAlert.setBackground(new Color(255, 127, 80));
add(topAlert);
topAlert.setColumns(10);
topAlert = createNewAlert();
middleAlert = createNewAlert();
buttomAlert = createNewAlert();

middleAlert = new JTextField(" ");
middleAlert.setBackground(new Color(255, 127, 80));
add(topAlert);
add(middleAlert);
middleAlert.setColumns(10);

buttomAlert = new JTextField(" ");
buttomAlert.setBackground(new Color(255, 127, 80));
add(buttomAlert);
buttomAlert.setColumns(10);

topAlert.setFont(font);
middleAlert.setFont(font);
buttomAlert.setFont(font);

topAlert.setForeground(Color.WHITE);
;
}

topAlert.setEditable(false);
middleAlert.setEditable(false);
buttomAlert.setEditable(false);
public JTextField createNewAlert() {
JTextField textBox = new JTextField("");
textBox.setBackground(new Color(255, 127, 80));
textBox.setColumns(10);
textBox.setFont(font);
textBox.setForeground(Color.WHITE);
textBox.setHorizontalAlignment(JTextField.CENTER);
textBox.setEditable(false);
return textBox;
}

public void addMissileToOrefPanel(String destination, int time) {
public void addMissileToOrefPanel(String destination, int time, int flyTime) {
if (time < ALERT_DISPLAY_TIME && time % 2 == 0) {
topAlert.setText(" Alert in " + destination);
topAlert.setText("Alert in " + destination);
validate();
} else if (time < ALERT_DISPLAY_TIME) {
topAlert.setText("");

} else {
topAlert.setText("");
// the alert is finished, free the topAlert Label
}
if (time == flyTime) {
// if missile flyTime is less then ALERT_DISPLAY_TIME
topAlert.setText("");

}
}

}
2 changes: 1 addition & 1 deletion Java-Missle/src/view/WarGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void updateMissileProgress(int time, String missileId, String type,
String destination, int damage, int flyTime) {
progressPanel.updateMissileTime(time, missileId, type,destination,damage,flyTime);

orefPanel.addMissileToOrefPanel(destination, time);
orefPanel.addMissileToOrefPanel(destination, time, flyTime);
}

public void selectIronDomeToFireFrom(String missileId) {
Expand Down

0 comments on commit 94f63a3

Please sign in to comment.