간단한 데이터 입력 대화 상자를위한 맞춤 패널을 만들려고합니다. 레이블과 텍스트 필드를 추가하는 사용자 정의 패널을 만들었습니다. 표시를 위해 JOptionPane에 추가하려고합니다.자바가 JOptionPane에 컴포넌트를 추가하는 중
내가 호출하면 내 구성 요소는 표시되지 않지만 JOptionPane 버튼은 수행합니다. 이 작업을 수행하는 올바른 방법은 무엇입니까? 고마워요 !! 당신은 당신의 TestPanel 메인 패널을 추가 할 필요가
public class TestPanel extends JPanel {
JTextField custIdTextField;
JTextField companyTextField;
JTextField firstNameTextField;
JTextField lastNameTextField;
public TestPanel() {
initUI();
}
public final void initUI() {
// create the panel and set the layout
JPanel main = new JPanel();
main.setLayout(new GridLayout(4,4));
// create the labels
JLabel custIdLabel = new JLabel("Cust Id: ");
JLabel companyLabel = new JLabel("Company: ");
JLabel firstNameLabel = new JLabel("First Name: ");
JLabel lastNameLabel = new JLabel("Last Name: ");
// create the text fields
custIdTextField = new JTextField();
companyTextField = new JTextField();
firstNameTextField = new JTextField();
lastNameTextField = new JTextField();
// add componets to panel
main.add(custIdLabel);
main.add(custIdTextField);
main.add(companyLabel);
main.add(companyTextField);
main.add(firstNameLabel);
main.add(firstNameTextField);
main.add(lastNameLabel);
main.add(lastNameTextField);
}
감사! 정말 감사. 나는 아직도이 GUI 물건들을 모두 배우고있다. – wyoskibum