我不知道如何去制作一个图片库像这样的:平铺图像库中的Java
所有我需要的是让它在一个5x5的方形像上面有显示图像点击事件(我知道如何做ActionEvents)
我试着制作一个GridLayout
与构造函数5, 5
,然后添加图像与panel.add(image, 0, 0);
等,但无济于事。下面是代码:
imagelayout = new GridLayout(5, 5, 5, 5);
imagepanel = new JPanel(imagelayout);
JLabel image = new JLabel(LogoManager.getInstance().getLogo("Apple"));
JLabel image1 = new JLabel(LogoManager.getInstance().getLogo("McDonalds"));
JLabel image2 = new JLabel(LogoManager.getInstance().getLogo("Fox"));
JLabel image3 = new JLabel(LogoManager.getInstance().getLogo("Microsoft"));
imagepanel.add(image, 0, 0);
imagepanel.add(image1, 1, 0);
imagepanel.add(image2, 1, 1);
imagepanel.add(image3, 2, 0);
而这就是我得到:
谢谢你们!
错字,这是一个网格布局;) – nrubin29 2013-05-05 22:10:56
那么究竟什么是你找谁? – user2277872 2013-05-05 22:12:08
要在示例图像中显示图像的方式。 – nrubin29 2013-05-05 22:15:04