Ãcréation d'une vue tetris avec bouton paue, score et affichage de la prochaine piece

This commit is contained in:
ROGER
2025-05-13 14:30:34 +02:00
parent 63d5db5d6a
commit f9e3f1d2bb
4 changed files with 96 additions and 13 deletions

View 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;
}
}