CreateDirDialog.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:3k
- /* $Id: CreateDirDialog.java,v 1.3 2002/09/09 05:50:39 parasuraman Exp $ */
- /*
- * @(#)CreateDirDialog.java
- * Copyright (c) 1996-2003 AdventNet, Inc. All Rights Reserved.
- * Please read the associated COPYRIGHTS file for more details.
- */
- import java.applet.*;
- import java.awt.*;
- import java.awt.event.*;
- import java.util.*;
- public class CreateDirDialog extends Frame implements ActionListener {
- LabeledTextField ltf =null;
- ButtonPanel ok_close =null;
- public SasClientFunction sframe;
- Font fontb = new Font("Helvetica", Font.BOLD, 16);
- Font font = new Font("Helvetica", Font.PLAIN, 16);
- String advent = new String("AdventNet Create Directory Dialog");
- /* This takes care of the look of CreateDirDialog */
- public CreateDirDialog(String title, boolean modal, String prompt, String defaulttext, int txtlength) {
- super();
- setTitle(new String(title + " : " + advent));
- setBackground(Color.lightGray);
- setLayout(new BorderLayout());
- ltf = new LabeledTextField(prompt,defaulttext,txtlength);
- ltf.addActionListener(this);
- add("Center", ltf);
- String buttons[] = {"OK","Cancel"};
- ok_close = new ButtonPanel(buttons);
- Button[] butts = ok_close.getButtons();
- for (int i=0;i<butts.length;i++) butts[i].addActionListener(this);
- add("South", ok_close);
- setFont(fontb, font);
-
- addWindowListener( new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- setVisible(false);
- }
- });
- setSize(550,200);
- }
- /* set fonts to the buttons and TextField */
- public void setFont(Font fontb, Font font) {
- if (ltf != null) ltf.setFont(fontb, font);
- if (ok_close != null) ok_close.setFont(fontb);
- super.setFont(fontb);
- }
- boolean loading = false; // to avoid loading MIBs twice
- /* actions for OK and Cancel buttons */
- public void actionPerformed(ActionEvent e) {
- if (loading) return;
- Component comp = (Component)e.getSource();
- if (comp instanceof Button) {
- if (e.getActionCommand().equals("Cancel")) this.setVisible(false);
- else if (e.getActionCommand().equals("OK")) {
- loading = true;
- setCursor(new Cursor(Cursor.WAIT_CURSOR));
- ((SasClientFunction)sframe).createDir(ltf.textfield.getText());
- setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
- this.setVisible(false);
- }
- }
- if (comp instanceof TextField) {
- loading = true;
- setCursor(new Cursor(Cursor.WAIT_CURSOR));
- ((SasClientFunction)sframe).createDir(ltf.textfield.getText());
- setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
- this.setVisible(false);
- }
- }
- /** Allow another MIB load only if shown again */
- public synchronized void setVisible(boolean flag) {
- loading = false;
- super.setVisible(flag);
- }
-
- }