public NewTraitDialog() { setSize(500, 300); setTitle(translate("dialog.title")); View.centerScreen(this); View.setWindowIcon(this); Container cnt = getContentPane(); cnt.setLayout(new BorderLayout()); JPanel optionsPanel = new JPanel(new FlowLayout()); // optionsPanel.add(new JLabel(translate("label.type"))); typeComboBox = new JComboBox<>( new String[] { translate("type.method"), translate("type.getter"), translate("type.setter"), translate("type.const"), translate("type.slot"), }); staticCheckbox = new JCheckBox(translate("checkbox.static")); optionsPanel.add(staticCheckbox); String accessStrings[] = new String[modifiers.length]; for (int i = 0; i < accessStrings.length; i++) { String pref = Namespace.kindToPrefix(modifiers[i]); String name = Namespace.kindToStr(modifiers[i]); accessStrings[i] = (pref.isEmpty() ? "" : pref + " ") + "(" + name + ")"; } // optionsPanel.add(new JLabel(translate("label.access"))); accessComboBox = new JComboBox<>(accessStrings); optionsPanel.add(accessComboBox); optionsPanel.add(typeComboBox); // optionsPanel.add(new JLabel(translate("label.name"))); nameField = new JTextField(); nameField.setPreferredSize(new Dimension(300, nameField.getPreferredSize().height)); optionsPanel.add(nameField); cnt.add(optionsPanel, BorderLayout.CENTER); JPanel buttonsPanel = new JPanel(new FlowLayout()); JButton buttonOk = new JButton(AppStrings.translate("button.ok")); buttonOk.setActionCommand(ACTION_OK); buttonOk.addActionListener(this); JButton buttonCancel = new JButton(AppStrings.translate("button.cancel")); buttonCancel.setActionCommand(ACTION_CANCEL); buttonCancel.addActionListener(this); buttonsPanel.add(buttonOk); buttonsPanel.add(buttonCancel); cnt.add(buttonsPanel, BorderLayout.SOUTH); pack(); setDefaultCloseOperation(HIDE_ON_CLOSE); setModalityType(ModalityType.APPLICATION_MODAL); nameField.addAncestorListener( new AncestorListener() { @Override public void ancestorAdded(AncestorEvent event) { JComponent component = event.getComponent(); component.requestFocusInWindow(); } @Override public void ancestorRemoved(AncestorEvent event) {} @Override public void ancestorMoved(AncestorEvent event) {} }); getRootPane().setDefaultButton(buttonOk); }