Skip to content

Commit

Permalink
lol had an idea.. last one for today
Browse files Browse the repository at this point in the history
  • Loading branch information
siqq committed Sep 7, 2014
1 parent 94f63a3 commit da081ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion Java-Missle/src/view/OrefPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

public class OrefPanel extends JPanel {
public static final String OREF_IMAGE_PATH = "/drawable/orefImage225x70.png";
public static final String OREF_ALERT_IMAGE_PATH = "/drawable/orefImage225x70Alert.png";
public static final int ALERT_DISPLAY_TIME = 8;
private JTextField topAlert, middleAlert, buttomAlert;
private JLabel orefImageLable;
Expand Down Expand Up @@ -58,21 +59,34 @@ public JTextField createNewAlert() {
}

public void addMissileToOrefPanel(String destination, int time, int flyTime) {

// time % 2 - to make the alert blink every second
if (time < ALERT_DISPLAY_TIME && time % 2 == 0) {
topAlert.setText("Alert in " + destination);
validate();
setOrefImage(OREF_ALERT_IMAGE_PATH);
} else if (time < ALERT_DISPLAY_TIME) {
setOrefImage(OREF_ALERT_IMAGE_PATH);
topAlert.setText("");

} else {
topAlert.setText("");
// the alert is finished, free the topAlert Label
setOrefImage(OREF_IMAGE_PATH);
topAlert.setText("");

}
if (time == flyTime) {
// if missile flyTime is less then ALERT_DISPLAY_TIME
topAlert.setText("");
setOrefImage(OREF_IMAGE_PATH);

}
}

private void setOrefImage(String orefImagePath) {
orefImageLable.setIcon(new ImageIcon(OrefPanel.class
.getResource(orefImagePath)));

}

}

0 comments on commit da081ae

Please sign in to comment.