home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
inprise
/
JRUNTIME.Z
/
PasswordDialog.java
< prev
next >
Wrap
Text File
|
1998-05-08
|
4KB
|
133 lines
// This snippet creates a new dialog box
// that prompts for a password
// <File=PasswordDialog.java>
//Title:
//Version:
//Copyright:
//Author:
//Company:
//Description:
//
//<PACKAGE>
import java.awt.*;
import java.awt.event.*;
import borland.jbcl.layout.*;
import borland.jbcl.control.*;
public class PasswordDialog extends Dialog {
Panel panel1 = new Panel();
Panel panel2 = new Panel();
Panel dialogPanel = new Panel();
BevelPanel bevelPanel1 = new BevelPanel();
Button button1 = new Button();
Button button2 = new Button();
Label label1 = new Label();
TextField textField1 = new TextField(24);
BorderLayout borderLayout1 = new BorderLayout();
BorderLayout borderLayout2 = new BorderLayout();
GridLayout gridLayout1 = new GridLayout();
FlowLayout flowLayout1 = new FlowLayout();
public PasswordDialog(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
add(dialogPanel,BorderLayout.CENTER);
//pack();
}
public PasswordDialog(Frame frame, String title) {
this(frame, title, false);
}
public PasswordDialog(Frame frame) {
this(frame, "", false);
}
private void jbInit() throws Exception {
dialogPanel.setLayout(borderLayout2);
bevelPanel1.setLayout(borderLayout1);
button1.setLabel("OK");
button1.addActionListener(new PasswordDialog_button1_actionAdapter(this));
button2.setLabel("Cancel");
label1.setText("Enter Password");
textField1.setEchoChar('@');
gridLayout1.setVgap(4);
gridLayout1.setHgap(6);
button2.addActionListener(new PasswordDialog_button2_actionAdapter(this));
this.addWindowListener(new PasswordDialog_this_windowAdapter(this));
panel1.add(panel2);
bevelPanel1.setMargins(new Insets(4, 4, 4, 4));
panel2.setLayout(gridLayout1);
panel1.setLayout(flowLayout1);
dialogPanel.setSize(new Dimension(400, 100));
bevelPanel1.setBevelInner(BevelPanel.RAISED);
bevelPanel1.setBevelOuter(BevelPanel.LOWERED);
bevelPanel1.add(label1,BorderLayout.NORTH);
bevelPanel1.add(textField1,BorderLayout.SOUTH);
dialogPanel.add(panel1, BorderLayout.SOUTH);
panel2.add(button1);
panel2.add(button2);
dialogPanel.add(bevelPanel1,BorderLayout.CENTER);
pack();
textField1.requestFocus();
}
//OK
void button1_actionPerformed(ActionEvent e) {
dispose();
}
//Cancel
void button2_actionPerformed(ActionEvent e) {
dispose();
}
void this_windowClosing(WindowEvent e) {
dispose();
}
}
class PasswordDialog_button1_actionAdapter implements ActionListener {
PasswordDialog adaptee;
PasswordDialog_button1_actionAdapter(PasswordDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button1_actionPerformed(e);
}
}
class PasswordDialog_button2_actionAdapter implements ActionListener {
PasswordDialog adaptee;
PasswordDialog_button2_actionAdapter(PasswordDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.button2_actionPerformed(e);
}
}
class PasswordDialog_this_windowAdapter extends WindowAdapter {
PasswordDialog adaptee;
PasswordDialog_this_windowAdapter(PasswordDialog adaptee) {
this.adaptee = adaptee;
}
public void windowClosing(WindowEvent e) {
adaptee.this_windowClosing(e);
}
}