표시되지 않습니다. 그러나 JPanel
에 구성 요소를 추가하면 버튼 만 표시됩니다. 하지만 아니 JLabel
.인 JPanel는 - 나는 <code>JScrollPane</code>에서 <code>JPanel</code> 필요 내가 <code>.setLocation(x, y)</code></p> <p>와 함께 모든 요소의 위치를 설정할 요소
방법은 다음과 JFrame
생성자에서 호출 :
private void initGUI_test() {
this.setSize(950, 700);
this.setResizable(false);
this.getContentPane().setLayout(null);
JScrollPane mainScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JPanel container = new JPanel();
mainScroll.setSize(900,500);
mainScroll.setLocation(0,100);
mainScroll.setBorder(BorderFactory.createLineBorder(Color.blue));
mainScroll.add(container);
container.setLayout(null);
container.setLocation(0, 0);
container.setSize(900, 500);
JLabel rowA = new JLabel();
rowA.setSize(180, 26);
rowA.setLocation(10, 100);
rowA.setText("Row A");
JButton loadButton = new JButton();
loadButton.setSize(180, 34);
loadButton.setLocation(290, 110);
loadButton.setText("Load file");
container.add(rowA);
container.add(loadButton);
this.getContentPane().add(mainScroll);
}
이 ** **'널 layout' 사용을 금지해야합니다! 스윙은 다양한 플랫폼, 화면 해상도, 픽셀 완벽한 GUI로 유지 보수하기가 어렵지만 대신 레이아웃 관리자 또는 [조합]을 사용해야합니다 (http://docs.oracle.com/javase/tutorial/uiswing /layout/visual.html) 및 [구성 요소 사이의 공백]에 대한 빈 테두리 (http://stackoverflow.com/questions/17874717/providing-white-space-in-a-swing-gui/17874718#17874718)를 참조하십시오. – Frakcool
[Null layout is evil] (http://www.leepoint.net/GUI/layouts/nulllayout.html)과 [왜 스윙에서 null 레이아웃을 사용하는 것을 눈살을 찌푸리게하는지] (http://stackoverflow.com)를 참조하십시오./question/6592468/why-it-frowned-on-to-use-null-layout-in-swing) 왜 사용하지 말아야하는지에 대한 자세한 정보를 제공합니다. 위의 링크를 읽은 후에는 복사하여 붙여 넣기 할 수있는 [mcve]를 게시하여 동일한 문제를 참조하십시오. – Frakcool
ASCII 아트 또는 최소 크기에서 GUI의 * 의도 된 * 레이아웃의 간단한 그림을 제공하고 크기를 조정할 수 있으면 더 많은 너비와 높이를 제공하십시오. –