だから私の問題は、私が以前にJspinnersで抱えていた問題です。jspinnerをタイトル付きの境界線で囲んでいます。ただし、GUIでは、jsが小さいため、タイトルテキストがカットされます。では、タイトルの長さに基づいてGUIを強制的にreziseする方法、またはタイトル全体に収まる十分なスペースを提供するためにjspinnerを長くするように管理する方法を教えてください。
JTextField name= new JTextField(9);
name.setBorder(new TitledBorder("Name"));
//setup spinner date format
SimpleDateFormat datePattern = new SimpleDateFormat("MM/dd/yyyy");
JSpinner dob = new JSpinner(new SpinnerDateModel());
dob.setEditor(new JSpinner.DateEditor(dob, datePattern.toPattern()));
dob.setBorder(new TitledBorder("Date of Birth"));
JPanel childPanel = new JPanel();
childPanel.setLayout(new FlowLayout());
childPanel.add(name);
childPanel.add(dob);
childPanel.setBorder(new TitledBorder("Child Info"));
それで:
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
mainPanel.add(childPanel);
childPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
//there are more items in this panel, just omitted them, that's why using BoxLayout