1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.*;
/**
* Created by IntelliJ IDEA.
* User: bebe
* Date: 10-Jun-2006
* Time: 18:58:33
* To change this template use File | Settings | File Templates.
*/
public class MyPanel extends JPanel {
private GridBagLayout gridBagLayout1 = new GridBagLayout();
private JPanel defautIdentityPanel = new JPanel();
private JLabel titleLabel = new JLabel();
private GridBagLayout gridBagLayout2 = new GridBagLayout();
private JLabel yourNameLabel = new JLabel();
private JLabel emailAddressLabel = new JLabel();
private JLabel replyToAddressLabel = new JLabel();
private JLabel organisationLabel = new JLabel();
private JTextField nameTextField = new JTextField();
private JTextField emailAddressTextField = new JTextField();
private JTextField replyAddressTextField = new JTextField();
private JTextField organisationTextField = new JTextField();
private JCheckBox attachSignatureCheckBox = new JCheckBox();
private JTextField signatureTextField = new JTextField();
private JButton chooseButton = new JButton();
private JButton editCardButton = new JButton();
private JCheckBox attachVCardCheckBox = new JCheckBox();
private JLabel outgoingServerLabel = new JLabel();
private JComboBox outgoingServerCombobox = new JComboBox();
private JButton manageIdentitiesButton = new JButton();
private JScrollPane accountsScrollPane = new JScrollPane();
private JButton addAccountButton = new JButton();
private JButton setAsDefaultButton = new JButton();
private JButton removeAccountButton = new JButton();
private JButton okButton = new JButton();
private JButton cancelButton = new JButton();
private JTree accountTree = new JTree();
public MyPanel() {
initGui();
}
private void initGui() {
this.setLayout(gridBagLayout1);
this.setSize(new Dimension(626, 474));
defautIdentityPanel.setBorder(BorderFactory.createTitledBorder("Default Identity"));
defautIdentityPanel.setLayout(gridBagLayout2);
titleLabel.setText("Each account has an identity, wich is the information .... ");
yourNameLabel.setText("Your Name :");
emailAddressLabel.setText("Email Address :");
replyToAddressLabel.setText("Reply to address :");
organisationLabel.setText("Organisation :");
attachSignatureCheckBox.setText("Attach this signature :");
attachSignatureCheckBox.setMargin(new Insets(0, 0, 0, 0));
signatureTextField.setMinimumSize(new Dimension(100, 20));
signatureTextField.setPreferredSize(new Dimension(300, 20));
chooseButton.setText("Choose ...");
editCardButton.setText("Edit Card...");
attachVCardCheckBox.setText("Attach my VCard to messages");
outgoingServerLabel.setText("Outgoing Server (SMTP) :");
manageIdentitiesButton.setText("Manage Identities ...");
addAccountButton.setText("Add Account...");
setAsDefaultButton.setText("Set as Default");
removeAccountButton.setText("Remove Account");
okButton.setText("OK");
cancelButton.setText("Cancel");
defautIdentityPanel.add(titleLabel,
new GridBagConstraints(0, 0, GridBagConstraints.REMAINDER,
1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(5, 5, 5, 5),
0, 0));
defautIdentityPanel.add(yourNameLabel,
new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(5, 5, 0, 0),
0, 0));
defautIdentityPanel.add(emailAddressLabel,
new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(5, 5, 0, 0),
0, 0));
defautIdentityPanel.add(replyToAddressLabel,
new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(5, 5, 0, 0),
0, 0));
defautIdentityPanel.add(organisationLabel,
new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(5, 5, 0, 0),
0, 0));
defautIdentityPanel.add(nameTextField,
new GridBagConstraints(1, 1, GridBagConstraints.REMAINDER,
1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(3, 5, 0, 5),
0, 0));
defautIdentityPanel.add(emailAddressTextField,
new GridBagConstraints(1, 2, GridBagConstraints.REMAINDER,
1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(3, 5, 0, 5),
0, 0));
defautIdentityPanel.add(replyAddressTextField,
new GridBagConstraints(1, 3, GridBagConstraints.REMAINDER,
1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(3, 5, 0, 5),
0, 0));
defautIdentityPanel.add(organisationTextField,
new GridBagConstraints(1, 4, GridBagConstraints.REMAINDER,
1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(3, 5, 0, 5),
0, 0));
defautIdentityPanel.add(attachSignatureCheckBox,
new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(10, 5, 0, 0),
0, 0));
defautIdentityPanel.add(signatureTextField,
new GridBagConstraints(0, 6, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
new Insets(3, 25, 0, 5),
0, 0));
defautIdentityPanel.add(chooseButton,
new GridBagConstraints(2, 6, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL,
new Insets(3, 0, 0, 5),
0, 0));
defautIdentityPanel.add(editCardButton,
new GridBagConstraints(2, 7, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL,
new Insets(3, 0, 0, 5),
0, 0));
defautIdentityPanel.add(attachVCardCheckBox,
new GridBagConstraints(0, 7, 2, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(5, 5, 0, 0),
0, 0));
defautIdentityPanel.add(outgoingServerLabel,
new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
new Insets(8, 5, 0, 0),
0, 0));
defautIdentityPanel.add(outgoingServerCombobox,
new GridBagConstraints(1, 8, GridBagConstraints.REMAINDER,
1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 5, 5),
0, 0));
this.add(defautIdentityPanel,
new GridBagConstraints(1, 0, 4, 1, 0.6, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 5, 5), 0, 0));
this.add(manageIdentitiesButton,
new GridBagConstraints(3, 1, GridBagConstraints.REMAINDER,
1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
new Insets(10, 0, 0, 10), 0, 0));
accountsScrollPane.getViewport().add(accountTree, null);
this.add(accountsScrollPane,
new GridBagConstraints(0, 0, 1, 2, 0.4, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(5, 5, 5, 5), 0, 0));
this.add(addAccountButton,
new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 5, 0, 5), 0, 0));
this.add(setAsDefaultButton,
new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 0, 5), 0, 0));
this.add(removeAccountButton,
new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 0, 5), 0, 2));
this.add(okButton,
new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
new Insets(5, 0, 5, 5), 0, 0));
this.add(cancelButton,
new GridBagConstraints(3, 5, 1, 1, 0.1, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
new Insets(5, 5, 0, 5), 0, 0));
}
public static void main(String[] args) {
JFrame myFrame = new JFrame("GridBagLayout power");
myFrame.add(new MyPanel());
myFrame.pack();
myFrame.setLocationRelativeTo(null);
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.setVisible(true);
}
} |
Partager