added saveScorePanel

This commit is contained in:
timbo
2015-01-30 11:24:17 +01:00
parent 8a49c29d46
commit 39da462523
2 changed files with 144 additions and 3 deletions
+7 -2
View File
@@ -1,14 +1,17 @@
package de.heatup.testing;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import de.heatup.ui.menu.HighscorePanel;
import de.heatup.ui.menu.SaveScorePanel;
public class Main extends JFrame {
private static final long serialVersionUID = 1L;
private static HighscorePanel p = new HighscorePanel();
private static SaveScorePanel p = new SaveScorePanel();
public Main() {
@@ -16,7 +19,9 @@ public class Main extends JFrame {
this.setSize(800, 600);
this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
this.add(HighscorePanel.getHighscorePanel(), BorderLayout.CENTER);
p.setScoreLabelText(222);
this.add(p.getSaveScorePanel());
this.setVisible(true);
}
@@ -0,0 +1,136 @@
package de.heatup.ui.menu;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.TextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import de.heatup.ui.FontLoader;
public class SaveScorePanel {
private static JPanel saveScorePanel = new JPanel();
//
private static JPanel headingPanel, dividerPanel, formPanel;
private static JLabel headingLabel, dividerLabel, scoreLabel;
private static TextField nameField;
// Font loader and font Settings
private static FontLoader fl = new FontLoader();
private static Font ttfbase, emulogicHeading, emulogicDivider, emulogicSmall;
private static int score = 0;
public SaveScorePanel() {
ttfbase = FontLoader.getFont();
emulogicHeading = ttfbase.deriveFont(Font.PLAIN, 40);
emulogicDivider = ttfbase.deriveFont(Font.PLAIN, 20);
emulogicSmall = ttfbase.deriveFont(Font.PLAIN, 18);
saveScorePanel.setSize(new Dimension(800, 600));
saveScorePanel.setBackground(Color.BLACK);
saveScorePanel.setVisible(true);
initHeadingPanel();
saveScorePanel.add(headingPanel);
saveScorePanel.add(dividerPanel);
}
private static void initHeadingPanel() {
headingPanel = new JPanel();
headingPanel.setSize(new Dimension(800, 50));
headingPanel.setBackground(Color.BLACK);
headingPanel.setFocusable(false);
headingPanel.setVisible(true);
headingLabel = new JLabel();
headingLabel.setFont(emulogicHeading);
headingLabel.setForeground(Color.YELLOW);
headingLabel.setBackground(Color.BLACK);
headingLabel.setFocusable(false);
headingLabel.setText("Heatup");
headingPanel.add(headingLabel);
dividerPanel = new JPanel();
dividerPanel.setSize(new Dimension(800, 50));
dividerPanel.setBackground(Color.BLACK);
dividerPanel.setFocusable(false);
dividerPanel.setVisible(true);
dividerLabel = new JLabel();
dividerLabel.setFont(emulogicDivider);
dividerLabel.setForeground(Color.YELLOW);
dividerLabel.setBackground(Color.BLACK);
dividerLabel.setFocusable(false);
dividerLabel.setText("--------------------------------");
dividerPanel.add(dividerLabel);
}
private static void initFormPanel() {
formPanel = new JPanel();
formPanel.setSize(new Dimension(800, 400));
formPanel.setBackground(Color.BLACK);
formPanel.setFocusable(true);
formPanel.setVisible(true);
//
nameField = new TextField("Name", 25);
nameField.setEditable(true);
nameField.setFont(emulogicSmall);
//
scoreLabel = new JLabel();
scoreLabel.setFont(emulogicSmall);
scoreLabel.setForeground(Color.YELLOW);
scoreLabel.setBackground(Color.BLACK);
scoreLabel.setFocusable(false);
JPanel nameFormPanel = new JPanel();
nameFormPanel.setSize(new Dimension(800, 300));
nameFormPanel.setLayout(new GridLayout(2, 1));
nameFormPanel.setBackground(Color.BLACK);
nameFormPanel.setFocusable(true);
nameFormPanel.setVisible(true);
nameFormPanel.add(nameField);
formPanel.add(nameFormPanel);
}
public static void setScoreLabelText(int score) {
SaveScorePanel.score = score;
scoreLabel.setText("Score : " + SaveScorePanel.score);
initFormPanel();
formPanel.add(scoreLabel);
saveScorePanel.add(formPanel);
}
public static void setScore(int score) {
SaveScorePanel.score = score;
}
public static int getScore() {
return score;
}
public static JPanel getSaveScorePanel() {
return saveScorePanel;
}
public static void setSaveScorePanel(JPanel saveScorePanel) {
SaveScorePanel.saveScorePanel = saveScorePanel;
}
}