001: // @(#)ProxyAuthDialog.java 1.2 "@(#)ProxyAuthDialog.java 1.2 00/02/09 Sun Microsystems"
002:
003: package com.sun.portal.netlet.client.common;
004:
005: import java.awt.*;
006: import java.awt.event.ActionEvent;
007: import java.awt.event.ActionListener;
008: import java.awt.event.KeyEvent;
009: import java.awt.event.KeyListener;
010:
011: public class ProxyAuthDialog extends Dialog {
012:
013: Label port;
014: TextField namefield, passfield;
015:
016: ProxyAuthDialog(Frame f, ActionListener a) {
017: super (f, ResourceProperties.getString("pad.1")); //Netlet Proxy Authentication
018:
019: GridBagLayout gb = new GridBagLayout();
020: GridBagConstraints gc = new GridBagConstraints();
021: setLayout(gb);
022: gc.fill = GridBagConstraints.NONE;
023: gc.gridwidth = GridBagConstraints.REMAINDER;
024: gc.gridheight = 1;
025:
026: gc.gridx = 0;
027: gc.gridy = 0;
028: // Proxy Authentication Required
029: Label label = new Label(ResourceProperties.getString("pad.2"),
030: Label.CENTER);
031: gb.setConstraints(label, gc);
032: add(label);
033:
034: gc.gridx = 0;
035: gc.gridy = 1;
036: // Please enter Proxy Username and Password:
037: Label label2 = new Label(ResourceProperties.getString("pad.3"));
038: gb.setConstraints(label2, gc);
039: add(label2);
040:
041: gc.gridx = 0;
042: gc.gridy = 2;
043: Panel up = new Panel(new GridLayout(2, 2));
044: Label nlabel = new Label(ResourceProperties.getString("pad.4")); // Username:
045: gc.anchor = GridBagConstraints.EAST;
046: up.add(nlabel);
047: namefield = new TextField(20);
048: gc.anchor = GridBagConstraints.CENTER;
049: up.add(namefield);
050: Label plabel = new Label(ResourceProperties.getString("pad.5")); // Password:
051: gc.anchor = GridBagConstraints.EAST;
052: up.add(plabel);
053: passfield = new TextField(20);
054: passfield.addActionListener(a);
055: passfield.setEchoChar('*');
056: gc.anchor = GridBagConstraints.CENTER;
057: up.add(passfield);
058: gb.setConstraints(up, gc);
059: add(up);
060:
061: namefield.addKeyListener(new KeyListener() {
062: public void keyTyped(KeyEvent e) {
063: }
064:
065: public void keyReleased(KeyEvent e) {
066: }
067:
068: public void keyPressed(KeyEvent e) {
069: if (e.getKeyCode() == KeyEvent.VK_TAB
070: || e.getKeyCode() == KeyEvent.VK_ENTER) {
071: passfield.requestFocus();
072: }
073: }
074: });
075: passfield.addKeyListener(new KeyListener() {
076: public void keyTyped(KeyEvent e) {
077: }
078:
079: public void keyReleased(KeyEvent e) {
080: }
081:
082: public void keyPressed(KeyEvent e) {
083: if (e.getKeyCode() == KeyEvent.VK_ENTER) {
084: // make enter act like hitting the OK button
085: dispatchEvent((new ActionEvent(this , 1001, "OK")));
086: } else if (e.getKeyCode() == KeyEvent.VK_TAB) {
087: namefield.requestFocus();
088: }
089: }
090: });
091:
092: gc.gridx = 0;
093: gc.gridy = 3;
094: Panel b = new Panel(new FlowLayout(FlowLayout.CENTER, 10, 10));
095: Button ok = new Button(ResourceProperties.getString("pad.6")); // OK
096: ok.addActionListener(a);
097: b.add(ok);
098: Button cancel = new Button(ResourceProperties
099: .getString("pad.7")); // Cancel
100: cancel.addActionListener(a);
101: cancel.setActionCommand("cancel");
102: b.add(cancel);
103: gb.setConstraints(b, gc);
104: add(b);
105:
106: pack();
107: Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
108: Point p = new Point();
109: p.x = (d.width / 6);
110: p.y = (d.height / 6);
111: setLocation(p);
112: }
113:
114: public void showWarning() {
115: setVisible(true);
116: namefield.requestFocus();
117: toFront();
118: }
119:
120: synchronized public void waitForAction() {
121: try {
122: wait();
123: } catch (InterruptedException e) {
124: }
125: }
126:
127: synchronized public void notifyAction() {
128: notify();
129: }
130:
131: public String getUsername() {
132: return (namefield.getText());
133: }
134:
135: public String getPassword() {
136: return (passfield.getText());
137: }
138:
139: }
|