68 lines
2.1 KiB
Java
68 lines
2.1 KiB
Java
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);
|
|
initierNextPiecePanel();
|
|
|
|
//PAUSE BUTTON
|
|
pauseButton = new JButton("Pause / Play");
|
|
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;
|
|
}
|
|
|
|
private void initierNextPiecePanel() {
|
|
nextPiecePanel.removeAll();
|
|
nextPiecePanel.setLayout(new GridLayout(4, 4));
|
|
for (int i = 0; i < 16; i++) {
|
|
JPanel caseG = new JPanel();
|
|
caseG.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
|
caseG.setBackground(Color.WHITE);
|
|
nextPiecePanel.add(caseG);
|
|
}
|
|
nextPiecePanel.revalidate();
|
|
nextPiecePanel.repaint();
|
|
}
|
|
} |