List of usage examples for java.awt GridBagLayout setConstraints
public void setConstraints(Component comp, GridBagConstraints constraints)
From source file:pcgen.gui2.prefs.OutputPanel.java
/** * Instantiates a new output panel.// w ww . ja v a 2s. c o m */ public OutputPanel() { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); JLabel label; Border etched = null; TitledBorder title1 = BorderFactory.createTitledBorder(etched, IN_OUTPUT); title1.setTitleJustification(TitledBorder.LEADING); this.setBorder(title1); this.setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(2, 2, 2, 2); Utility.buildConstraints(c, 0, 0, 1, 1, 0, 0); label = new JLabel(LanguageBundle.getString("in_Prefs_outputSheetHTMLDefault")); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 0, 1, 1, 1, 0); outputSheetHTMLDefault = new JTextField( String.valueOf(SettingsHandler.getSelectedCharacterHTMLOutputSheet(null))); // sage_sam 9 April 2003 outputSheetHTMLDefault.addFocusListener(textFieldListener); gridbag.setConstraints(outputSheetHTMLDefault, c); this.add(outputSheetHTMLDefault); Utility.buildConstraints(c, 2, 0, 1, 1, 0, 0); outputSheetHTMLDefaultButton = createChooseButton(); gridbag.setConstraints(outputSheetHTMLDefaultButton, c); this.add(outputSheetHTMLDefaultButton); outputSheetHTMLDefaultButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(c, 0, 1, 1, 1, 0, 0); label = new JLabel(LanguageBundle.getString("in_Prefs_outputSheetPDFDefault")); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 1, 1, 1, 1, 0); outputSheetPDFDefault = new JTextField( String.valueOf(SettingsHandler.getSelectedCharacterPDFOutputSheet(null))); // sage_sam 9 April 2003 outputSheetPDFDefault.addFocusListener(textFieldListener); gridbag.setConstraints(outputSheetPDFDefault, c); this.add(outputSheetPDFDefault); Utility.buildConstraints(c, 2, 1, 1, 1, 0, 0); outputSheetPDFDefaultButton = createChooseButton(); gridbag.setConstraints(outputSheetPDFDefaultButton, c); this.add(outputSheetPDFDefaultButton); outputSheetPDFDefaultButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(c, 0, 2, 1, 1, 0, 0); label = new JLabel(IN_OUTPUT_SHEET_EQ_SET); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 2, 1, 1, 0, 0); outputSheetEqSet = new JTextField(String.valueOf(SettingsHandler.getSelectedEqSetTemplate())); // sage_sam 9 April 2003 outputSheetEqSet.addFocusListener(textFieldListener); gridbag.setConstraints(outputSheetEqSet, c); this.add(outputSheetEqSet); Utility.buildConstraints(c, 2, 2, 1, 1, 0, 0); outputSheetEqSetButton = createChooseButton(); gridbag.setConstraints(outputSheetEqSetButton, c); this.add(outputSheetEqSetButton); outputSheetEqSetButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(c, 0, 3, 3, 1, 0, 0); saveOutputSheetWithPC.setText(IN_SAVE_OUTPUT_SHEET_WITH_PC); gridbag.setConstraints(saveOutputSheetWithPC, c); this.add(saveOutputSheetWithPC); Utility.buildConstraints(c, 0, 4, 1, 1, 0, 0); label = new JLabel(LanguageBundle.getString("in_Prefs_outputSpellSheetDefault")); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 4, 1, 1, 0, 0); outputSheetSpellsDefault = new JTextField(String.valueOf(SettingsHandler.getSelectedSpellSheet())); outputSheetSpellsDefault.addFocusListener(textFieldListener); gridbag.setConstraints(outputSheetSpellsDefault, c); this.add(outputSheetSpellsDefault); Utility.buildConstraints(c, 2, 4, 1, 1, 0, 0); outputSheetSpellsDefaultButton = createChooseButton(); gridbag.setConstraints(outputSheetSpellsDefaultButton, c); this.add(outputSheetSpellsDefaultButton); outputSheetSpellsDefaultButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(c, 0, 5, 3, 1, 0, 0); printSpellsWithPC.setText(LanguageBundle.getString("in_Prefs_printSpellsWithPC")); gridbag.setConstraints(printSpellsWithPC, c); this.add(printSpellsWithPC); Utility.buildConstraints(c, 0, 6, 1, 1, 0, 0); label = new JLabel(IN_PAPER_TYPE); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 6, 2, 1, 0, 0); final int paperCount = Globals.getPaperCount(); paperNames = new String[paperCount]; for (int i = 0; i < paperCount; ++i) { paperNames[i] = Globals.getPaperInfo(i, PaperInfo.NAME); } paperType = new JComboBoxEx<>(paperNames); gridbag.setConstraints(paperType, c); this.add(paperType); Utility.buildConstraints(c, 0, 7, 3, 1, 0, 0); gridbag.setConstraints(removeTempFiles, c); this.add(removeTempFiles); Utility.buildConstraints(c, 0, 8, 3, 1, 0, 0); weaponProfPrintout = new JCheckBox(IN_WEAPON_PROF_PRINTOUT, SettingsHandler.getWeaponProfPrintout()); gridbag.setConstraints(weaponProfPrintout, c); this.add(weaponProfPrintout); Utility.buildConstraints(c, 0, 9, 1, 1, 0, 0); label = new JLabel(IN_POST_EXPORT_COMAND_STANDARD); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 9, 2, 1, 0, 0); postExportCommandStandard = new JTextField(String.valueOf(SettingsHandler.getPostExportCommandStandard())); gridbag.setConstraints(postExportCommandStandard, c); this.add(postExportCommandStandard); Utility.buildConstraints(c, 0, 10, 1, 1, 0, 0); label = new JLabel(IN_POST_EXPORT_COMMAND_PDF); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 10, 2, 1, 0, 0); postExportCommandPDF = new JTextField(String.valueOf(SettingsHandler.getPostExportCommandPDF())); gridbag.setConstraints(postExportCommandPDF, c); this.add(postExportCommandPDF); Utility.buildConstraints(c, 0, 11, 1, 1, 0, 0); label = new JLabel(IN_SKILL_FILTER); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 11, GridBagConstraints.REMAINDER, 1, 0, 0); skillFilter.setModel(new DefaultComboBoxModel<>(new SkillFilter[] { SkillFilter.Ranks, SkillFilter.NonDefault, SkillFilter.Usable, SkillFilter.All })); skillFilter.setSelectedItem(SkillFilter.getByValue(PCGenSettings.OPTIONS_CONTEXT .initInt(PCGenSettings.OPTION_SKILL_FILTER, SkillFilter.Usable.getValue()))); gridbag.setConstraints(skillFilter, c); this.add(skillFilter); Utility.buildConstraints(c, 0, 12, 1, 1, 0, 0); label = new JLabel(IN_INVALID_TO_HIT_TEXT); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 12, 2, 1, 0, 0); invalidToHitText = new JTextField(String.valueOf(SettingsHandler.getInvalidToHitText())); gridbag.setConstraints(invalidToHitText, c); this.add(invalidToHitText); Utility.buildConstraints(c, 0, 13, 1, 1, 0, 0); label = new JLabel(IN_INVALID_DMG_TEXT); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 13, GridBagConstraints.REMAINDER, 1, 0, 0); invalidDmgText = new JTextField(String.valueOf(SettingsHandler.getInvalidDmgText())); gridbag.setConstraints(invalidDmgText, c); this.add(invalidDmgText); Utility.buildConstraints(c, 0, 14, 3, 1, 0, 0); alwaysOverwrite = new JCheckBox(IN_ALWAYS_OVERWRITE, SettingsHandler.getAlwaysOverwrite()); gridbag.setConstraints(alwaysOverwrite, c); this.add(alwaysOverwrite); Utility.buildConstraints(c, 0, 15, 3, 1, 0, 0); showSingleBoxPerBundle = new JCheckBox(IN_SHOW_SINGLE_BOX_PER_BUNDLE, SettingsHandler.getShowSingleBoxPerBundle()); gridbag.setConstraints(showSingleBoxPerBundle, c); this.add(showSingleBoxPerBundle); Utility.buildConstraints(c, 0, 16, 1, 1, 0, 0); label = new JLabel(LanguageBundle.getString("in_Prefs_exportChoice")); // $NON-NSL-1$ gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 16, GridBagConstraints.REMAINDER, 1, 0, 0); gridbag.setConstraints(exportChoice, c); this.add(exportChoice); Utility.buildConstraints(c, 0, 17, 3, 1, 0, 0); gridbag.setConstraints(generateTempFileWithPdf, c); this.add(generateTempFileWithPdf); Utility.buildConstraints(c, 0, 20, 3, 1, 1, 1); c.fill = GridBagConstraints.BOTH; label = new JLabel(" "); gridbag.setConstraints(label, c); this.add(label); }
From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.ConfigurationDialog.java
ConfigurationDialog(final Component owner, final UploaderGuiController controller, final GiftCloudPropertiesFromApplication giftCloudProperties, final ProjectListModel projectListModel, final ResourceBundle resourceBundle, final GiftCloudDialogs giftCloudDialogs, final GiftCloudReporter reporter) { this.controller = controller; this.giftCloudProperties = giftCloudProperties; this.projectListModel = projectListModel; this.resourceBundle = resourceBundle; this.giftCloudDialogs = giftCloudDialogs; this.reporter = reporter; temporaryDropDownListModel = new TemporaryProjectListModel(projectListModel, giftCloudProperties.getLastProject()); componentToCenterDialogOver = owner; dialog = new JDialog(); dialog.setModal(true);/*w w w . j a va 2s .com*/ dialog.setResizable(false); // Call custom dialog close code when the close button is clicked dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { closeDialog(); } }); dialog.setLocationRelativeTo(componentToCenterDialogOver); // without this, appears at TLHC rather then center of parent or screen dialog.setTitle(resourceBundle.getString("configurationDialogTitle")); final GridBagConstraints sectionTitleConstraints = new GridBagConstraints(); sectionTitleConstraints.gridx = 0; sectionTitleConstraints.gridy = 1; sectionTitleConstraints.gridwidth = 2; sectionTitleConstraints.weightx = 1; sectionTitleConstraints.weighty = 1; sectionTitleConstraints.anchor = GridBagConstraints.CENTER; sectionTitleConstraints.fill = GridBagConstraints.HORIZONTAL; final GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.gridx = 0; labelConstraints.gridy = 0; labelConstraints.gridwidth = 1; labelConstraints.weightx = 1; labelConstraints.weighty = 1; labelConstraints.anchor = GridBagConstraints.LINE_START; labelConstraints.fill = GridBagConstraints.NONE; final GridBagConstraints inputConstraints = new GridBagConstraints(); inputConstraints.gridx = 1; inputConstraints.gridy = 0; inputConstraints.gridwidth = 1; inputConstraints.weightx = 1; inputConstraints.weighty = 1; inputConstraints.anchor = GridBagConstraints.LINE_END; inputConstraints.fill = GridBagConstraints.HORIZONTAL; GridBagConstraints separatorConstraint = new GridBagConstraints(); separatorConstraint.weightx = 1.0; separatorConstraint.fill = GridBagConstraints.HORIZONTAL; separatorConstraint.gridwidth = GridBagConstraints.REMAINDER; // The panel containing the GIFT-Cloud server configuration final JPanel giftCloudServerPanel = new JPanel(); { GridBagLayout projectUploadlayout = new GridBagLayout(); giftCloudServerPanel.setLayout(projectUploadlayout); JLabel serverPanelLabel = new JLabel(resourceBundle.getString("configPanelServerConfig"), SwingConstants.CENTER); giftCloudServerPanel.add(serverPanelLabel, sectionTitleConstraints); // GIFT-Cloud server URL { labelConstraints.gridwidth = 1; labelConstraints.gridy = 2; final JLabel giftCloudServerLabel = new JLabel(resourceBundle.getString("giftCloudServerText"), SwingConstants.RIGHT); giftCloudServerLabel.setToolTipText(resourceBundle.getString("giftCloudServerTextToolTipText")); giftCloudServerPanel.add(giftCloudServerLabel, labelConstraints); giftCloudServerText = new AutoFocusTextField(giftCloudProperties.getGiftCloudUrl().orElse(""), textFieldLengthForGiftCloudServerUrl); inputConstraints.gridy = 2; giftCloudServerPanel.add(giftCloudServerText, inputConstraints); } // GIFT-Cloud username { labelConstraints.gridy = 3; final JLabel giftCloudUserNameLabel = new JLabel(resourceBundle.getString("giftCloudUsername"), SwingConstants.RIGHT); giftCloudUserNameLabel.setToolTipText(resourceBundle.getString("giftCloudUsernameToolTipText")); giftCloudServerPanel.add(giftCloudUserNameLabel, labelConstraints); final Optional<String> serverUrl = giftCloudProperties.getLastUserName(); final String initialServerText = serverUrl.isPresent() ? serverUrl.get() : ""; giftCloudUsernameText = new AutoFocusTextField(initialServerText); inputConstraints.gridy = 3; giftCloudServerPanel.add(giftCloudUsernameText, inputConstraints); } // GIFT-Cloud password { labelConstraints.gridy = 4; final JLabel giftCloudPasswordLabel = new JLabel(resourceBundle.getString("giftCloudPassword"), SwingConstants.RIGHT); giftCloudPasswordLabel.setToolTipText(resourceBundle.getString("giftCloudPasswordToolTipText")); giftCloudServerPanel.add(giftCloudPasswordLabel, labelConstraints); final Optional<char[]> password = giftCloudProperties.getLastPassword(); final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray(); giftCloudPasswordText = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field inputConstraints.gridy = 4; giftCloudServerPanel.add(giftCloudPasswordText, inputConstraints); } // Project list { labelConstraints.gridy = 5; JLabel projectListLabel = new JLabel(resourceBundle.getString("giftCloudProjectLabelText"), SwingConstants.RIGHT); giftCloudServerPanel.add(projectListLabel, labelConstraints); inputConstraints.gridy = 5; projectList = new BackwardsCompatibleComboBox(); projectList.setEditable(false); projectList.setToolTipText(resourceBundle.getString("giftCloudProjectTooltip")); giftCloudServerPanel.add(projectList, inputConstraints); labelConstraints.gridx = 1; projectListWaitingLabel = new JLabel(resourceBundle.getString("giftCloudProjectWaitingLabelText"), SwingConstants.RIGHT); giftCloudServerPanel.add(projectListWaitingLabel, labelConstraints); labelConstraints.gridx = 0; } // Subject prefix { labelConstraints.gridy = 6; JLabel subjectPrefixLabel = new JLabel(resourceBundle.getString("configPanelListenerSubjectPrefix"), SwingConstants.RIGHT); subjectPrefixLabel .setToolTipText(resourceBundle.getString("configPanelListenerSubjectPrefixTooltip")); giftCloudServerPanel.add(subjectPrefixLabel, labelConstraints); inputConstraints.gridy = 6; final Optional<String> subjectPrefixText = giftCloudProperties.getSubjectPrefix(); subjectPrefixField = new AutoFocusTextField(subjectPrefixText.orElse("")); giftCloudServerPanel.add(subjectPrefixField, inputConstraints); } } // Local Dicom node configuration final JPanel listenerPanel = new JPanel(); { GridBagLayout listenerPanellayout = new GridBagLayout(); listenerPanel.setLayout(listenerPanellayout); JSeparator separator = new JSeparator(); listenerPanel.add(separator, separatorConstraint); JLabel listenerPanelLabel = new JLabel(resourceBundle.getString("configPanelListenerConfig"), SwingConstants.CENTER); listenerPanel.add(listenerPanelLabel, sectionTitleConstraints); { labelConstraints.gridy = 2; JLabel listeningAETitleJLabel = new JLabel(resourceBundle.getString("configPanelListenerAe"), SwingConstants.RIGHT); listeningAETitleJLabel.setToolTipText(resourceBundle.getString("configPanelListenerAeToolTip")); listenerPanellayout.setConstraints(listeningAETitleJLabel, labelConstraints); listenerPanel.add(listeningAETitleJLabel); inputConstraints.gridy = 2; final String listeningAETitleInitialText = giftCloudProperties.getListenerAETitle(); listeningAETitleField = new AutoFocusTextField(listeningAETitleInitialText); listenerPanellayout.setConstraints(listeningAETitleField, inputConstraints); listenerPanel.add(listeningAETitleField); } { labelConstraints.gridy = 3; JLabel listeningPortJLabel = new JLabel(resourceBundle.getString("configPanelListenerPort"), SwingConstants.RIGHT); listeningPortJLabel.setToolTipText(resourceBundle.getString("configPanelListenerPortToolTip")); listenerPanellayout.setConstraints(listeningPortJLabel, labelConstraints); listenerPanel.add(listeningPortJLabel); inputConstraints.gridy = 3; final int port = giftCloudProperties.getListeningPort(); final String portValue = Integer.toString(port); listeningPortField = new AutoFocusTextField(portValue); listenerPanellayout.setConstraints(listeningPortField, inputConstraints); listenerPanel.add(listeningPortField); } { labelConstraints.gridy = 4; JLabel patientListExportFolderLabel = new JLabel( resourceBundle.getString("configPanelListenerPatientListExportFolder"), SwingConstants.RIGHT); patientListExportFolderLabel.setToolTipText( resourceBundle.getString("configPanelListenerPatientListExportFolderTooltip")); listenerPanellayout.setConstraints(patientListExportFolderLabel, labelConstraints); listenerPanel.add(patientListExportFolderLabel); inputConstraints.gridy = 4; final Optional<String> patientListExportFolder = giftCloudProperties.getPatientListExportFolder(); patientListExportFolderField = new AutoFocusTextField(patientListExportFolder.orElse("")); listenerPanellayout.setConstraints(patientListExportFolderField, inputConstraints); listenerPanel.add(patientListExportFolderField); } // Patient list spreadsheet password { labelConstraints.gridy = 5; final JLabel patientListSpreadsheetPasswordLabel = new JLabel( resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPassword"), SwingConstants.RIGHT); patientListSpreadsheetPasswordLabel.setToolTipText( resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPasswordTooltip")); listenerPanel.add(patientListSpreadsheetPasswordLabel, labelConstraints); final Optional<char[]> password = giftCloudProperties.getPatientListPassword(); final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray(); patientListSpreadsheetPasswordField = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field inputConstraints.gridy = 5; listenerPanel.add(patientListSpreadsheetPasswordField, inputConstraints); } } // Remote PACS configuration final JPanel remoteAEPanel = new JPanel(); { GridBagLayout pacsPanellayout = new GridBagLayout(); remoteAEPanel.setLayout(pacsPanellayout); JSeparator separator = new JSeparator(); remoteAEPanel.add(separator, separatorConstraint); JLabel remotePanelLabel = new JLabel(resourceBundle.getString("pacsPanelListenerConfig"), SwingConstants.CENTER); remoteAEPanel.add(remotePanelLabel, sectionTitleConstraints); { labelConstraints.gridy = 2; JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsAeTitle"), SwingConstants.RIGHT); remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsAeTitleTooltip")); remoteAEPanel.add(remoteAeTitleLabel, labelConstraints); final Optional<String> pacsAeTitle = giftCloudProperties.getPacsAeTitle(); remoteAETitleField = new AutoFocusTextField(pacsAeTitle.isPresent() ? pacsAeTitle.get() : ""); inputConstraints.gridy = 2; remoteAEPanel.add(remoteAETitleField, inputConstraints); } { labelConstraints.gridy = 3; JLabel remoteAeHostLabel = new JLabel(resourceBundle.getString("configPanelPacsHostname"), SwingConstants.RIGHT); remoteAeHostLabel.setToolTipText(resourceBundle.getString("configPanelPacsHostnameTooltip")); remoteAEPanel.add(remoteAeHostLabel, labelConstraints); remoteAEHostName = new AutoFocusTextField(giftCloudProperties.getPacsHostName().orElse("")); inputConstraints.gridy = 3; remoteAEPanel.add(remoteAEHostName, inputConstraints); } { labelConstraints.gridy = 4; JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsPort"), SwingConstants.RIGHT); remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsPortTooltip")); remoteAEPanel.add(remoteAeTitleLabel, labelConstraints); remoteAEPortField = new AutoFocusTextField(Integer.toString(giftCloudProperties.getPacsPort())); inputConstraints.gridy = 4; remoteAEPanel.add(remoteAEPortField, inputConstraints); } } // The panel containing the cancel and apply buttons JPanel buttonPanel = new JPanel(); JPanel closeButtonPanel = new JPanel(); { final GridBagLayout buttonPanellayout = new GridBagLayout(); buttonPanel.setLayout(buttonPanellayout); JSeparator separator = new JSeparator(); buttonPanel.add(separator, separatorConstraint); closeButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); JButton cancelButton = new JButton(resourceBundle.getString("cancelSettingsButtonLabelText")); cancelButton.setToolTipText(resourceBundle.getString("cancelSettingsButtonToolTipText")); closeButtonPanel.add(cancelButton); cancelButton.addActionListener(new CancelActionListener()); JButton applyButton = new JButton(resourceBundle.getString("applySettingsButtonLabelText")); applyButton.setToolTipText(resourceBundle.getString("applySettingsButtonToolTipText")); closeButtonPanel.add(applyButton); applyButton.addActionListener(new ApplyActionListener()); JButton closeButton = new JButton(resourceBundle.getString("closeSettingsButtonLabelText")); closeButton.setToolTipText(resourceBundle.getString("closeSettingsButtonToolTipText")); closeButtonPanel.add(closeButton); closeButton.addActionListener(new CloseActionListener()); final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; buttonPanellayout.setConstraints(closeButtonPanel, constraints); buttonPanel.add(closeButtonPanel); } // The main panel of the configuration dialog JPanel configPanel = new JPanel(); { final GridBagLayout configPanelLayout = new GridBagLayout(); configPanel.setLayout(configPanelLayout); { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(giftCloudServerPanel, constraints); configPanel.add(giftCloudServerPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(listenerPanel, constraints); configPanel.add(listenerPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 2; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(remoteAEPanel, constraints); configPanel.add(remoteAEPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 3; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(buttonPanel, constraints); configPanel.add(buttonPanel); } } projectList.setModel(temporaryDropDownListModel); showProjectList(projectListModel.isEnabled()); // Create a listener to enable/disable the project list when it is set from the server. // The reason for this is that the project list is set after logging into the server, which can happen asynchronously after property changes have been applied. // If the server was configured in the dialog and apply clicked, it might take a few seconds for the project list to be updated, and we want it to become available when this happens projectListEnabledListener = new DropDownListModel.EnabledListener<Boolean>() { @Override public void statusChanged(final Boolean visibility) { showProjectList(projectListModel.isEnabled()); } }; projectListModel.addListener(projectListEnabledListener); GridBagLayout layout = new GridBagLayout(); dialog.setLayout(layout); Container content = dialog.getContentPane(); content.add(configPanel); dialog.pack(); dialog.setVisible(true); dialog.pack(); }