//***************************************************************************** // // Beenish Chaudry, Geetika Tewari, Elif Tosun and // Ileana Streinu // // Summer 1999, Fall 1999, Spring 2000 // //***************************************************************************** // //FrameText.java //Used in "Edit User Label" //Takes in the user input typed in a text area for the user label. // //***************************************************************************** import java.awt.*; import java.awt.event.*; import java.lang.*; import java.io.*; import java.util.*; public class FrameText extends Frame implements ActionListener, KeyListener { TextField tf; Label la; Button ok, cancel; PointObj thisnode; FramePoint bf; //************************** // // Constructor // //************************** public FrameText (FramePoint bff, String title, String label) { super(title); bf = bff; ok = new Button("OK"); cancel = new Button ("Cancel"); la = new Label (label); tf = new TextField (15); Panel top = new Panel(); top.setLayout (new FlowLayout()); top.add("West",la); top.add("East",tf); Panel bottom = new Panel(); bottom.setLayout (new FlowLayout()); bottom.add("West", ok); bottom.add("East", cancel); add ("North", top); add ("South", bottom); setVisible(true); setBounds (Constants.xFT,Constants.yFT,Constants.wFT,Constants.hFT); tf.addKeyListener(this); ok.addActionListener(this); cancel.addActionListener(this); }//end constructor //*************************** // // Action Performed // //*************************** public void actionPerformed(ActionEvent e) { if (e.getSource() == ok) { thisnode.appearanceP.userLabel = tf.getText(); setVisible(false); bf.pc.repaint(); } else if (e.getSource() == cancel) { setVisible(false); bf.pc.repaint(); } }//end action performed //*************************** // // keyPressed // //*************************** public void keyPressed(KeyEvent e) { if (e.getKeyCode() == Constants.ENTER) { thisnode.appearanceP.userLabel = tf.getText(); setVisible(false); bf.pc.repaint(); } else if (e.getKeyCode() == Constants.ESC) { setVisible(false); bf.pc.repaint(); } }//end key pressed public void keyTyped (KeyEvent e) { } public void keyReleased (KeyEvent e) { } //*************************** // // EditLabel // (user defined) //*************************** public void EditLabel(PointObj node) { setVisible(true); tf.setText(node.appearanceP.userLabel); tf.select( 0, node.appearanceP.userLabel.length()+1); thisnode = node; } }