package view; import javax.swing.*; import java.awt.*; import model.*; /** * Petite fenêtre qui affiche les informations d'une voiture : * - carburant restant * - nombre de tours * - état (mode de conduite) * et un bouton Pause/Reprendre. */ public class FenetreTableau extends JFrame { private final Car voiture; private final JLabel lblCarburant, lblTours, lblEtat; private final JButton boutonPause; public FenetreTableau(Car voiture, FenetreJeu parent) { this.voiture = voiture; setTitle("Tableau de bord - Voiture"); setLayout(new GridLayout(4, 1)); getContentPane().setBackground(Color.LIGHT_GRAY); lblCarburant = new JLabel("Carburant : " + voiture.getFuel(), SwingConstants.CENTER); lblTours = new JLabel("Tours : " + voiture.getRound(), SwingConstants.CENTER); lblEtat = new JLabel("État : " + voiture.getState().get(), SwingConstants.CENTER); boutonPause = new JButton("⏸️ Pause / ▶️ Reprendre"); boutonPause.addActionListener(e -> { if (parent.getActionPause() != null) parent.getActionPause().run(); }); add(lblCarburant); add(lblTours); add(lblEtat); add(boutonPause); setSize(250, 180); setLocationByPlatform(true); setVisible(true); } /** Met à jour les infos affichées */ public void rafraichir() { lblCarburant.setText("Carburant : " + voiture.getFuel()); lblTours.setText("Tours : " + voiture.getRound()); lblEtat.setText("État : " + voiture.getState().get()); } }