panel display intro

This commit is contained in:
martinbst 2025-05-07 21:21:18 +02:00
parent 31571fcd99
commit a253732423
2 changed files with 38 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

View File

@ -28,9 +28,12 @@ import java.awt.event.ActionEvent;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.AbstractListModel; import javax.swing.AbstractListModel;
import javax.swing.ImageIcon;
import javax.swing.JToggleButton; import javax.swing.JToggleButton;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.*;
import java.awt.*;
public class MyInterface extends JFrame { public class MyInterface extends JFrame {
@ -161,14 +164,15 @@ public class MyInterface extends JFrame {
} }
} }
public void clicButtonStart() { public void clicButtonStart() {
this.instantiateSimu(); this.instantiateSimu();
int introduction = introduction();
int depth = askDifficulty(); int depth = askDifficulty();
int time=askTime(); int time=askTime();
game.setAutoPlayerDepth(depth); game.setAutoPlayerDepth(depth);
game.setDefaultSetup(); game.setDefaultSetup();
} }
public void clickButtonAdder() { public void clickButtonAdder() {
panelDraw.toggleAdderMode(); panelDraw.toggleAdderMode();
} }
@ -326,4 +330,37 @@ public class MyInterface extends JFrame {
default: return 4; // 10 min default: return 4; // 10 min
} }
} }
private int introduction() {
int boardWidth = 600;
int boardHeight = 600;
String imagePath = "image_OOP.png"; // replace with your actual image path
ImageIcon originalIcon = new ImageIcon(imagePath);
// Check if the image was loaded successfully
if (originalIcon.getImageLoadStatus() != MediaTracker.COMPLETE) {
JOptionPane.showMessageDialog(this, "Error loading image: " + imagePath, "Image Error", JOptionPane.ERROR_MESSAGE);
return 0; // Return or handle the error as needed
}
Image originalImage = originalIcon.getImage();
Image resizedImage = originalImage.getScaledInstance(boardWidth, boardHeight, Image.SCALE_SMOOTH);
ImageIcon resizedIcon = new ImageIcon(resizedImage);
Object[] options = {"Start"};
int choice = JOptionPane.showOptionDialog(
this,
" ",
" ",
JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE,
resizedIcon,
options,
options[0]
);
return 1;
}
} }