GridLayout面板上的面板

时间:2013-10-06 06:17:18

标签: java swing layout jpanel grid-layout

是否可以在具有GridLayout图像的面板上显示面板(例如Panel-A几乎透明)?

JPanel mainPanel = new JPanel(new BorderLayout());

JPanel gridOfImages = new JPanel(new GridLayout(3,3));//Panel with a grid of images
JPanel nearlyOpaquePanel = new JPanel(); //A panel that is almost transparent.

// assuming that all already have the required properties like size and colour.

mainPanel.add(gridOfImages,Borderlayout.CENTER);
mainPanel.add(nearlyOpaquePanel,BorderLayout.CENTER);

我对这个想法的想法是,面板将堆叠在一起,gridOfImages将通过nearlyOpaquePanel显示,但我的结果是我只有nearlyOpaquePanel来显示和我无法通过它看到gridOfImages

1 个答案:

答案 0 :(得分:2)

相关问题