home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 25 / IOPROG_25.ISO / SOFT / JavaS / javastar-eval.exe / data1.cab / Program_Files / examples / namedb / namedb.java < prev    next >
Encoding:
Java Source  |  1999-02-11  |  21.1 KB  |  667 lines

  1. /* ****************************************************************
  2. ** @(#)namedb.java    1.5 0
  3. **
  4. ** Copyright 1997 Sun Microsystems, Inc. All Rights Reserved
  5. **
  6. ** ****************************************************************
  7. */
  8.  
  9. import java.applet.*;
  10. import java.awt.*;
  11. import java.awt.event.*;
  12. import java.io.*;
  13. import java.util.Vector;
  14. import gjt.*;
  15.  
  16. public class namedb extends Applet implements ActionListener {        
  17.  
  18.   public intlStrings strings=new intlStrings(1);
  19.  
  20.   public Box box1,box2,box3;
  21.   public Panel p1,p2,p3;
  22.   public Label index;
  23.  
  24.   public Label title_label;
  25.   public Panel button1_panel,button2_panel,data_panel,main_panel;
  26.  
  27.   public Frame theframe;
  28.   private RoloApi rolo;
  29.  
  30.   public boolean UseSetName=true;
  31.   public boolean ugly=false;
  32.   public boolean right=false;
  33.  
  34.   public namePop nameDialog;
  35.   public searchPop searchDialog;
  36.   public FileDialog fileDialog;
  37.   public messagebox errorDialog;
  38.  
  39.   public OpenlookButton forward_button,back_button,namelist_button;
  40.   public OpenlookButton search_button,add_button,change_button,remove_button;
  41.   public OpenlookButton clear_button;
  42.   public Button open_button,save_button,saveas_button;
  43.   public Button close_button,exit_button;
  44.  
  45.   public Label name_label;
  46.   public Label address1_label;
  47.   public Label address2_label;
  48.   public Label phone_label;
  49.   public Label email_label;
  50.   public Label other_label;
  51.  
  52.   public TextField name_text;
  53.   public TextField address1_text;
  54.   public TextField address2_text;
  55.   public TextField phone_text;
  56.   public TextField email_text;
  57.   public TextField other_text;
  58.  
  59.   public void init() {
  60.  
  61.     try{
  62.       String lang = getParameter("Lang");
  63.       if (lang != null && lang.equals("fr")) {
  64.     strings.setLang(2);
  65.       }
  66.     } catch(NullPointerException npe){
  67.       //occurs when running as application
  68.     }
  69.  
  70.     if (UseSetName)
  71.       setName("namedbFrame");
  72.     theframe=new Frame(strings.title());
  73.     if (UseSetName)
  74.       theframe.setName("namedb_frame");
  75.     theframe.setBackground(Color.lightGray);
  76.  
  77.     rolo = new RoloApi();
  78.  
  79.     nameDialog = new namePop();
  80.     nameDialog.setParent(this);
  81.     nameDialog.init();
  82.     if (UseSetName)
  83.       nameDialog.setName("nameDialog");
  84.  
  85.     searchDialog = new searchPop();
  86.     searchDialog.setParent(this);
  87.     searchDialog.init();
  88.     if (UseSetName)
  89.       searchDialog.setName("searchDialog");
  90.  
  91.     fileDialog=new FileDialog(theframe);
  92.     if (UseSetName)
  93.       fileDialog.setName("fileDialog");
  94.  
  95.     errorDialog=new messagebox("Error","Must set name to add entry");
  96.     errorDialog.pack();
  97.     if (UseSetName)
  98.       errorDialog.setName("errorDialog");
  99.  
  100.     main_panel=new Panel();
  101.     if (UseSetName)
  102.       main_panel.setName("centerPanel");
  103.     add(main_panel);
  104.  
  105.     data_panel=new Panel();
  106.     if (UseSetName)
  107.       data_panel.setName("data_panel");
  108.     add(data_panel);
  109.  
  110.     button1_panel=new Panel();
  111.     if (UseSetName)
  112.       button1_panel.setName("button1_panel");
  113.     button1_panel.setLayout(new GridLayout(2,4));
  114.  
  115.     button2_panel=new Panel();
  116.     if (UseSetName)
  117.       button2_panel.setName("button2_panel");
  118.     button2_panel.setLayout(new GridLayout(1,5));
  119.  
  120.     GridBagLayout main_grid = new GridBagLayout();
  121.     GridBagLayout data_grid = new GridBagLayout();
  122.  
  123.     title_label=new Label(strings.title()+" - Untitled");
  124.     if (UseSetName)
  125.       title_label.setName("title_label");
  126.     if (!ugly)
  127.       title_label.setFont(new Font("Serif",Font.BOLD,20));
  128.     main_panel.add(title_label);
  129.  
  130.     if (!ugly) {
  131.       box1=new Box(button1_panel,"");
  132.       main_panel.add(box1);
  133.       box2=new Box(button2_panel,"");
  134.       main_panel.add(box2);
  135.       box3=new Box(data_panel," 0 of 0 ");
  136.       if (UseSetName)
  137.     box3.titleLabel.setName("status_label");
  138.       box3.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  139.       main_panel.add(box3);
  140.     } else {
  141.       p1=new Panel();
  142.       p1.add(button1_panel);
  143.       main_panel.add(p1);
  144.       p2=new Panel();
  145.       p2.add(button2_panel);
  146.       main_panel.add(p2);
  147.       p3=new Panel();
  148.       p3.add(data_panel);
  149.       main_panel.add(p3);
  150.       index=new Label(" 0 of 0 ");
  151.       if (UseSetName)
  152.     index.setName("status_label");
  153.       main_panel.add(index);
  154.     }
  155.  
  156.     back_button=new OpenlookButton("<<");
  157.     if (UseSetName)
  158.       back_button.setName("back_button");
  159.     if (!ugly)
  160.       back_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  161.     back_button.addActionListener(this);
  162.     button1_panel.add(back_button,new Point(0,0));
  163.  
  164.     forward_button=new OpenlookButton(">>");
  165.     if (UseSetName)
  166.       forward_button.setName("forward_button");
  167.     if (!ugly)
  168.       forward_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  169.     forward_button.addActionListener(this);
  170.     button1_panel.add(forward_button,new Point(0,1));
  171.  
  172.     namelist_button=new OpenlookButton(strings.nameb());
  173.     if (UseSetName)
  174.       namelist_button.setName("namelist_button");
  175.     if (!ugly)
  176.       namelist_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  177.     namelist_button.addActionListener(this);
  178.     button1_panel.add(namelist_button,new Point(0,2));
  179.  
  180.     search_button=new OpenlookButton(strings.searchb());
  181.     if (UseSetName)
  182.       search_button.setName("search_button");
  183.     if (!ugly)
  184.       search_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  185.     search_button.addActionListener(this);
  186.     button1_panel.add(search_button,new Point(0,3));
  187.  
  188.     add_button=new OpenlookButton(strings.addb());
  189.     if (UseSetName)
  190.       add_button.setName("add_button");
  191.     if (!ugly)
  192.       add_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  193.     add_button.addActionListener(this);
  194.     button1_panel.add(add_button,new Point(1,0));
  195.  
  196.     change_button=new OpenlookButton(strings.changeb());
  197.     if (UseSetName)
  198.       change_button.setName("change_button");
  199.     if (!ugly)
  200.       change_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  201.     change_button.addActionListener(this);
  202.     button1_panel.add(change_button,new Point(1,1));
  203.  
  204.     remove_button=new OpenlookButton(strings.removeb());
  205.     if (UseSetName)
  206.       remove_button.setName("remove_button");
  207.     if (!ugly)
  208.       remove_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  209.     remove_button.addActionListener(this);
  210.     button1_panel.add(remove_button,new Point(1,2));
  211.  
  212.     clear_button=new OpenlookButton(strings.clearb());
  213.     if (UseSetName)
  214.       clear_button.setName("clear_button");
  215.     if (!ugly)
  216.       clear_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  217.     clear_button.addActionListener(this);
  218.     button1_panel.add(clear_button,new Point(1,3));
  219.  
  220.     open_button=new Button(strings.openb());
  221.     if (UseSetName)
  222.       open_button.setName("open_button");
  223.     if (!ugly)
  224.       open_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  225.     open_button.addActionListener(this);
  226.     button2_panel.add(open_button,new Point(0,0));
  227.  
  228.     save_button=new Button(strings.saveb());;
  229.     if (UseSetName)
  230.       save_button.setName("save_button");
  231.     if (!ugly)
  232.       save_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  233.     save_button.addActionListener(this);
  234.     button2_panel.add(save_button,new Point(0,1));
  235.  
  236.     saveas_button=new Button(strings.saveasb());
  237.     if (UseSetName)
  238.       saveas_button.setName("saveas_button");
  239.     if (!ugly)
  240.       saveas_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  241.     saveas_button.addActionListener(this);
  242.     button2_panel.add(saveas_button,new Point(0,2));
  243.  
  244.     close_button=new Button(strings.closeb());
  245.     if (UseSetName)
  246.       close_button.setName("close_button");
  247.     if (!ugly)
  248.       close_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  249.     close_button.addActionListener(this);
  250.     button2_panel.add(close_button,new Point(0,3));
  251.  
  252.     exit_button=new Button(strings.exitb());
  253.     if (UseSetName)
  254.       exit_button.setName("exit_button");
  255.     if (!ugly)
  256.       exit_button.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  257.     exit_button.addActionListener(this);
  258.     button2_panel.add(exit_button,new Point(0,4));
  259.  
  260.     name_label = new Label();
  261.     name_label.setText(strings.namel());
  262.     if (!ugly)
  263.       name_label.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  264.     if (UseSetName)
  265.       name_label.setName("name_label");
  266.     data_panel.add(name_label);
  267.  
  268.     name_text = new TextField(40);
  269.     if (UseSetName)
  270.       name_text.setName("name_text");
  271.     name_text.setBackground(Color.lightGray.darker());
  272.     if (!ugly)
  273.       name_text.setFont(new Font("TimesRoman",Font.BOLD,14));
  274.     name_text.addActionListener(this);
  275.     data_panel.add(name_text);
  276.  
  277.     address1_label = new Label();
  278.     address1_label.setText(strings.addressl());
  279.     if (!ugly)
  280.       address1_label.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  281.     if (UseSetName)
  282.       address1_label.setName("address1_button");
  283.     data_panel.add(address1_label);
  284.  
  285.     address1_text = new TextField(20);
  286.     if (UseSetName)
  287.       address1_text.setName("address1_text");
  288.     address1_text.setBackground(Color.lightGray.darker());
  289.     if (!ugly)
  290.       address1_text.setFont(new Font("TimesRoman",Font.BOLD,14));
  291.     data_panel.add(address1_text);
  292.  
  293.     address2_text = new TextField(20);
  294.     if (UseSetName)
  295.       address2_text.setName("address2_text");
  296.     address2_text.setBackground(Color.lightGray.darker());
  297.     if (!ugly)
  298.       address2_text.setFont(new Font("TimesRoman",Font.BOLD,14));
  299.     data_panel.add(address2_text);
  300.  
  301.     phone_label = new Label();
  302.     phone_label.setText(strings.phonel());
  303.     if (UseSetName)
  304.       phone_label.setName("phone_label");
  305.     if (!ugly)
  306.       phone_label.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  307.     data_panel.add(phone_label);
  308.  
  309.     phone_text = new TextField(20);
  310.     if (UseSetName)
  311.       phone_text.setName("phone_text");
  312.     phone_text.setBackground(Color.lightGray.darker());
  313.     if (!ugly)
  314.       phone_text.setFont(new Font("TimesRoman",Font.BOLD,14));
  315.     data_panel.add(phone_text);
  316.  
  317.     email_text = new TextField(20);
  318.     if (UseSetName)
  319.       email_text.setName("email_text");
  320.     email_text.setBackground(Color.lightGray.darker());
  321.     if (!ugly)
  322.       email_text.setFont(new Font("TimesRoman",Font.BOLD,14));
  323.     data_panel.add(email_text);
  324.  
  325.     other_label = new Label();
  326.     other_label.setText(strings.salaryl());
  327.     if (UseSetName)
  328.       other_label.setName("other_label");
  329.     if (!ugly)
  330.       other_label.setFont(new Font("Serif",Font.BOLD+Font.ITALIC,14));
  331.     data_panel.add(other_label);
  332.  
  333.     other_text = new TextField(20);
  334.     if (UseSetName)
  335.       other_text.setName("other_text");
  336.     other_text.setBackground(Color.lightGray.darker());
  337.     if (!ugly)
  338.       other_text.setFont(new Font("TimesRoman",Font.BOLD,14));
  339.     data_panel.add(other_text);
  340.  
  341.     // set the data grid, all data labels and tfs
  342.     constrain( data_grid, name_label, 0,0,1,1,GridBagConstraints.WEST,GridBagConstraints.NONE,0,0,0,5,0,0,0,0 );
  343.  
  344.     constrain( data_grid, name_text, 1,0,2,1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,0,0,0,0,0,0,0,0);
  345.  
  346.     constrain( data_grid, address1_label, 0,1,1,1,GridBagConstraints.WEST,GridBagConstraints.NONE,0,0,0,0,0,0,0,0 );
  347.  
  348.     constrain( data_grid, address1_text, 1,1,1,1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,0,0,0,0,0,0,0,0 );
  349.  
  350.     constrain( data_grid, address2_text, 2,1,1,1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,0,0,0,0,0,0,0,0 );
  351.  
  352.     constrain( data_grid, phone_label, 0,2,1,1,GridBagConstraints.WEST,GridBagConstraints.NONE,0,0,0,0,0,0,0,0 );
  353.  
  354.     constrain( data_grid, phone_text, 1,2,1,1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,0,0,0,0,0,0,0,0 );
  355.  
  356.     constrain( data_grid, email_text, 2,2,1,1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,0,0,0,0,0,0,0,0 );
  357.  
  358.     constrain( data_grid, other_label, 0,3,1,1,GridBagConstraints.WEST,GridBagConstraints.NONE,0,0,0,0,0,0,0,0 );
  359.  
  360.     constrain( data_grid, other_text, 1,3,1,1,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,0,0,0,0,0,0,0,0 );
  361.  
  362.     data_panel.setLayout(data_grid);
  363.  
  364.     constrain( main_grid, title_label, 1,0,2,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,0,0,0,0,0,0,0,0 );
  365.  
  366.     if (ugly) {
  367.       constrain( main_grid, index, 1,3,1,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,0,0,0,0,0,0,0,0 );
  368.       constrain( main_grid, title_label,1,0,2,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,0,0,0,0,0,0,0,0 );
  369.       constrain( main_grid, p1, 1,2,2,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,0,0,0,0,0,0,0,0 );
  370.       constrain( main_grid, p2, 1,1,2,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,0,0,10,0,10,0,0,0 );
  371.       constrain( main_grid, p3, 1,4,2,4, GridBagConstraints.CENTER,GridBagConstraints.NONE, 0,0,0,0,0,0,0,0 );
  372.     } else {
  373.       constrain( main_grid, box1, 1,5,2,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,0,0,0,0,0,0,0,0 );
  374.       constrain( main_grid, box2, 1,7,2,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,0,0,10,0,10,0,0,0 );
  375.       constrain( main_grid, box3, 1,1,2,4, GridBagConstraints.CENTER,GridBagConstraints.NONE, 0,0,0,0,0,0,0,0 );
  376.     }
  377.     main_panel.setLayout(main_grid);
  378.  
  379.     GridBagLayout framegrid = new GridBagLayout();
  380.     constrain( framegrid, main_panel, 0,0,1,1,GridBagConstraints.CENTER,GridBagConstraints.BOTH,40,40,0,0,0,30,0,0);
  381.  
  382.     setLayout(framegrid);
  383.  
  384.     change_button.setEnabled(false);
  385.     // Give the application a chance to do its initialization
  386.     super.init();
  387.   }
  388.  
  389.   public void actionPerformed(ActionEvent event) {
  390.     Component comp=(Component)event.getSource();
  391.     if (comp == back_button) {
  392.       rolo.current--;
  393.       if (rolo.current<0)
  394.     rolo.current=rolo.getSize()-1;
  395.       updateCurrent();
  396.     }
  397.     if (comp == forward_button) {
  398.       rolo.current++;
  399.       if (rolo.getSize()==0)
  400.     rolo.current= -1;
  401.       if (rolo.current==rolo.getSize())
  402.     rolo.current=0;
  403.       updateCurrent();
  404.     }
  405.     if (comp == name_text ) {
  406.       getEntry();
  407.     }
  408.     if (comp == namelist_button    ) {
  409.       goNameDialog();
  410.     } else
  411.     if (comp == search_button ) {
  412.       goSearchDialog();
  413.     } else
  414.     if (comp == add_button ) {
  415.       addEntry();
  416.     } else
  417.     if (comp == change_button ) {
  418.       if (change_button.isEnabled()==true)
  419.     changeEntry();
  420.     } else
  421.     if (comp == clear_button ) {
  422.       clearEntry();
  423.     } else
  424.     if (comp == remove_button ) {
  425.       removeEntry();
  426.     } else
  427.     if (comp == open_button ) {
  428.       openFile();
  429.     } else
  430.     if (comp == save_button ) {
  431.       saveFile();
  432.     } else
  433.     if (comp == saveas_button ) {
  434.       saveasFile();
  435.     } else
  436.     if (comp == exit_button ) {
  437.       System.exit(0);
  438.     } else
  439.     if (comp == close_button ) {
  440.       clearAll();
  441.       clearEntry();
  442.       rolo.filename=null;
  443.     }
  444.   }
  445.  
  446.   public static void main(String[] args) {
  447.  
  448.     File file=null;
  449.     Frame f=new Frame();
  450.     namedb win=new namedb();
  451.     int num;
  452.     f.setTitle(win.strings.title());
  453.     // support passing filename commandline as well as
  454.     // -en,-fr,-nosetname,-help
  455.     for (int i=0;i<args.length;i++) {
  456.       if (args[i].startsWith("-")==false) {
  457.     file=new File(args[i]);
  458.       }
  459.       if (args[i].equals("-help")) {
  460.     System.out.println("namedb parameters:");
  461.     System.out.println("  -v1 ugly gui with English");
  462.     System.out.println("  -v2 pretty gui in French with components on right");
  463.     System.out.println("  -en English");
  464.     System.out.println("  -fr French");
  465.     System.out.println("  -help this message");
  466.     System.out.println("  -langN language where N is the number");
  467.     System.out.println("  -nosetname will not use setName");
  468.     System.out.println("  <filename> a db file to open");
  469.       }
  470.       if (args[i].equals("-nosetname")) {
  471.     win.UseSetName=false;
  472.       }
  473.       if (args[i].equals("-rolo"))
  474.     win.strings.setLang(0);
  475.       if (args[i].equals("-en"))
  476.     win.strings.setLang(1);
  477.       if (args[i].equals("-fr"))
  478.     win.strings.setLang(2);
  479.       if (args[i].equals("-ugly")) {
  480.     win.ugly=true;
  481.       }
  482.       if (args[i].equals("-right")) {
  483.     win.right=true;
  484.       }
  485.       if (args[i].equals("-v1")) {
  486.     win.ugly=true;
  487.       }
  488.       if (args[i].equals("-v2")) {
  489.     win.right=true;
  490.     win.strings.setLang(2);
  491.       }
  492.       if (args[i].startsWith("-lang")) {
  493.     try {
  494.       num=new Integer( args[i].substring(5) ).intValue();
  495.     } catch (NumberFormatException e) {
  496.       System.out.println("could not process number in: "+args[i]);
  497.       num=1;
  498.     }
  499.     win.strings.setLang(num);
  500.       }
  501.     }
  502.     win.init();
  503.     if (file!=null && file.exists()) {
  504.       win.rolo.open(file);
  505.       win.title_label.setText(win.strings.title()+" - "+file.getName());
  506.       win.main_panel.remove(win.title_label);
  507.       win.main_panel.add(win.title_label);
  508.       win.updateScreen();
  509.     }
  510.     win.theframe.add("Center",win);
  511.     win.theframe.pack();
  512.     win.theframe.show();
  513.   }
  514.  
  515.   public void constrain(GridBagLayout grid,Component comp,int gridx,int gridy,int gridwidth,int gridheight,int anchor,int fill,int ipadx,int ipady,int top,int left,int bottom,int right,double weightx,double weighty) {
  516.     GridBagConstraints con=new GridBagConstraints();
  517.     con.gridx = gridx;
  518.     con.gridy = gridy;
  519.     con.gridwidth = gridwidth;
  520.     con.gridheight = gridheight;
  521.     con.anchor = anchor;
  522.     con.fill = fill;
  523.     con.ipadx = ipadx;
  524.     con.ipady = ipady;
  525.     con.weightx=weightx;
  526.     con.weighty=weighty;
  527.     con.insets = new Insets(top,left,bottom,right);
  528.     grid.setConstraints(comp,con);
  529.   }
  530.  
  531.   public void getEntry() {
  532.     Vector res;
  533.     res=rolo.searchIt(1,name_text.getText());
  534.     if (res.size()==0)
  535.       return;
  536.     rolo.current=((Integer)res.elementAt(0)).intValue();
  537.     rolo.showEntry(rolo.current);
  538.     updateScreen();
  539.   }
  540.  
  541.   public void addEntry() {
  542.     if (name_text.getText().length()==0) {
  543.       errorDialog.doit("Add Error","Must set name to add entry");
  544.       return;
  545.     }
  546.     if (strings.getLang()>0) {
  547.       try {
  548.     rolo.processSalary( other_text.getText() );
  549.       } catch (InvalidSalary e) {
  550.     errorDialog.doit("Invalid Salary",e.toString());
  551.     return;
  552.       }
  553.     }
  554.     rolo.current =
  555.       rolo.addEntry( name_text.getText(), address1_text.getText(),
  556.              address2_text.getText(), phone_text.getText(),
  557.              email_text.getText(), other_text.getText() );
  558.     nameDialog.updateData();
  559.     updateScreen();
  560.     change_button.setEnabled(true);
  561.   }
  562.  
  563.   public void changeEntry() {
  564.     rolo.removeEntry(rolo.current);
  565.     addEntry();
  566.   }
  567.  
  568.   public void removeEntry() {
  569.     if (rolo.current== -1) return;
  570.     rolo.removeEntry(rolo.current);
  571.     if (rolo.current == rolo.getSize())
  572.       rolo.current--;
  573.     updateCurrent();
  574.   }
  575.   public void updateCurrent()
  576.   {
  577.     rolo.updateCurrent();
  578.     updateScreen();
  579.     nameDialog.updateData();
  580.     if (rolo.current== -1)
  581.       change_button.setEnabled(false);
  582.   }
  583.  
  584.   public void clearEntry() {
  585.     rolo.current= -1;
  586.     rolo.updateCurrent();
  587.     updateScreen();
  588.     change_button.setEnabled(false);
  589.   }
  590.  
  591.   public void openFile() {
  592.     fileDialog.setTitle("Open");
  593.     fileDialog.setMode(FileDialog.LOAD);
  594.     fileDialog.show();
  595.     String fdir=fileDialog.getDirectory();
  596.     String ffile=fileDialog.getFile();
  597.     if (fdir!=null && ffile!=null) {
  598.       File file=new File(fdir,ffile);
  599.       if (file.isFile()==false)
  600.     return;
  601.       clearEntry();
  602.       rolo.open(file);
  603.       nameDialog.updateData();
  604.       title_label.setText(strings.title()+" - "+file.getName());
  605.       main_panel.remove(title_label);
  606.       main_panel.add(title_label);
  607.       theframe.pack();
  608.       updateScreen();
  609.     }
  610.   }
  611.   public void saveasFile() {
  612.     fileDialog.setTitle("Save As");
  613.     fileDialog.setMode(FileDialog.SAVE);
  614.     fileDialog.show();
  615.     String fdir=fileDialog.getDirectory();
  616.     String ffile=fileDialog.getFile();
  617.     if (fdir!=null && ffile!=null) {
  618.       File file=new File(fdir,ffile);
  619.       rolo.filename=file;
  620.       rolo.save();
  621.       title_label.setText(strings.title()+" - "+file.getName());
  622.       main_panel.remove(title_label);
  623.       main_panel.add(title_label);
  624.     }
  625.   }
  626.   public void saveFile() {
  627.     if (rolo.filename!=null)
  628.       rolo.save();
  629.     else
  630.       saveasFile();
  631.   }
  632.  
  633.   public void clearAll() {
  634.     rolo=new RoloApi();
  635.     nameDialog.updateData();
  636.     searchDialog.clearsearch();
  637.     title_label.setText(strings.title()+" - Untitled");
  638.       main_panel.remove(title_label);
  639.       main_panel.add(title_label);
  640.       clearEntry();
  641.   }
  642.  
  643.   public void goNameDialog() {
  644.     nameDialog.showIt();
  645.   }
  646.  
  647.   public void goSearchDialog() {
  648.     searchDialog.clearsearch();
  649.     searchDialog.showit();
  650.   }
  651.  
  652.   public void updateScreen() {
  653.     change_button.setEnabled(true);
  654.     name_text.setText( rolo.recurrent.name );
  655.     address1_text.setText( rolo.recurrent.address1 );
  656.     address2_text.setText( rolo.recurrent.address2 );
  657.     phone_text.setText( rolo.recurrent.phone );
  658.     email_text.setText( rolo.recurrent.email );
  659.     other_text.setText( rolo.recurrent.other );
  660.     if (ugly)
  661.       index.setText(" "+(rolo.current+1)+" of "+rolo.getSize()+" ");
  662.     else
  663.       box3.setText(" "+(rolo.current+1)+" of "+rolo.getSize()+" ");
  664.   }
  665.   public RoloApi getApi() { return rolo; }
  666. }
  667.