0
텍스트 필드, 텍스트 영역 및 단추 두 개를 만들어야하지만 내 프로그램을 실행할 때 나타나지 않기 때문에 텍스트 필드에 붙어 있습니다. 내 JFrame은 계속 비어 있습니다.텍스트 필드가 나타나지 않는 이유는 무엇입니까?
public class SentanceBuilder extends JFrame {
private JTextField textField = new JTextField(50);
private JTextArea textArea = new JTextArea(200,200);
private JButton Submit = new JButton();
private JButton Cancel = new JButton();
public SentanceBuilder(){
textField.setVisible(true);
textField.setLocation(50, 50);
this.textField();
this.setSize(400, 300);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
public void textField(){
String textContent = textField.getText();
}
}
'textField.setLocation (50, 50) '1) 자바의 GUI는, 이와 같이 등 다른 OS', 스크린 크기, 스크린 해상도에서 작동해야 그들은 픽셀 완벽한 레이아웃에 도움이되지 않습니다. 대신 레이아웃 관리자 또는 [조합] (http://stackoverflow.com/a/5630271/418556)과 [공백] 레이아웃 채우기 및 테두리 (http://stackoverflow.com/a/17874718/)를 사용하십시오. 418556). 2) 더 빨리 도움을 받으려면 [MCVE] (http://stackoverflow.com/help/mcve) (최소한의 완전하고 검증 가능한 예)를 게시하십시오. –
'private JTextArea textArea = new JTextArea (200,200);'이 텍스트 영역을 200 열 200 행으로 설정 하시겠습니까? 나는 그것을 충분히 표현할만큼 큰 모니터가 없다! 나는 당신이 그것들이 픽셀 값이라고 생각했다. –