How to code a Menu in Java

Опубликовано: 31 Январь 2024
на канале: Claire Firman
47
3

We code a Menu using a do while loop and a switch case. We go through two example questions together.

Please contact me on firmanclaire@gmail.com for Extra IEB IT lessons.
Here is the code for the second method in Exercise 2:
public static void displayChoc(String in) {
try {
JFrame frame = new JFrame();
File imageFile = new File(in);
Image i = ImageIO.read(imageFile);
ImageIcon image = new ImageIcon(i);
JLabel imageLabel = new JLabel(image);
frame.add(imageLabel);
frame.setLayout(null);
imageLabel.setLocation(0, 0);
imageLabel.setSize(700, 300);
imageLabel.setVisible(true);
frame.setVisible(true);
frame.setSize(700, 300);
JOptionPane.showMessageDialog(null,"Click to continue");
frame.dispose();
} catch (IOException e) {
e.printStackTrace();
}
}

The images can be found here:
https://drive.google.com/drive/folder...


На этой странице сайта вы можете посмотреть видео онлайн How to code a Menu in Java длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Claire Firman 31 Январь 2024, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 47 раз и оно понравилось 3 зрителям. Приятного просмотра!