void jbInit() throws Exception {
// Add a window listener to see when the window closes without
// selecting OK
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
userCancelled = true;
}
});
// Ok button
jButtonOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButtonOK_actionPerformed(e);
}
});
jButtonOK.setText("OK");
jButtonOK.setMnemonic('o");
getRootPane().setDefaultButton(jButtonOK);
// Cancel button
jButtonCancel.setText("Cancel");
jButtonCancel.setMnemonic('c");
jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButtonCancel_actionPerformed(e);
}
});
// Passphrase panel
JPanel passphrasePanel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets(0, 2, 2, 2);
gbc.weightx = 1.0;
UIUtil.jGridBagAdd(passphrasePanel, message, gbc,
GridBagConstraints.REMAINDER);
UIUtil.jGridBagAdd(passphrasePanel, jPasswordField, gbc,
GridBagConstraints.REMAINDER);
// Create the center banner panel
IconWrapperPanel centerPanel = new IconWrapperPanel(new ResourceIcon(
PASSPHRASE_ICON), passphrasePanel);
centerPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
//
JPanel buttonPanel = new JPanel(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.CENTER;
gbc.insets = new Insets(6, 6, 0, 0);
gbc.weighty = 1.0;
UIUtil.jGridBagAdd(buttonPanel, jButtonOK, gbc,
GridBagConstraints.RELATIVE);
UIUtil.jGridBagAdd(buttonPanel, jButtonCancel, gbc,
GridBagConstraints.REMAINDER);
JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
southPanel.add(buttonPanel);
// Wrap the whole thing in an empty border
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
mainPanel.add(centerPanel, BorderLayout.CENTER);
mainPanel.add(southPanel, BorderLayout.SOUTH);
// Build the main panel
getContentPane().add(mainPanel);
//
jPasswordField.grabFocus();
}
|