Back to index

wims  3.65+svn20090927
CommentDialog.java
Go to the documentation of this file.
00001 package rene.zirkel.dialogs;
00002 
00003 // file: ZirkelFrame.java
00004 
00005 import java.awt.*;
00006 import java.awt.event.*;
00007 
00008 import rene.gui.*;
00009 import rene.zirkel.Zirkel;
00010 
00011 public class CommentDialog extends HelpCloseDialog implements DoActionListener
00012 {      TextArea V;
00013        String S;
00014        Button Close;
00015        public CommentDialog (Frame f, String s, String title, boolean readonly)
00016        {      super(f,title,true);
00017               setLayout(new BorderLayout());
00018               S=s;
00019               V=new TextArea(s,30,60,TextArea.SCROLLBARS_VERTICAL_ONLY);
00020               if (Global.Background!=null) V.setBackground(Global.Background);
00021               add("Center",V);
00022               Panel p=new MyPanel();
00023               if (readonly)
00024               {      p.add(Close=new ButtonAction(this,Zirkel.name("close"),"Close"));
00025               }
00026               else
00027               {      p.add(new ButtonAction(this,Zirkel.name("ok"),"OK"));
00028                      p.add(Close=new ButtonAction(this,Zirkel.name("cancel"),"Close"));
00029               }
00030               addHelp(p,"comment");
00031               add("South",new Panel3D(p));
00032               pack();
00033               center(f);
00034               V.addKeyListener(this);
00035               V.setEditable(!readonly);
00036               setVisible(true);
00037        }
00038        public void doAction (String s)
00039        {      if (s.equals("OK"))
00040               {      S=V.getText();
00041                      doclose();
00042               }
00043               else super.doAction(s);
00044        }
00045        public String getText ()
00046        {      return S;
00047        }
00048        public boolean escape ()
00049        {      return true;
00050        }
00051        public void focusGained (FocusEvent e)
00052        {      Close.requestFocus();
00053        }
00054 }