Ãcréation d'une vue tetris avec bouton paue, score et affichage de la prochaine piece
This commit is contained in:
54
app/src/main/java/org/Views/VueControle.java
Normal file
54
app/src/main/java/org/Views/VueControle.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package org.Views;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class VueControle extends JPanel {
|
||||
private JLabel scoreLabel;
|
||||
private JPanel nextPiecePanel;
|
||||
private JButton pauseButton;
|
||||
|
||||
public VueControle() {
|
||||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||
setBackground(Color.gray);
|
||||
setPreferredSize(new Dimension(200, 600));
|
||||
|
||||
//SCORE
|
||||
scoreLabel = new JLabel("Score: 0");
|
||||
scoreLabel.setForeground(Color.white);
|
||||
scoreLabel.setFont(new Font("Arial", Font.PLAIN, 16));
|
||||
scoreLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
|
||||
//NEXT PIECE
|
||||
nextPiecePanel = new JPanel();
|
||||
nextPiecePanel.setPreferredSize(new Dimension(100, 100));
|
||||
nextPiecePanel.setMaximumSize(new Dimension(100, 100));
|
||||
nextPiecePanel.setBackground(Color.LIGHT_GRAY);
|
||||
nextPiecePanel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
|
||||
//PAUSE BUTTON
|
||||
pauseButton = new JButton("Pause");
|
||||
pauseButton.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
|
||||
add(Box.createVerticalStrut(20)); // Add some space at the top
|
||||
add(scoreLabel);
|
||||
add(Box.createVerticalStrut(20)); // Add some space between score and next piece
|
||||
add(nextPiecePanel);
|
||||
add(Box.createVerticalStrut(20)); // Add some space between next piece and button
|
||||
add(pauseButton);
|
||||
|
||||
//setVisible(true);
|
||||
}
|
||||
|
||||
public void setScore(int score) {
|
||||
scoreLabel.setText("Score: " + score);
|
||||
}
|
||||
|
||||
public JButton getPauseButton() {
|
||||
return pauseButton;
|
||||
}
|
||||
|
||||
public JPanel getNextPiecePanel() {
|
||||
return nextPiecePanel;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user