Java tutorial
// Copyright 2009 Victor Iacoban // // 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 bazaar4idea.ui; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.core.Spacer; import javax.swing.*; import java.awt.*; public class BzrUsernamePasswordDialog extends DialogWrapper { private JPanel basePanel; private JTextField usernameTxt; private JPasswordField passwordTxt; public BzrUsernamePasswordDialog(Project project) { super(project, false); setTitle("Username and password required"); init(); } public void setUsername(String username) { usernameTxt.setText(username); } public String getUsername() { return usernameTxt.getText(); } public char[] getPassword() { return passwordTxt.getPassword(); } protected JComponent createCenterPanel() { return basePanel; } { // 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$$$() { basePanel = new JPanel(); basePanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); final JLabel label1 = new JLabel(); label1.setText("Username"); label1.setDisplayedMnemonic('U'); label1.setDisplayedMnemonicIndex(0); basePanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); usernameTxt = new JTextField(); basePanel.add(usernameTxt, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); final JLabel label2 = new JLabel(); label2.setText("Password"); label2.setDisplayedMnemonic('P'); label2.setDisplayedMnemonicIndex(0); basePanel.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); basePanel.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); passwordTxt = new JPasswordField(); passwordTxt.setText(""); basePanel.add(passwordTxt, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); label1.setLabelFor(usernameTxt); label2.setLabelFor(passwordTxt); } /** @noinspection ALL */ public JComponent $$$getRootComponent$$$() { return basePanel; } }