AppendFileDialog.java
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:3k
源码类别:

SNMP编程

开发平台:

C/C++

  1. /* $Id: AppendFileDialog.java,v 1.3 2002/09/09 05:50:39 parasuraman Exp $ */
  2. /*
  3.  * @(#)AppendFileDialog.java
  4.  * Copyright (c) 1996-2002 AdventNet, Inc. All Rights Reserved.
  5.  * Please read the associated COPYRIGHTS file for more details.
  6.  */
  7. import java.applet.*;
  8. import java.awt.*;
  9. import java.awt.event.*;
  10. import java.util.*;
  11. public class AppendFileDialog extends Frame implements ActionListener {
  12.   
  13.   public SasClientFunction sframe; // The frame that provides the OK function
  14.   Font fontb = new Font("Helvetica", Font.BOLD, 16);
  15.   Font font = new Font("Helvetica", Font.PLAIN, 16);
  16.   String advent = new String("AdventNet Append File Dialog");
  17.   TextField field;
  18.   TextArea text;
  19.   
  20. /* This takes care of the look of AppendFileDialog */
  21.   public AppendFileDialog() {
  22.     super();
  23.     setTitle(new String(advent));
  24.     setBackground(Color.lightGray);
  25.     GridBagLayout gridbag = new GridBagLayout();  // we'll use gridbag
  26.     GridBagConstraints c = new GridBagConstraints();
  27.     setLayout(gridbag);
  28.     c.fill = GridBagConstraints.BOTH;
  29.     c.weightx = 1.0;
  30.     c.insets = new Insets(20,10,0,10);
  31.     
  32.     c.gridwidth = GridBagConstraints.REMAINDER;
  33.     Label label = new Label("Enter the Text to be Appended");
  34. label.setFont(fontb);
  35.     gridbag.setConstraints(label,c);
  36.     add(label);
  37.     c.insets = new Insets(0,10,10,10);
  38.     c.gridwidth = GridBagConstraints.REMAINDER;
  39.     text = new TextArea();
  40.     text.setEditable(true);
  41.     gridbag.setConstraints(text,c);
  42.     add(text);
  43.     c.gridwidth = 1;
  44.     label = new Label("Enter File Name to be Appended");
  45. label.setFont(fontb);
  46.     gridbag.setConstraints(label,c);
  47.     add(label);
  48.     c.gridwidth = GridBagConstraints.REMAINDER;
  49.     field = new TextField();
  50.     field.setEditable(true);
  51.     gridbag.setConstraints(field,c);
  52.     add(field);
  53.      // Bottom panel is a panel sub-class we've defined for a row of buttons
  54.     c.weighty = 0.0;
  55.     c.gridheight = 1;
  56.     String buttons[] = {"Append Text", "Cancel"};
  57.     ButtonPanel bp = new ButtonPanel(buttons);
  58.     bp.setFont(fontb);
  59. Button[] butts = bp.getButtons();
  60. for (int i=0;i<butts.length;i++) butts[i].addActionListener(this);
  61.     gridbag.setConstraints(bp,c);
  62.     add(bp);
  63. addWindowListener( new WindowAdapter() {
  64. public void windowClosing(WindowEvent e) {
  65. setVisible(false);
  66. }
  67. });
  68.     setSize(550,400);
  69.   }
  70. /* for OK and CANCEL actions */
  71.   public void actionPerformed(ActionEvent e) {
  72. if (e.getActionCommand().equals("Cancel")) this.setVisible(false);
  73.     else if (e.getActionCommand().equals("Append Text")) {
  74.   setCursor(new Cursor(Cursor.WAIT_CURSOR));
  75.   ((SasClientFunction)sframe).appendFile(text.getText(),field.getText());
  76.   setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
  77.   this.setVisible(false);
  78.     }
  79.   }
  80.   
  81.   /** Allow another MIB load only if shown again */
  82.   public synchronized void setVisible(boolean flag) {
  83.     super.setVisible(flag);
  84.   }
  85.   
  86. }