package ip.hak;
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
public class ListDialog
extends Dialog
implements WindowListener, ActionListener, ItemListener {
Vector v;
List fileList;
Button okButton, cancelButton;
TextField tf;
String filename = null;
public ListDialog(Frame parent, String title, Vector vl) {
super(parent, title, true);
v = vl;
addWindowListener(this);
setSize(300, 300);
init();
setVisible(true);
}
public void init() {
setLayout(null);
setResizable(false);
fileList = new List(6, false);
fileList.setSize(240, 200);
fileList.setLocation(30, 30);
add(fileList);
fileList.addItemListener(this);
tf = new TextField();
tf.setSize(240, 20);
tf.setLocation(30, 240);
add(tf);
okButton = new Button("Select");
okButton.setSize(60, 20);
okButton.setLocation(60, 270);
okButton.addActionListener(this);
add(okButton);
cancelButton = new Button("Cancel");
cancelButton.setSize(60, 20);
cancelButton.setLocation(180, 270);
cancelButton.addActionListener(this);
add(cancelButton);
}
public void itemStateChanged(ItemEvent e) {
filename = fileList.getSelectedItem();
tf.setText(filename);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == okButton) {
if (tf.getText() == null) {
return;
}
setVisible(false);
return;
}
if (e.getSource() == cancelButton) {
setVisible(false);
return;
}
}
public void windowOpened(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
dispose();
}
public void windowClosed(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
}