菜單你好eveybody我創造了這個代碼:打開從按鈕
package project1;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.awt.image.ImageProducer;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
public class ccc {
public static void main(String[] args){
JFrame frame = new JFrame("Food delivery"); // Create a frame
frame.setSize(1600, 1400); // Set the frame size
frame.setLocationRelativeTo(null); // New since JDK 1.4
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true); // Display the frame
JPanel panel = new JPanel(new FlowLayout());
JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
ImageIcon icon = new ImageIcon("hamburger.jpg");
frame.setIconImage(icon.getImage());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new GridBagLayout());
try {
frame.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("fd12.jpg")))));
} catch (IOException e) {
e.printStackTrace();
}
frame.setLayout(new FlowLayout(FlowLayout.LEFT));
JLabel label = new JLabel("Welcome to Food Delivery");
label.setFont(new Font("Courier New", Font.BOLD, 38));
label.setForeground(Color.black);
System.out.println("");
JButton btn1= new JButton("Breakfast");
btn1.setFont(new Font("Courier New", Font.BOLD, 16));
btn1.setForeground(Color.BLACK);
JButton btn2= new JButton("Starters");
btn2.setFont(new Font("Courier New", Font.BOLD, 16));
btn2.setForeground(Color.BLACK);
JButton btn3= new JButton("Main Dishes");
btn3.setFont(new Font("Courier New", Font.BOLD, 16));
btn3.setForeground(Color.BLACK);
JButton btn4= new JButton("Deserts");
btn4.setFont(new Font("Courier New", Font.BOLD, 16));
btn4.setForeground(Color.BLACK);
JButton btn5= new JButton("Drinks");
btn5.setFont(new Font("Courier New", Font.BOLD, 16));
btn5.setForeground(Color.BLACK);
frame.add(label);
frame.add(new JSeparator());
frame.add(btn1);
frame.add(btn2);
frame.add(btn3);
frame.add(btn4);
frame.add(btn5);
frame.pack();
frame.setVisible(true);
}}
屏幕截圖: enter image description here
我很想得到得到打開的頁面中的新頁面對於每個按鈕和裏面我會寫的食物菜單選擇和附近它有價格寫?請幫助我,我不能這樣做的一切,就可以知道如何...
感謝
像[Card Layout](https://docs.oracle.com/javase/tutorial/uiswing/layout/card.html)這樣的風格是需要檢查的東西嗎? – Emz