0
我有一个扩展JFrame的类,它包含3个面板+另一个将布局中的所有3个面板放在一起。将图像文件设置为背景
panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add("North", panel2); //row of buttons
panel.add("Center",grid); // grid of buttons
panel.add("South",panel3); // a textfield that stretches across the total width of the frame
add(panel);
JLabel background = new JLabel (new ImageIcon ("C:\\.png"));
background.setBounds (0,0,500,550);
add(background);
//the background for the frame
setVisible (true);
setResizable (false);
setBounds (398,70, 570, 620);
setDefaultCloseOperation (EXIT_ON_CLOSE);
我的问题是程序让我在的JLabel与背景图像/影像的输出才可见或以某种方式掩盖了面板/使按钮不可见。我需要背景图像在按钮后面,我的意思是这就是为什么它被称为背景我错过了什么?
-
因为嗯,这不是马上就会设置为一个小程序的任何时间,我没有使用的容器
- IDK的,如果这个原因就足够了,但耶
虽然我没有使用容器? – user3026693
JPanel是一个容器,JFrame是一个容器,JLabel是容器... – MadProgrammer
从编辑到问题*“我没有使用容器,因为它不会被设置为applet ..”*? !?你似乎认为一个'容器'与它实际上是完全不同的东西。无可否认,['Applet'](http://docs.oracle.com/javase/7/docs/api/java/applet/Applet.html)确实继承了['Container'](http:// docs。 oracle.com/javase/7/docs/api/java/awt/Container.html),但是几乎所有在屏幕上出现在Java GUI中的其他东西(无论是嵌入式applet还是自由浮动框架)。 –