Java tutorial
/** * Copyright (C) 2008 Atlassian * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.atlassian.theplugin.idea.jira; import com.intellij.openapi.ui.DialogWrapper; import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import java.awt.*; public class GetUserNameDialog extends DialogWrapper { private JTextField userName; private JPanel panel; public GetUserNameDialog(String issueKey) { super(false); init(); setOKActionEnabled(false); userName.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { update(); } public void removeUpdate(DocumentEvent e) { update(); } public void changedUpdate(DocumentEvent e) { update(); } private void update() { setOKActionEnabled(userName.getText().length() > 0); } }); setTitle("New Assignee For " + issueKey); } public String getName() { return userName.getText(); } protected JComponent createCenterPanel() { return panel; } public JComponent getPreferredFocusedComponent() { return userName; } { // GUI initializer generated by IntelliJ IDEA GUI Designer // >>> IMPORTANT!! <<< // DO NOT EDIT OR ADD ANY CODE HERE! $$$setupUI$$$(); } /** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * * @noinspection ALL */ private void $$$setupUI$$$() { panel = new JPanel(); panel.setLayout(new GridBagLayout()); final JLabel label1 = new JLabel(); label1.setText("User Name"); GridBagConstraints gbc; gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(12, 12, 12, 0); panel.add(label1, gbc); userName = new JTextField(); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.weightx = 1.0; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 12, 0, 12); panel.add(userName, gbc); final JLabel label2 = new JLabel(); label2.setFont(new Font(label2.getFont().getName(), label2.getFont().getStyle(), 10)); label2.setHorizontalAlignment(0); label2.setHorizontalTextPosition(0); label2.setText("Warning: user name is sent to JIRA without validation"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 2; gbc.weightx = 1.0; panel.add(label2, gbc); } /** * @noinspection ALL */ public JComponent $$$getRootComponent$$$() { return panel; } }