import java.awt.*;
import javax.swing.*;
public class GUI{
public static void main(String[] args) {
JFrame f = new JFrame("酒店介绍界面");
f.setSize(1366,740);
JPanel imagePanel3=new JPanel(new BorderLayout());
Container contentPane=f.getContentPane();
contentPane.setLayout(new GridLayout(3,2));
JLabel j1=new JLabel("酒店的地理位置:",JLabel.CENTER);
JLabel j2=new JLabel("沈阳三环内,时尚三好街上!",JLabel.CENTER);
contentPane.add(j1);
contentPane.add(j2);
imagePanel3.add(contentPane,BorderLayout.CENTER);
JPanel imagePanel1=new JPanel(new BorderLayout());
JPanel imagePanel2=new JPanel(new BorderLayout());
ImageIcon image1=new ImageIcon("图片右.jpg");
ImageIcon image2=new ImageIcon("图片左.jpg");
JLabel imageLabel1=new JLabel();
JLabel imageLabel2=new JLabel();
imageLabel1.setIcon(image1);
imageLabel2.setIcon(image2);
imagePanel1.add(imageLabel1,BorderLayout.EAST);
imagePanel2.add(imageLabel2,BorderLayout.WEST);
JButton south = new JButton("South");
JLabel j=new JLabel("夏黄林王大酒店的介绍",JLabel.CENTER);
j.setFont(new Font("Serif", Font.BOLD, 50));
j.setForeground(Color.BLUE);
j1.setFont(new Font("Serif", Font.BOLD, 20));
j2.setFont(new Font("Serif", Font.BOLD, 20));
south.setFont(new Font("Serif", Font.BOLD, 45));
f.add(j,BorderLayout.NORTH);
f.add("South", south);
f.add(imagePanel1,BorderLayout.EAST);
f.add(imagePanel2,BorderLayout.WEST);
f.add(imagePanel3,BorderLayout.CENTER);
f.setVisible(true);
}
}
------解决方案--------------------
先把一个JPanel设置成GridLayout布局,然后,把另一JPanel设置BorderLayout布局,最后把组件添加上去。