【发布时间】:2015-08-30 01:19:11
【问题描述】:
如何在 JScrollPane 中添加图像作为背景? 我试过了,但图像不显示:
BufferedImage img = null;
try {
img = ImageIO.read(new File("C:\\Users\\Suraj\\Documents\\NetBeansProjects\\JavaApplication2\\src\\javaapplication2\\images\\2.jpg"));
}
catch (IOException e) {
e.printStackTrace();
}
Image imag = img.getScaledInstance(d.width, d.height, Image.SCALE_SMOOTH);
ImageIcon imageBack = new ImageIcon(imag);
FlowLayout fl = new FlowLayout();
frame.getContentPane().setLayout(fl);
fl.addLayoutComponent(null, new JLabel(imageBack));
编辑:我想在带有背景的 JScrollPane 上添加 jlabels 和 jbuttons
【问题讨论】:
标签: java image swing background jscrollpane