AppendFileDialog.java.txt
上传用户:aonuowh
上传日期:2021-05-23
资源大小:35390k
文件大小:3k
- /* $Id: AppendFileDialog.java,v 1.3 2002/09/09 05:50:39 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.awt.*;
- import java.awt.event.*;
- import java.util.*;
- public class AppendFileDialog extends Frame implements ActionListener {
-
- public SasClientFunction 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;
-
- /* This takes care of the look of AppendFileDialog */
- public AppendFileDialog() {
- super();
- setTitle(new String(advent));
- 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);
- Button[] butts = bp.getButtons();
- for (int i=0;i<butts.length;i++) butts[i].addActionListener(this);
- gridbag.setConstraints(bp,c);
- add(bp);
- addWindowListener( new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- setVisible(false);
- }
- });
- setSize(550,400);
- }
- /* for OK and CANCEL actions */
- public void actionPerformed(ActionEvent e) {
- if (e.getActionCommand().equals("Cancel")) this.setVisible(false);
- else if (e.getActionCommand().equals("Append Text")) {
- setCursor(new Cursor(Cursor.WAIT_CURSOR));
- ((SasClientFunction)sframe).appendFile(text.getText(),field.getText());
- setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
- this.setVisible(false);
- }
- }
-
- /** Allow another MIB load only if shown again */
- public synchronized void setVisible(boolean flag) {
- super.setVisible(flag);
- }
-
- }