JDesktopPane 내의 모든 JInternalFrames의 z 순서 (계층 깊이)를 얻으려면 어떻게해야할까요? 이것을위한 직접적인 방법이없는 것 같습니다. 어떤 아이디어?JDesktopPane의 JInternalFrames z 순서를 얻는 방법
4
A
답변
4
이 시도하지는 않았지만 클래스의 조상 인 Container
클래스는 getComponentZOrder
메서드를 포함합니다. Container
에있는 Component
을 전달하면 int
의 z 순서가 반환됩니다. 메서드에 의해 반환 된 가장 낮은 z 순서 값을 가진 Component
이 마지막에 그려지며, 다시 말하면 상단에 그려집니다.
의 배열을 반환하는 JDesktopPane.getAllFrames
메서드를 사용하면 내부 프레임의 z 순서를 얻을 수 있다고 생각합니다.
편집
나는 실제로 그것을 밖으로 시도하고 작동하는 것 같다 : 위의 예에서
final JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JDesktopPane desktopPane = new JDesktopPane();
desktopPane.add(new JInternalFrame("1") {
{
setVisible(true);
setSize(100, 100);
}
});
desktopPane.add(new JInternalFrame("2") {
{
setVisible(true);
setSize(100, 100);
}
});
desktopPane.add(new JInternalFrame("3") {
JButton b = new JButton("Get z-order");
{
setVisible(true);
setSize(100, 100);
getContentPane().add(b);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
JInternalFrame[] iframes = desktopPane.getAllFrames();
for (JInternalFrame iframe : iframes)
{
System.out.println(iframe + "\t" +
desktopPane.getComponentZOrder(iframe));
}
}
});
}
});
f.setContentPane(desktopPane);
f.setLocation(100, 100);
f.setSize(400, 400);
f.validate();
f.setVisible(true);
하는 JDesktopPane
이 세 번째가를 갖는 세 JInternalFrame
들로 채워집니다 버튼을 누르면 JInternalFrame
과 그 z 순서의 목록이 System.out
에 출력됩니다.
JDesktopPaneTest$3[... tons of info on the frame ...] 0
JDesktopPaneTest$2[... tons of info on the frame ...] 1
JDesktopPaneTest$1[... tons of info on the frame ...] 2
예는 단지 짧은 코드를 유지하기 위해 익명 내부 클래스를 많이 사용하지만 실제 프로그램 아마 그렇게 안 :
예 출력은 다음과 같다.
관련 문제
- 1. WinForms를 사용하여 컨트롤의 Z 순서를 설정하는 방법
- 2. Swing Java에서 이미지에 Z 순서를 설정하는 방법
- 3. 컨트롤이 Z 순서를 변경하지 못하도록하려면?
- 4. iframe 객체의 Z 순서를 설정하십시오.
- 5. JDesktopPane의 배경 설정
- 6. Objective-C에서 스프라이트의 Z 순서를 변경하려면 어떻게해야합니까?
- 7. Question on JInternalFrames
- 8. Windows에서 z-order를 얻는 방법은 무엇입니까?
- 9. 여러 JInternalFrames 간의 공유 객체
- 10. Visual Studio adorner z 순서를 변경할 수 없습니다.
- 11. RedGate 데이터를 얻는 방법 비교 정렬 순서를 고려하십시오?
- 12. 안드로이드 장치와 사용자 상호 작용의 순서를 얻는 방법?
- 13. 윈도우의 Z- 순서를 쿼리하거나 설정하기위한 스윙 해킹이 있습니까?
- 14. Visual Studio Express에서 z- 순서를 한 번씩 변경하는 방법은 무엇입니까?
- 15. IE7이 Z- 인덱스 순서를 따르지 않는 이유는 무엇입니까?
- 16. SplitViewController - rootview 및 detailview의 z 순서를 변경할 수 있습니까?
- 17. Explorer에서 파일/디렉터리의 순서를 얻는 방법은 무엇입니까?
- 18. 부팅 순서를 읽는 방법?
- 19. 가상 지구에서 레이어 순서를 제어하는 방법
- 20. LINQ 쿼리에서 그룹화 및 순서를 지정하는 방법
- 21. MKAnnotationViews의 Z 순서 지정
- 22. regex를 사용하여 문자열에서 [a-z]/[a-z] /를 제거하는 방법?
- 23. SqlBulkCopy로 행 순서를 유지하는 방법?
- 24. 컬렉션의 항목 순서를 보장하는 방법
- 25. web.xml에서 리스너의 순서를 결정하는 방법
- 26. NHibernate - 정렬 순서를 업데이트하는 방법
- 27. StackPanel에서 항목 순서를 설정하는 방법
- 28. CGPath의 요점 순서를 뒤집는 방법
- 29. Mysql에서 기본 순서를 뒤집는 방법?
- 30. jquery에서 탭 순서를 설정하는 방법