0
如何将我的“images/name.jpg”添加到ContentPane窗口容器中?将图像添加到窗口应用程序的内容窗格中
public class WindowName extends JFrame
{
public WindowName()
{
JFrame Window = new JFrame();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("...");
setSize(700, 600);
setVisible(true);
Container powZawartosci = getContentPane();
powZawartosci.setLayout(null);
}
}
你想让图像成为背景吗? BTW 1)`setSize(700,600);`不要那样做,而是设置孩子的首选大小并打包框架。 2)`powZawartosci.setLayout(null);`a)在主要以英文进行的网站上发布的例子中使用英语。 b)**使用布局** – 2011-12-14 00:21:34