저는 2 개의 JPanels, 1 개의 버튼 패널 및 1 개의 그래픽 패널을 가지고 있습니다. 버튼 패널을 그래픽 패널 바로 아래에 배치하고 싶지만 버튼 패널은 그래픽 패널을 중간에 자릅니다. 나는 토론에서 보이는 상자 레이아웃을 시도해 왔는데, 내가하려고하는 것에 대한 최상의 형식처럼 보입니다. 누구든지 내 서식 문제에 대한 조언을 해줄 수 있습니까? 당신이 구성 요소의 setSize() 메서드를 호출하지 않을 것 때문에JPanel 형식 문제
JFrame canvas = new JFrame("Baseball Strike K");
JFrame canvas = new JFrame ("GraphicBoard");
canvas.setVisible(true);
canvas.setSize(1000,1000);
canvas.setDefaultCloseOperation(EXIT_ON_CLOSE);
//create two panels
//add them to contentPane
//set Layout
JPanel buttonPanel = createButtons();
JPanel mainPanel = new Graphic(); //extends JPanel and writes the paint method
mainPanel.setSize(1000, 1000);
Container content = canvas.getContentPane();
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
content.add(mainPanel);
content.add(buttonPanel);
코드가 충분하지 않습니다. 최소한 Graphic과 createButtons를 볼 필요가 있습니다. 실행 가능한 예제도 매우 유용 할 것입니다. – MadProgrammer
Eclipse IDE에서 WindowBuilder를 살펴보십시오. 돌아 보지 않을거야. – Java42
1) 더 빨리 도움을 받으려면 [SSCCE] (http://sscce.org/)를 게시하십시오. 2) JPanel을 확장하고 paint 메소드'Should be ..'the paintComponent 메소드를 작성한다. (예 : 여러 JFrame의 사용, 좋고 나쁜 관행?) (http://stackoverflow.com/a/9554657/418556) ' –