Skip to content

Commit

Permalink
top Oref Panel Alert Works
Browse files Browse the repository at this point in the history
  • Loading branch information
siqq committed Sep 6, 2014
1 parent f27d0f3 commit 6ac0a23
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
36 changes: 25 additions & 11 deletions Java-Missle/src/view/OrefPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@

import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import javax.swing.JOptionPane;
import javax.swing.SpringLayout;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JButton;

import java.awt.Font;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.GridLayout;

import javax.swing.JTextField;

import war.controller.WarUIEventsListener;

public class OrefPanel extends JPanel {
public static final String OREF_IMAGE_PATH = "/drawable/orefImage225x70.png";
public static final int ALERT_DISPLAY_TIME = 8;
private JTextField topAlert, middleAlert, buttomAlert;
private JLabel orefImageLable;
private Font font = new Font("SansSerif", Font.BOLD, 20);

public OrefPanel() {
setBackground(Color.DARK_GRAY);
Expand All @@ -45,20 +51,28 @@ public OrefPanel() {
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 void addMissileToOrefPanel(String destination) {
if (topAlert.getText() == " ") {
topAlert.setText(destination);
public void addMissileToOrefPanel(String destination, int time) {
if (time < ALERT_DISPLAY_TIME && time % 2 == 0) {
topAlert.setText(" Alert in " + destination);
validate();
} else if (time < ALERT_DISPLAY_TIME) {
topAlert.setText("");

} else {
// the alert is finished, free the topAlert Label
}
}
}








}
3 changes: 2 additions & 1 deletion Java-Missle/src/view/WarGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void addMissileDestructorToModelEvenet(String destructorId,
public void addMissileToUI(String missileId, String destination, int damage,
int flyTime) {
progressPanel.addMissileToProgressBar(missileId,destination,damage,flyTime);
orefPanel.addMissileToOrefPanel(destination);


}

Expand Down Expand Up @@ -215,6 +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);
}

public void selectIronDomeToFireFrom(String missileId) {
Expand Down

0 comments on commit 6ac0a23

Please sign in to comment.