Modification du style
This commit is contained in:
BIN
TestV2/ressources/images/Icone/ExitIcon.png
Normal file
BIN
TestV2/ressources/images/Icone/ExitIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
TestV2/ressources/images/Icone/ExitIcon2.png
Normal file
BIN
TestV2/ressources/images/Icone/ExitIcon2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
@@ -27,6 +27,9 @@ public class Main {
|
|||||||
* @param args Tableau de String contenant les arguments passé en paramètre au programme
|
* @param args Tableau de String contenant les arguments passé en paramètre au programme
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
// Créer la fenêtre des modes de jeu
|
||||||
|
JFrame gameModeFrame = new JFrame("Choix des modes de jeu - Dorfromantik");
|
||||||
|
|
||||||
// Créer la fenêtre du jeu
|
// Créer la fenêtre du jeu
|
||||||
JFrame gameFrame = new JFrame("Jeu - Dorfromantik");
|
JFrame gameFrame = new JFrame("Jeu - Dorfromantik");
|
||||||
|
|
||||||
@@ -41,7 +44,7 @@ public class Main {
|
|||||||
MusicPlayer.playMusic();
|
MusicPlayer.playMusic();
|
||||||
MainMenu mainMenu = new MainMenu();
|
MainMenu mainMenu = new MainMenu();
|
||||||
MainMenuResizeController MainMenuResizeController = new MainMenuResizeController(mainMenu);
|
MainMenuResizeController MainMenuResizeController = new MainMenuResizeController(mainMenu);
|
||||||
MainMenuButtonController MainMenuButtonController = new MainMenuButtonController(mainMenu,settingsFrame,howToPlayFrame,gameFrame);
|
MainMenuButtonController MainMenuButtonController = new MainMenuButtonController(mainMenu,settingsFrame,howToPlayFrame,gameModeFrame);
|
||||||
|
|
||||||
|
|
||||||
// Fenêtre des paramètres
|
// Fenêtre des paramètres
|
||||||
@@ -52,14 +55,16 @@ public class Main {
|
|||||||
|
|
||||||
// Fenêtre du tutoriel
|
// Fenêtre du tutoriel
|
||||||
CloseWindowListener howToPlayWindowListener = new CloseWindowListener(mainMenu, howToPlayFrame);
|
CloseWindowListener howToPlayWindowListener = new CloseWindowListener(mainMenu, howToPlayFrame);
|
||||||
TutorialController tutorialController = new TutorialController();
|
TutorialController tutorialController = new TutorialController(mainMenu, howToPlayFrame);
|
||||||
howToPlayFrame.addWindowListener(howToPlayWindowListener);
|
howToPlayFrame.addWindowListener(howToPlayWindowListener);
|
||||||
howToPlayFrame.add(tutorialController.getTutorialPanel());
|
howToPlayFrame.add(tutorialController.getTutorialPanel());
|
||||||
|
|
||||||
// Fenêtre du choix des modes de jeu
|
// Fenêtre du choix des modes de jeu
|
||||||
|
CloseWindowListener gameModeWindowListener = new CloseWindowListener(mainMenu, gameModeFrame);
|
||||||
GameModeController gameModeController = new GameModeController();
|
GameModeController gameModeController = new GameModeController();
|
||||||
GameModeSelectionPanel gameModeSelectionPanel = new GameModeSelectionPanel(gameModeController);
|
GameModeSelectionPanel gameModeSelectionPanel = new GameModeSelectionPanel(gameModeController);
|
||||||
|
gameModeFrame.addWindowListener(gameModeWindowListener);
|
||||||
gameModeController.setGameModeSelectionPanel(gameModeSelectionPanel);
|
gameModeController.setGameModeSelectionPanel(gameModeSelectionPanel);
|
||||||
gameFrame.add(gameModeSelectionPanel);
|
gameModeFrame.add(gameModeSelectionPanel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ package fr.monkhanny.dorfromantik.controller;
|
|||||||
import fr.monkhanny.dorfromantik.gui.TutorialPanel;
|
import fr.monkhanny.dorfromantik.gui.TutorialPanel;
|
||||||
import fr.monkhanny.dorfromantik.gui.Step;
|
import fr.monkhanny.dorfromantik.gui.Step;
|
||||||
import fr.monkhanny.dorfromantik.enums.Images;
|
import fr.monkhanny.dorfromantik.enums.Images;
|
||||||
|
import fr.monkhanny.dorfromantik.gui.MainMenu;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -11,14 +12,20 @@ import java.util.List;
|
|||||||
public class TutorialController {
|
public class TutorialController {
|
||||||
private TutorialPanel tutorialPanel;
|
private TutorialPanel tutorialPanel;
|
||||||
|
|
||||||
public TutorialController() {
|
private MainMenu mainMenu;
|
||||||
|
private JFrame tutorialFrame;
|
||||||
|
|
||||||
|
public TutorialController(MainMenu mainMenu, JFrame tutorialFrame) {
|
||||||
|
this.mainMenu = mainMenu;
|
||||||
|
this.tutorialFrame = tutorialFrame;
|
||||||
|
|
||||||
List<Step> steps = new ArrayList<>();
|
List<Step> steps = new ArrayList<>();
|
||||||
steps.add(new Step("Étape n°1", "Explication de la première étape ici.", Images.TUTORIAL_GIF1.getImagePath()));
|
steps.add(new Step("Étape n°1", "Explication de la première étape ici.", Images.TUTORIAL_GIF1.getImagePath()));
|
||||||
steps.add(new Step("Étape n°2", "Explication de la deuxième étape ici.", Images.TUTORIAL_GIF2.getImagePath()));
|
steps.add(new Step("Étape n°2", "Explication de la deuxième étape ici.", Images.TUTORIAL_GIF2.getImagePath()));
|
||||||
steps.add(new Step("Étape n°3", "Explication de la troisième étape ici.", Images.TUTORIAL_GIF3.getImagePath()));
|
steps.add(new Step("Étape n°3", "Explication de la troisième étape ici.", Images.TUTORIAL_GIF3.getImagePath()));
|
||||||
steps.add(new Step("Étape n°4", "Explication de la quatrième étape ici.", Images.TUTORIAL_GIF4.getImagePath()));
|
steps.add(new Step("Étape n°4", "Explication de la quatrième étape ici.", Images.TUTORIAL_GIF4.getImagePath()));
|
||||||
|
|
||||||
tutorialPanel = new TutorialPanel(steps);
|
tutorialPanel = new TutorialPanel(steps, mainMenu, tutorialFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel getTutorialPanel() {
|
public JPanel getTutorialPanel() {
|
||||||
|
@@ -4,6 +4,7 @@ import fr.monkhanny.dorfromantik.Options;
|
|||||||
import fr.monkhanny.dorfromantik.components.Title;
|
import fr.monkhanny.dorfromantik.components.Title;
|
||||||
import fr.monkhanny.dorfromantik.listeners.*;
|
import fr.monkhanny.dorfromantik.listeners.*;
|
||||||
import fr.monkhanny.dorfromantik.utils.MusicPlayer;
|
import fr.monkhanny.dorfromantik.utils.MusicPlayer;
|
||||||
|
import fr.monkhanny.dorfromantik.enums.Images;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -18,9 +19,11 @@ public class SettingsPanel extends JPanel {
|
|||||||
this.mainMenu = mainMenu;
|
this.mainMenu = mainMenu;
|
||||||
this.settingsFrame = settingsFrame;
|
this.settingsFrame = settingsFrame;
|
||||||
|
|
||||||
|
setLayout(new BorderLayout());
|
||||||
initializeSettingsFrame();
|
initializeSettingsFrame();
|
||||||
setupBackground();
|
setupBackground();
|
||||||
setupMainPanel();
|
setupTopPanel(); // Nouveau panneau pour le titre et le bouton de retour
|
||||||
|
setupMainPanel(); // Configuration du panneau principal pour les sliders et boutons
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeSettingsFrame() {
|
private void initializeSettingsFrame() {
|
||||||
@@ -30,56 +33,47 @@ public class SettingsPanel extends JPanel {
|
|||||||
private void setupBackground() {
|
private void setupBackground() {
|
||||||
JLabel background = new JLabel(new ImageIcon("./ressources/images/MainMenu/backgroundBlured.jpg"));
|
JLabel background = new JLabel(new ImageIcon("./ressources/images/MainMenu/backgroundBlured.jpg"));
|
||||||
background.setLayout(new GridBagLayout());
|
background.setLayout(new GridBagLayout());
|
||||||
this.setLayout(new BorderLayout());
|
this.add(background, BorderLayout.CENTER); // Déplacer l'ajout du fond au centre
|
||||||
this.add(background);
|
}
|
||||||
|
|
||||||
|
private void setupTopPanel() {
|
||||||
|
JPanel topPanel = new JPanel(new BorderLayout());
|
||||||
|
topPanel.setOpaque(false);
|
||||||
|
|
||||||
|
Title title = new Title("Paramètres", 70, Color.WHITE);
|
||||||
|
title.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
topPanel.add(title, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
JButton returnButton = createReturnButtonWithIcon();
|
||||||
|
JPanel leftPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
|
leftPanel.setOpaque(false);
|
||||||
|
leftPanel.add(returnButton);
|
||||||
|
topPanel.add(leftPanel, BorderLayout.WEST);
|
||||||
|
|
||||||
|
this.add(topPanel, BorderLayout.NORTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
super.paintComponent(g);
|
||||||
|
ImageIcon backgroundImage = new ImageIcon("./ressources/images/MainMenu/backgroundBlured.jpg");
|
||||||
|
g.drawImage(backgroundImage.getImage(), 0, 0, getWidth(), getHeight(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupMainPanel() {
|
private void setupMainPanel() {
|
||||||
JPanel mainPanel = createMainPanel();
|
|
||||||
JLabel title = createTitle();
|
|
||||||
|
|
||||||
mainPanel.add(title, createGridBagConstraints(0, 0, 2));
|
|
||||||
mainPanel.add(Box.createVerticalStrut(30), createGridBagConstraints(0, 1, 1));
|
|
||||||
|
|
||||||
// Musique Panel
|
|
||||||
JSlider musicSlider = new JSlider(0, 100, Options.MUSIC_MUTED ? 0 : Options.MUSIC_VOLUME);
|
|
||||||
JPanel musicPanel = createSoundPanel("Musique", musicSlider, new MusicVolumeChangeListener(musicSlider), new MuteCheckBoxListener("Musique"));
|
|
||||||
mainPanel.add(musicPanel, createGridBagConstraints(0, 2, 1));
|
|
||||||
|
|
||||||
mainPanel.add(Box.createVerticalStrut(30), createGridBagConstraints(0, 3, 1));
|
|
||||||
|
|
||||||
// SFX Panel
|
|
||||||
JSlider sfxSlider = new JSlider(0, 100, Options.SOUNDS_MUTED ? 0 : Options.SOUNDS_VOLUME);
|
|
||||||
JPanel sfxPanel = createSoundPanel("SFX", sfxSlider, new SoundsVolumeChangeListener(sfxSlider), new MuteCheckBoxListener("SFX"));
|
|
||||||
mainPanel.add(sfxPanel, createGridBagConstraints(0, 4, 1));
|
|
||||||
|
|
||||||
// Close Button
|
|
||||||
JButton closeButton = createCloseButton();
|
|
||||||
mainPanel.add(closeButton, createGridBagConstraints(0, 5, 1));
|
|
||||||
|
|
||||||
// Add to background
|
|
||||||
((JLabel) this.getComponent(0)).add(mainPanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel createMainPanel() {
|
|
||||||
JPanel mainPanel = new JPanel(new GridBagLayout());
|
JPanel mainPanel = new JPanel(new GridBagLayout());
|
||||||
mainPanel.setOpaque(false);
|
mainPanel.setOpaque(false);
|
||||||
return mainPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Title createTitle() {
|
JSlider musicSlider = new JSlider(0, 100, Options.MUSIC_MUTED ? 0 : Options.MUSIC_VOLUME);
|
||||||
Title title = new Title("Paramètres", 70, Color.WHITE);
|
JPanel musicPanel = createSoundPanel("Musique", musicSlider, new MusicVolumeChangeListener(musicSlider), new MuteCheckBoxListener("Musique"));
|
||||||
return title;
|
mainPanel.add(musicPanel, createGridBagConstraints(0, 0, 1));
|
||||||
}
|
|
||||||
|
|
||||||
private GridBagConstraints createGridBagConstraints(int x, int y, int gridWidth) {
|
JSlider sfxSlider = new JSlider(0, 100, Options.SOUNDS_MUTED ? 0 : Options.SOUNDS_VOLUME);
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
JPanel sfxPanel = createSoundPanel("SFX", sfxSlider, new SoundsVolumeChangeListener(sfxSlider), new MuteCheckBoxListener("SFX"));
|
||||||
gbc.gridx = x;
|
mainPanel.add(sfxPanel, createGridBagConstraints(0, 1, 1));
|
||||||
gbc.gridy = y;
|
|
||||||
gbc.gridwidth = gridWidth;
|
mainPanel.add(Box.createVerticalStrut(30), createGridBagConstraints(0, 2, 1));
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
this.add(mainPanel, BorderLayout.CENTER);
|
||||||
gbc.insets = new Insets(20, 30, 20, 30);
|
|
||||||
return gbc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel createSoundPanel(String labelText, JSlider volumeSlider, ChangeListener sliderChangeListener, MuteCheckBoxListener muteCheckBoxListener) {
|
private JPanel createSoundPanel(String labelText, JSlider volumeSlider, ChangeListener sliderChangeListener, MuteCheckBoxListener muteCheckBoxListener) {
|
||||||
@@ -128,15 +122,31 @@ public class SettingsPanel extends JPanel {
|
|||||||
return sliderPanel;
|
return sliderPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JButton createCloseButton() {
|
private GridBagConstraints createGridBagConstraints(int x, int y, int gridWidth) {
|
||||||
JButton closeButton = new JButton("Retour");
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
closeButton.setFont(new Font("Roboto", Font.BOLD, 24));
|
gbc.gridx = x;
|
||||||
closeButton.setForeground(Color.BLACK);
|
gbc.gridy = y;
|
||||||
closeButton.setBackground(Color.WHITE);
|
gbc.gridwidth = gridWidth;
|
||||||
closeButton.setOpaque(true);
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
closeButton.setPreferredSize(new Dimension(75, 50));
|
gbc.insets = new Insets(20, 30, 20, 30);
|
||||||
closeButton.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
return gbc;
|
||||||
closeButton.addActionListener(new CloseButtonListener(mainMenu, settingsFrame));
|
}
|
||||||
return closeButton;
|
|
||||||
|
|
||||||
|
private JButton createReturnButtonWithIcon() {
|
||||||
|
ImageIcon originalIcon = new ImageIcon(Images.EXIT_ICON.getImagePath());
|
||||||
|
|
||||||
|
// Redimensionner l'image à la taille du bouton
|
||||||
|
Image scaledImage = originalIcon.getImage().getScaledInstance(50, 50, Image.SCALE_SMOOTH);
|
||||||
|
ImageIcon resizedIcon = new ImageIcon(scaledImage);
|
||||||
|
|
||||||
|
JButton returnButton = new JButton(resizedIcon);
|
||||||
|
returnButton.setPreferredSize(new Dimension(50, 50)); // Ajuster la taille du bouton selon l'icône
|
||||||
|
returnButton.setContentAreaFilled(false); // Bouton transparent
|
||||||
|
returnButton.setBorderPainted(false); // Pas de bordure
|
||||||
|
returnButton.setFocusPainted(false); // Pas de focus
|
||||||
|
returnButton.addActionListener(new CloseButtonListener(mainMenu, settingsFrame));
|
||||||
|
|
||||||
|
return returnButton;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,9 @@ package fr.monkhanny.dorfromantik.gui;
|
|||||||
|
|
||||||
import fr.monkhanny.dorfromantik.components.Title;
|
import fr.monkhanny.dorfromantik.components.Title;
|
||||||
import fr.monkhanny.dorfromantik.gui.Step;
|
import fr.monkhanny.dorfromantik.gui.Step;
|
||||||
|
import fr.monkhanny.dorfromantik.listeners.CloseButtonListener;
|
||||||
|
import fr.monkhanny.dorfromantik.gui.MainMenu;
|
||||||
|
import fr.monkhanny.dorfromantik.enums.Images;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -11,16 +14,19 @@ public class TutorialPanel extends JPanel {
|
|||||||
|
|
||||||
private List<Step> steps;
|
private List<Step> steps;
|
||||||
private int currentStepIndex;
|
private int currentStepIndex;
|
||||||
|
|
||||||
private Title title;
|
private Title title;
|
||||||
private JLabel stepText;
|
private JLabel stepText;
|
||||||
private JLabel stepImage;
|
private JLabel stepImage;
|
||||||
private JButton nextButton;
|
private JButton nextButton;
|
||||||
private JButton prevButton;
|
private JButton prevButton;
|
||||||
|
private MainMenu mainMenu;
|
||||||
|
private JFrame tutorialFrame;
|
||||||
|
|
||||||
public TutorialPanel(List<Step> steps) {
|
public TutorialPanel(List<Step> steps, MainMenu mainMenu, JFrame tutorialFrame) {
|
||||||
this.steps = steps;
|
this.steps = steps;
|
||||||
this.currentStepIndex = 0;
|
this.currentStepIndex = 0;
|
||||||
|
this.mainMenu = mainMenu;
|
||||||
|
this.tutorialFrame = tutorialFrame;
|
||||||
|
|
||||||
// Utiliser BorderLayout pour la disposition principale
|
// Utiliser BorderLayout pour la disposition principale
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
@@ -29,12 +35,25 @@ public class TutorialPanel extends JPanel {
|
|||||||
title = new Title("Comment jouer ?", 70f, Color.WHITE);
|
title = new Title("Comment jouer ?", 70f, Color.WHITE);
|
||||||
title.setHorizontalAlignment(JLabel.CENTER);
|
title.setHorizontalAlignment(JLabel.CENTER);
|
||||||
title.setOpaque(false);
|
title.setOpaque(false);
|
||||||
add(title, BorderLayout.NORTH);
|
|
||||||
|
// Panneau contenant le titre et le bouton de retour
|
||||||
|
JPanel northPanel = new JPanel(new BorderLayout());
|
||||||
|
northPanel.setOpaque(false);
|
||||||
|
northPanel.add(title, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
// Ajouter l'icône de retour à droite du panneau nord
|
||||||
|
JButton returnButton = createReturnButtonWithIcon();
|
||||||
|
JPanel topRightPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||||
|
topRightPanel.setOpaque(false);
|
||||||
|
topRightPanel.add(returnButton);
|
||||||
|
northPanel.add(topRightPanel, BorderLayout.WEST);
|
||||||
|
|
||||||
|
add(northPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
// Conteneur principal pour les étapes, centré
|
// Conteneur principal pour les étapes, centré
|
||||||
JPanel centerPanel = new JPanel();
|
JPanel centerPanel = new JPanel();
|
||||||
centerPanel.setLayout(new GridBagLayout());
|
centerPanel.setLayout(new GridBagLayout());
|
||||||
centerPanel.setOpaque(false); // Rendre le conteneur transparent
|
centerPanel.setOpaque(false); // Rendre le conteneur transparent
|
||||||
|
|
||||||
// Utiliser GridBagConstraints pour centrer le contenu verticalement
|
// Utiliser GridBagConstraints pour centrer le contenu verticalement
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
@@ -46,19 +65,19 @@ public class TutorialPanel extends JPanel {
|
|||||||
// Conteneur pour le texte et l'image
|
// Conteneur pour le texte et l'image
|
||||||
JPanel stepContainer = new JPanel();
|
JPanel stepContainer = new JPanel();
|
||||||
stepContainer.setLayout(new BoxLayout(stepContainer, BoxLayout.Y_AXIS));
|
stepContainer.setLayout(new BoxLayout(stepContainer, BoxLayout.Y_AXIS));
|
||||||
stepContainer.setOpaque(false); // Transparent
|
stepContainer.setOpaque(false); // Transparent
|
||||||
|
|
||||||
stepText = new JLabel();
|
stepText = new JLabel();
|
||||||
stepText.setFont(new Font("Arial", Font.BOLD, 28));
|
stepText.setFont(new Font("Arial", Font.BOLD, 28));
|
||||||
stepText.setForeground(Color.WHITE);
|
stepText.setForeground(Color.WHITE);
|
||||||
stepText.setAlignmentX(Component.CENTER_ALIGNMENT); // Centrer le texte horizontalement
|
stepText.setAlignmentX(Component.CENTER_ALIGNMENT); // Centrer le texte horizontalement
|
||||||
|
|
||||||
stepImage = new JLabel();
|
stepImage = new JLabel();
|
||||||
stepImage.setAlignmentX(Component.CENTER_ALIGNMENT); // Centrer l'image horizontalement
|
stepImage.setAlignmentX(Component.CENTER_ALIGNMENT); // Centrer l'image horizontalement
|
||||||
|
|
||||||
// Ajouter les composants au conteneur d'étapes
|
// Ajouter les composants au conteneur d'étapes
|
||||||
stepContainer.add(stepText);
|
stepContainer.add(stepText);
|
||||||
stepContainer.add(Box.createVerticalStrut(10)); // Espace entre texte et image
|
stepContainer.add(Box.createVerticalStrut(10)); // Espace entre texte et image
|
||||||
stepContainer.add(stepImage);
|
stepContainer.add(stepImage);
|
||||||
|
|
||||||
// Ajouter le conteneur d'étapes au centre du panel
|
// Ajouter le conteneur d'étapes au centre du panel
|
||||||
@@ -67,13 +86,19 @@ public class TutorialPanel extends JPanel {
|
|||||||
|
|
||||||
// Panneau pour les boutons de navigation
|
// Panneau pour les boutons de navigation
|
||||||
JPanel buttonPanel = new JPanel();
|
JPanel buttonPanel = new JPanel();
|
||||||
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); // Centrer les boutons
|
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); // Centrer les boutons
|
||||||
buttonPanel.setOpaque(false); // Transparent
|
buttonPanel.setOpaque(false); // Transparent
|
||||||
|
|
||||||
prevButton = new JButton("Précédent");
|
prevButton = new JButton("Précédent");
|
||||||
nextButton = new JButton("Suivant");
|
nextButton = new JButton("Suivant");
|
||||||
|
|
||||||
|
// Personnalisation des boutons
|
||||||
|
styleButton(prevButton);
|
||||||
|
styleButton(nextButton);
|
||||||
|
|
||||||
prevButton.addActionListener(e -> showPreviousStep());
|
prevButton.addActionListener(e -> showPreviousStep());
|
||||||
nextButton.addActionListener(e -> showNextStep());
|
nextButton.addActionListener(e -> showNextStep());
|
||||||
|
|
||||||
buttonPanel.add(prevButton);
|
buttonPanel.add(prevButton);
|
||||||
buttonPanel.add(nextButton);
|
buttonPanel.add(nextButton);
|
||||||
|
|
||||||
@@ -86,12 +111,12 @@ public class TutorialPanel extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g); // Appel à super pour s'assurer que le panneau est dessiné
|
super.paintComponent(g); // Appel à super pour s'assurer que le panneau est dessiné
|
||||||
|
|
||||||
// Dessin de l'image de fond pour couvrir tout le panneau
|
// Dessin de l'image de fond pour couvrir tout le panneau
|
||||||
ImageIcon backgroundImage = new ImageIcon("./ressources/images/MainMenu/backgroundBlured.jpg");
|
ImageIcon backgroundImage = new ImageIcon("./ressources/images/MainMenu/backgroundBlured.jpg");
|
||||||
Image image = backgroundImage.getImage();
|
Image image = backgroundImage.getImage();
|
||||||
g.drawImage(image, 0, 0, getWidth(), getHeight(), this); // Dessiner l'image pour couvrir tout le panneau
|
g.drawImage(image, 0, 0, getWidth(), getHeight(), this); // Dessiner l'image pour couvrir tout le panneau
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStepDisplay() {
|
private void updateStepDisplay() {
|
||||||
@@ -104,6 +129,32 @@ public class TutorialPanel extends JPanel {
|
|||||||
nextButton.setEnabled(currentStepIndex < steps.size() - 1);
|
nextButton.setEnabled(currentStepIndex < steps.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void styleButton(JButton button) {
|
||||||
|
// Police et taille
|
||||||
|
button.setFont(new Font("Arial", Font.BOLD, 18));
|
||||||
|
button.setForeground(Color.WHITE);
|
||||||
|
|
||||||
|
// Taille et forme des boutons
|
||||||
|
button.setPreferredSize(new Dimension(150, 50)); // Ajuster la taille des boutons
|
||||||
|
button.setBackground(new Color(34, 34, 34)); // Couleur de fond sombre
|
||||||
|
button.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); // Bordure blanche
|
||||||
|
|
||||||
|
// Effet au survol
|
||||||
|
button.setRolloverEnabled(true);
|
||||||
|
button.setContentAreaFilled(true);
|
||||||
|
button.setFocusPainted(false); // Pas de focus visible
|
||||||
|
|
||||||
|
// Ajout de l'effet de survol
|
||||||
|
button.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||||
|
public void mouseEntered(java.awt.event.MouseEvent evt) {
|
||||||
|
button.setBackground(new Color(60, 60, 60)); // Couleur plus claire au survol
|
||||||
|
}
|
||||||
|
public void mouseExited(java.awt.event.MouseEvent evt) {
|
||||||
|
button.setBackground(new Color(34, 34, 34)); // Retour à la couleur originale
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void showPreviousStep() {
|
private void showPreviousStep() {
|
||||||
if (currentStepIndex > 0) {
|
if (currentStepIndex > 0) {
|
||||||
currentStepIndex--;
|
currentStepIndex--;
|
||||||
@@ -117,4 +168,21 @@ public class TutorialPanel extends JPanel {
|
|||||||
updateStepDisplay();
|
updateStepDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JButton createReturnButtonWithIcon() {
|
||||||
|
ImageIcon originalIcon = new ImageIcon(Images.EXIT_ICON.getImagePath());
|
||||||
|
|
||||||
|
// Redimensionnement de l'image à la taille du bouton
|
||||||
|
Image scaledImage = originalIcon.getImage().getScaledInstance(50, 50, Image.SCALE_SMOOTH);
|
||||||
|
ImageIcon resizedIcon = new ImageIcon(scaledImage);
|
||||||
|
|
||||||
|
JButton returnButton = new JButton(resizedIcon);
|
||||||
|
returnButton.setPreferredSize(new Dimension(50, 50)); // Ajuste la taille du bouton selon l'icône
|
||||||
|
returnButton.setContentAreaFilled(false); // Bouton transparent
|
||||||
|
returnButton.setBorderPainted(false); // Pas de bordure
|
||||||
|
returnButton.setFocusPainted(false); // Pas de focus
|
||||||
|
returnButton.addActionListener(new CloseButtonListener(mainMenu, tutorialFrame));
|
||||||
|
|
||||||
|
return returnButton;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user