AppendFileDialog.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:3k
- /* $Id: AppendFileDialog.java,v 1.3 2002/09/09 05:46:50 parasuraman Exp $ */
- /*
- * @(#)AppendFileDialog.java
- * Copyright (c) 1996-2003 AdventNet, Inc. All Rights Reserved.
- * Please read the associated COPYRIGHTS file for more details.
- */
- import java.applet.*;
- import java.io.*;
- import java.awt.*;
- import java.util.*;
- import com.adventnet.snmp.snmp2.SASClient;
- public class AppendFileDialog extends Applet {
-
- public SASClient sframe; // The frame that provides the OK function
- Font fontb = new Font("Helvetica", Font.BOLD, 16);
- Font font = new Font("Helvetica", Font.PLAIN, 16);
- String advent = new String("AdventNet Append File Dialog");
- TextField field;
- TextArea text;
-
- public void init() {
-
-
- try{
- sframe = new SASClient(this,false,2);}
- catch(Exception e){}
- //sframe.protocol = 2;
- setBackground(Color.lightGray);
- GridBagLayout gridbag = new GridBagLayout(); // we'll use gridbag
- GridBagConstraints c = new GridBagConstraints();
- setLayout(gridbag);
- c.fill = GridBagConstraints.BOTH;
- c.weightx = 1.0;
- c.insets = new Insets(20,10,0,10);
-
- c.gridwidth = GridBagConstraints.REMAINDER;
- Label label = new Label("Enter the Text to be Appended");label.setFont(fontb);
- gridbag.setConstraints(label,c);
- add(label);
- c.insets = new Insets(0,10,10,10);
- c.gridwidth = GridBagConstraints.REMAINDER;
- text = new TextArea();
- text.setEditable(true);
- gridbag.setConstraints(text,c);
- add(text);
- c.gridwidth = 1;
- label = new Label("Enter File Name to be Appended");label.setFont(fontb);
- gridbag.setConstraints(label,c);
- add(label);
- c.gridwidth = GridBagConstraints.REMAINDER;
- field = new TextField();
- field.setEditable(true);
- gridbag.setConstraints(field,c);
- add(field);
- // Bottom panel is a panel sub-class we've defined for a row of buttons
- c.weighty = 0.0;
- c.gridheight = 1;
- String buttons[] = {"Append Text", "Cancel"};
- ButtonPanel bp = new ButtonPanel(buttons);
- bp.setFont(fontb);
- gridbag.setConstraints(bp,c);
- add(bp);
- resize(550,400);
- // setBackground(Title.fadedBlue);
- }
- /* for OK and CANCEL actions */
- public boolean action(Event e, Object arg) {
- if (e.target instanceof Button) {
- //if (arg.equals("Cancel")) this.hide();
- //else
- if (arg.equals("Append Text")) {
-
- try{
- String filename = (new File(field.getText())).getName(); // get rid of path
- //File f = new File("HTTPUsers"+File.separator+filename);
- //sframe.appendFile(f.getAbsolutePath(),(text.getText()).getBytes());
- sframe.appendFile(filename,(text.getText()).getBytes());
- hide();
- }
- catch(Exception ex){}
-
- //hide();
- }
- }
- return true;
- }
- /** Allow another MIB load only if shown again */
- public synchronized void show() {
- super.show();
- }
- /** To handle destroy window - pass all else to parent */
- public boolean handleEvent(Event e) {
- if (e.id == Event.WINDOW_DESTROY) {
- hide();
- }
- return super.handleEvent(e);
- }
- }