List of usage examples for javax.swing JPasswordField JPasswordField
public JPasswordField(String text, int columns)
JPasswordField
initialized with the specified text and columns. From source file:edu.ku.brc.ui.UIHelper.java
public static JPasswordField createPasswordField(final String val, final int size) { JPasswordField tf = new JPasswordField(val, size); setControlSize(tf);//from ww w .j a v a 2 s . c o m return tf; }
From source file:org.kuali.test.ui.components.dialogs.DatabaseDlg.java
@SuppressWarnings("unchecked") private void initComponents() { String[] labels = { "Name", "DB Type", "Connection URL", "Driver", "Schema", "User Name", "Password", "" }; name = new JTextField(dbconnection.getName(), 20); name.setEditable(!isEditmode());/* w ww. j ava 2 s . co m*/ type = new JComboBox(Utils.getXmlEnumerations(DatabaseType.class)); type.setSelectedItem(dbconnection.getType()); url = new JTextField(dbconnection.getJdbcUrl(), 30); driver = new JTextField(dbconnection.getJdbcDriver(), 30); schema = new JTextField(dbconnection.getSchema(), 15); username = new JTextField(dbconnection.getUsername(), 20); String pass = ""; if (StringUtils.isNotBlank(dbconnection.getPassword())) { try { pass = Utils.decrypt(getMainframe().getEncryptionPassword(), dbconnection.getPassword()); } catch (Exception ex) { UIUtils.showError(this, "Decrypt Exception", "Password decryption failed"); pass = ""; } } password = new JPasswordField(pass, 20); configuredTablesOnly = new JCheckBox("Configured Tables Only"); configuredTablesOnly.setSelected(dbconnection.getConfiguredTablesOnly()); JComponent[] components = { name, type, url, driver, schema, username, password, configuredTablesOnly }; getContentPane().add(UIUtils.buildEntryPanel(labels, components), BorderLayout.CENTER); addStandardButtons(); setDefaultBehavior(); }
From source file:org.kuali.test.ui.components.dialogs.JmxDlg.java
private void initComponents() { String[] labels = { "Name", "JMX URL", "User Name", "Password" }; name = new JTextField(jmx.getName(), 20); name.setEditable(!isEditmode());/*from w w w . j ava 2s .c o m*/ jmxUrl = new JTextField(jmx.getJmxUrl(), 30); username = new JTextField(jmx.getUsername(), 20); String pass = ""; if (StringUtils.isNotBlank(jmx.getPassword())) { try { pass = Utils.decrypt(getMainframe().getEncryptionPassword(), jmx.getPassword()); } catch (UnsupportedEncodingException ex) { UIUtils.showError(this, "Decrypt Exception", "Password decryption failed"); } } password = new JPasswordField(pass, 20); JComponent[] components = { name, jmxUrl, username, password }; getContentPane().add(UIUtils.buildEntryPanel(labels, components), BorderLayout.NORTH); JPanel p = new JPanel(new BorderLayout()); if (!isEditmode()) { JButton b = new JButton("Refresh JMX Attributes"); JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 1, 6)); p2.add(b); p.add(p2, BorderLayout.NORTH); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadJMXData(); } }); } tabbedPane = new JTabbedPane(); for (int i = 0; i < tabInfo.length; ++i) { tabbedPane.addTab(tabInfo[i].getTabName(), new TablePanel(getMBeanTable(tabInfo[i].getJmxBeanName()))); } p.add(tabbedPane, BorderLayout.CENTER); getContentPane().add(p, BorderLayout.CENTER); if (isEditmode()) { loadJMXData(); } addStandardButtons(); setDefaultBehavior(); }
From source file:org.kuali.test.ui.components.dialogs.WebServiceDlg.java
private void initComponents() { String[] labels = { "Name", "WSDL URL", "User Name", "Password" }; name = new JTextField(webService.getName(), 20); name.setEditable(!isEditmode());/* w w w .j ava2 s . c o m*/ wsdlUrl = new JTextField(webService.getWsdlUrl(), 30); username = new JTextField(webService.getUsername(), 20); String pass = ""; if (StringUtils.isNotBlank(webService.getPassword())) { try { pass = Utils.decrypt(Utils.getEncryptionPassword(getConfiguration()), webService.getPassword()); } catch (UnsupportedEncodingException ex) { UIUtils.showError(this, "Decrypt Exception", "Password decryption failed"); } } password = new JPasswordField(pass, 20); JComponent[] components = { name, wsdlUrl, username, password }; getContentPane().add(UIUtils.buildEntryPanel(labels, components), BorderLayout.CENTER); addStandardButtons(); setDefaultBehavior(); }
From source file:typoscript.TypoScriptPluginOptions.java
/** * Construcs the dialog to add or edit a site * If a site object is passed in, we are editing * otherwise a null site means new/*from ww w .j a va 2 s . c o m*/ * * @param parent A reference to the option pane that opened this dialog * @param site A T3Site object to edit, or null to create a new one */ public AddEditSiteDialog(Component ourParent, T3Site site) { super(JOptionPane.getFrameForComponent(ourParent), (site == null) ? "New Site" : "Edit Site", true); parent = (TypoScriptPluginOptions) ourParent; if (site == null) { curSite = new T3Site(); // temporary isNew = true; origSite = null; } else { curSite = site; isNew = false; origSite = site; } JPanel formPanel = new JPanel(new GridBagLayout()); JLabel lblURL = new JLabel("Site root URL"); JLabel lblUser = new JLabel("Backend Login"); JLabel lblPass = new JLabel("Password"); txtURL = new JTextField(curSite.getUrlBase().toString(), 20); txtUser = new JTextField(curSite.getUsername(), 20); txtPass = new JPasswordField(curSite.getPassword(), 20); chkClearCache = new JCheckBox("Clear TYPO3 cache on template save", curSite.clearCacheOnSave()); // defaults to true btnSave = new JButton("Save"); btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ok(); } }); btnCancel = new JButton("Cancel"); btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cancel(); } }); btnTest = new JButton("Test settings"); btnTest.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { test(true); } }); formPanel.add(lblURL, GridBagHelper.getConstraint(0, 0, 1, 1, "right")); formPanel.add(txtURL, GridBagHelper.getConstraintWithInsets(1, 0, 1, 1, "left", 1, 5, 1, 0)); formPanel.add(lblUser, GridBagHelper.getConstraint(0, 1, 1, 1, "right")); formPanel.add(txtUser, GridBagHelper.getConstraintWithInsets(1, 1, 1, 1, "left", 1, 5, 1, 0)); formPanel.add(lblPass, GridBagHelper.getConstraint(0, 2, 1, 1, "right")); formPanel.add(txtPass, GridBagHelper.getConstraintWithInsets(1, 2, 1, 1, "left", 1, 5, 3, 0)); formPanel.add(chkClearCache, GridBagHelper.getConstraint(0, 3, 2, 1, "centre")); JPanel buttons = new JPanel(); buttons.add(btnSave); buttons.add(btnCancel); buttons.add(btnTest); formPanel.add(buttons, GridBagHelper.getConstraint(0, 5, 2, 1, "centre")); this.getContentPane().add(formPanel); this.pack(); this.setLocationRelativeTo(GUIUtilities.getParentDialog(parent)); this.setVisible(true); txtURL.requestFocus(); }
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);/*from w w w . j a v a 2s . co m*/ 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(); }