mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 10:19:46 +02:00
StatusPanelAdder verändert mit GridBagLayout
This commit is contained in:
@@ -1,13 +1,11 @@
|
|||||||
package de.heatup.ui;
|
package de.heatup.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Font;
|
||||||
import java.awt.FlowLayout;
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
@@ -33,31 +31,122 @@ public class StatusPanelAdder{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void createPanel(){
|
public static void createPanel(){
|
||||||
JProgressBar tempbar= new JProgressBar(30,90);
|
JLabel labelTemp= new JLabel("temperature");
|
||||||
tempbar.setValue(45);
|
labelTemp.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||||
//tempbar.setSize(new Dimension(200,50));
|
labelTemp.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
|
|
||||||
|
JProgressBar tempBar= new JProgressBar(30,90);
|
||||||
|
tempBar.setValue(45);
|
||||||
|
|
||||||
|
JLabel labelScore= new JLabel("score");
|
||||||
|
labelScore.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||||
|
//labelScore.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
|
|
||||||
JLabel scoreLabel= new JLabel("new Score Label");
|
JLabel scoreLabel= new JLabel("new Score Label");
|
||||||
scoreLabel.setBorder(new LineBorder(Color.BLACK, 2));
|
scoreLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
//scoreLabel.setSize(new Dimension(100,50));
|
|
||||||
|
JLabel labelPowerUp = new JLabel("PowerUp");
|
||||||
|
labelPowerUp.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||||
|
//labelPowerUp.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
|
|
||||||
JLabel powerUpLabel = new JLabel(/*new ImageIcon("path_to_image.png")*/"powerUpLabel");
|
JLabel powerUpLabel = new JLabel(/*new ImageIcon("path_to_image.png")*/"powerUpLabel");
|
||||||
powerUpLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
//powerUpLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
//powerUpLabel.setSize(new Dimension(200,50));
|
|
||||||
|
|
||||||
|
|
||||||
|
JLabel labelTime=new JLabel("Time");
|
||||||
|
labelTime.setFont(new Font("Arial", Font.CENTER_BASELINE, 16));
|
||||||
|
//labelTime.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
|
labelTime.setSize(100,10);
|
||||||
|
labelTime.setHorizontalTextPosition(SwingConstants.CENTER);
|
||||||
|
|
||||||
JLabel timeLabel = new JLabel();
|
JLabel timeLabel = new JLabel();
|
||||||
timeLabel.setBorder(new LineBorder(Color.BLACK, 2));
|
//timeLabel.setBorder(new LineBorder(Color.BLACK, 1));
|
||||||
timeLabel.setText("0");
|
timeLabel.setText("123456789");
|
||||||
//timeLabel.setSize(new Dimension(300,24)); //Groesse,
|
timeLabel.setFont(new Font("Arial", Font.ITALIC, 12));
|
||||||
timeLabel.setHorizontalAlignment(SwingConstants.CENTER );
|
|
||||||
|
//Insets(int top, int left, int bottom, int right);
|
||||||
|
|
||||||
|
|
||||||
|
GameInterface.getStatusPanel().add(labelTime, new GridBagConstraints( // formPanel ist das Panel, indas eingefügt wird
|
||||||
|
1, 1, // Spaltennr., Zeilennr.
|
||||||
|
4, 2, // Spaltenbreite (gridwidth), Zeilenbreite (gridheigth)
|
||||||
|
0.0, 0.0,
|
||||||
|
GridBagConstraints.NORTH, // Ausrichtung
|
||||||
|
GridBagConstraints.BOTH,
|
||||||
|
new Insets(0,20,30,20), // Abstand zu den anderen Objekten
|
||||||
|
0,0));
|
||||||
|
|
||||||
|
GameInterface.getStatusPanel().add(timeLabel, new GridBagConstraints( // formPanel ist das Panel, indas eingefügt wird
|
||||||
|
2, 1, // Spaltennr., Zeilennr.
|
||||||
|
4, 2, // Spaltenbreite (gridwidth), Zeilenbreite (gridheigth)
|
||||||
|
0.0, 0.0,
|
||||||
|
GridBagConstraints.SOUTH, // Ausrichtung
|
||||||
|
GridBagConstraints.BOTH,
|
||||||
|
new Insets(38,20,0,20), // Abstand zu den anderen Objekten
|
||||||
|
0,0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GameInterface.getStatusPanel().add(timeLabel);
|
GameInterface.getStatusPanel().add(labelTemp, new GridBagConstraints( // formPanel ist das Panel, indas eingefügt wird
|
||||||
GameInterface.getStatusPanel().add(tempbar);
|
3, 1, // Spaltennr., Zeilennr.
|
||||||
GameInterface.getStatusPanel().add(scoreLabel);
|
4, 2, // Spaltenbreite (gridwidth), Zeilenbreite (gridheigth)
|
||||||
GameInterface.getStatusPanel().add(powerUpLabel);
|
0.0, 0.0,
|
||||||
}
|
GridBagConstraints.NORTH, // Ausrichtung
|
||||||
|
GridBagConstraints.NONE,
|
||||||
|
new Insets(0,20,30,20), // Abstand zu den anderen Objekten
|
||||||
|
0,0));
|
||||||
|
|
||||||
|
GameInterface.getStatusPanel().add(tempBar, new GridBagConstraints( // formPanel ist das Panel, indas eingefügt wird
|
||||||
|
3, 2, // Spaltennr., Zeilennr.
|
||||||
|
4, 2, // Spaltenbreite (gridwidth), Zeilenbreite (gridheigth)
|
||||||
|
0.0, 0.0,
|
||||||
|
GridBagConstraints.SOUTH, // Ausrichtung
|
||||||
|
GridBagConstraints.NONE,
|
||||||
|
new Insets(38,20,0,20), // Abstand zu den anderen Objekten
|
||||||
|
100,20));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GameInterface.getStatusPanel().add(labelScore, new GridBagConstraints( // formPanel ist das Panel, indas eingefügt wird
|
||||||
|
1, 2, // Spaltennr., Zeilennr.
|
||||||
|
4, 2, // Spaltenbreite (gridwidth), Zeilenbreite (gridheigth)
|
||||||
|
0.0, 0.0,
|
||||||
|
GridBagConstraints.NORTH, // Ausrichtung
|
||||||
|
GridBagConstraints.NONE,
|
||||||
|
new Insets (0,0,0,0), // Abstand zu den anderen Objekten
|
||||||
|
0,0));
|
||||||
|
GameInterface.getStatusPanel().add(scoreLabel, new GridBagConstraints( // formPanel ist das Panel, indas eingefügt wird
|
||||||
|
2, 2, // Spaltennr., Zeilennr.
|
||||||
|
4, 2, // Spaltenbreite (gridwidth), Zeilenbreite (gridheigth)
|
||||||
|
0.0, 0.0,
|
||||||
|
GridBagConstraints.SOUTH, // Ausrichtung
|
||||||
|
GridBagConstraints.NONE,
|
||||||
|
new Insets (0,0,0,0), // Abstand zu den anderen Objekten
|
||||||
|
0,0));
|
||||||
|
|
||||||
|
|
||||||
|
GameInterface.getStatusPanel().add(labelPowerUp, new GridBagConstraints( // formPanel ist das Panel, indas eingefügt wird
|
||||||
|
4, 1, // Spaltennr., Zeilennr.
|
||||||
|
4, 2, // Spaltenbreite (gridwidth), Zeilenbreite (gridheigth)
|
||||||
|
0.0, 0.0,
|
||||||
|
GridBagConstraints.NORTH, // Ausrichtung
|
||||||
|
GridBagConstraints.NONE,
|
||||||
|
new Insets (0,0,0,0), // Abstand zu den anderen Objekten
|
||||||
|
0,0));
|
||||||
|
|
||||||
|
|
||||||
|
GameInterface.getStatusPanel().add(powerUpLabel, new GridBagConstraints( // formPanel ist das Panel, indas eingefügt wird
|
||||||
|
4, 2, // Spaltennr., Zeilennr.
|
||||||
|
4, 2, // Spaltenbreite (gridwidth), Zeilenbreite (gridheigth)
|
||||||
|
0.0, 0.0,
|
||||||
|
GridBagConstraints.SOUTH, // Ausrichtung
|
||||||
|
GridBagConstraints.NONE,
|
||||||
|
new Insets (0,0,0,0), // Abstand zu den anderen Objekten
|
||||||
|
0,0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void getStatusPanel(){
|
private static void getStatusPanel(){
|
||||||
GameInterface.getStatusPanel();
|
GameInterface.getStatusPanel();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user