mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 10:19:46 +02:00
added saveScorePanel
This commit is contained in:
@@ -1,14 +1,17 @@
|
|||||||
package de.heatup.testing;
|
package de.heatup.testing;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import de.heatup.ui.menu.HighscorePanel;
|
import de.heatup.ui.menu.HighscorePanel;
|
||||||
|
import de.heatup.ui.menu.SaveScorePanel;
|
||||||
|
|
||||||
public class Main extends JFrame {
|
public class Main extends JFrame {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static HighscorePanel p = new HighscorePanel();
|
private static SaveScorePanel p = new SaveScorePanel();
|
||||||
|
|
||||||
public Main() {
|
public Main() {
|
||||||
|
|
||||||
@@ -16,7 +19,9 @@ public class Main extends JFrame {
|
|||||||
this.setSize(800, 600);
|
this.setSize(800, 600);
|
||||||
this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
|
this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
|
||||||
|
|
||||||
this.add(HighscorePanel.getHighscorePanel(), BorderLayout.CENTER);
|
p.setScoreLabelText(222);
|
||||||
|
this.add(p.getSaveScorePanel());
|
||||||
|
|
||||||
this.setVisible(true);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user