JLayeredPane
s을 살펴보십시오. Here is a tutorial.
은 편집 :
패널 a는 AWT 구성 요소 인 경우에는 하드 panelB이 중복 얻을 누르면됩니다.
경량 (스윙)을 혼합하지 마십시오과 경량의 구성 요소가 헤비급을 겹쳐 것으로 예상되는 컨테이너 내의 헤비급 (AWT) 구성 요소 : Sun의 Mixing Heavy and Light Components을받을 수 기사에서.
그러나 panelA에 프레임을 완전히 채우려는 경우 panelA를 panelA의 구성 요소로 추가하지 않으시겠습니까?
Edit2가 : 당신이 panelB에게 헤비급 구성 요소를 만들 수 있다면
, 당신은 JLayeredPane
를 사용할 수 있습니다.
public static void main(String[] args){
new GUITest();
}
public GUITest() {
frame = new JFrame("test");
frame.setSize(300,300);
addStuffToFrame();
SwingUtilities.invokeLater(new Runnable(){
public void run() {
frame.setVisible(true);
}
});
}
private void addStuffToFrame() {
Panel awtPanel = new Panel();
awtPanel.setBackground(Color.blue);
//here you can fool around with the pane:
//first, you can see how the layered pane works by switching the
//DEFUALT_LAYER and PALLETTE_LAYER back and forth between the two panels
//and re-compiling to see the results
awtPanel.setSize(200,300);
frame.getLayeredPane().add(awtPanel, JLayeredPane.DEFAULT_LAYER);
//next you comment out the above two lines and
//uncomment the following line. this will give you the desired effect of
//awtPanel filling in the entire frame, even on a resize.
//frame.add(awtPanel);
Panel awtPanel2 = new Panel();
awtPanel2.setBackground(Color.red);
awtPanel2.setSize(300,200);
frame.getLayeredPane().add(awtPanel2,JLayeredPane.PALETTE_LAYER);
}
출처
2009-09-15 16:43:22
akf
패널 A의 너비는 프레임의 너비와 일치해야합니다. – CarlG
네, 기본적으로 A가 높이와 너비 모두 전체 프레임을 채우기를 원합니다. –