package osa;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.undo.*;

public class Tab1
{
  private MainFrame tFrame;
  private BorderLayout tBorderLayout = new BorderLayout();
  private Action aFileNewProject;
  private Action aFileOpenProject;
  private Action aFileOpenUnicode;
  private Action aFileOpenANSI;
  private Action aFileOpenASCII;
  private Action aFileSaveProject;
  private Action aFileSaveProjectAs;
  private Action aFileSaveUnicode;
  private Action aFileSaveANSI;
  private Action aFileSaveASCII;
  private Action aFileExit;
  public  Action aEditUndo;
  public  Action aEditRedo;
  public  Action aEditCut;
  public  Action aEditCopy;
  private Action aEditPaste;
  public  Action aEditDelete;
  private Action aEditSelectAll;
  private Action aEditToLowerCase;
  private Action aHelpHelpTopics;
  private Action aHelpAbout;

  private JPanel t1Panel = new JPanel();
  private BorderLayout t1BorderLayout = new BorderLayout();
  private JLabel t1TLabel = new JLabel();
  public  Stack t1UndoStack = new Stack();
  public  Stack t1RedoStack = new Stack();
  public  editor.Editor t1TextArea = null;
  private JScrollPane t1ScrollPane = new JScrollPane();
  private JPanel t1BPanel = new JPanel();
  private BorderLayout t1BBorderLayout = new BorderLayout();
  private JLabel t1BLLabel = new JLabel();
  private JButton t1BCButton = new JButton();
  private JLabel t1BRLabel = new JLabel();

  public Tab1(MainFrame pMainFrame)
  {
    tFrame=pMainFrame;
    tFrame.mPanel1.setLayout(tBorderLayout);
    t1TextArea = new editor.Editor(tFrame.mFont.getSize());

    aFileNewProject = new AbstractAction("New Project",new ImageIcon(Tab1.class.getResource("new.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"New Project"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_N));
    public void actionPerformed(ActionEvent e)
    { tFrame.FileNewProject(); }};
    aFileOpenProject = new AbstractAction("Open Project...",new ImageIcon(Tab1.class.getResource("open.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Open Project..."); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_O));
    public void actionPerformed(ActionEvent e)
    { tFrame.FileOpenProject(); }};
    aFileOpenUnicode = new AbstractAction("Open Unicode File...",new ImageIcon(Tab1.class.getResource("uopen.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Open Unicode File..."); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_D));
    public void actionPerformed(ActionEvent e)
    { ArrayList al = new ArrayList(0x400);
      if(tFrame.OpenText("Ãðàììàòèêà UTF-16 (*.gru)",".gru",al,-1))
      { t1TextArea.selectAll();
        t1TextArea.replaceSelection(tFrame.ArrayListToString(al));
        t1TextArea.setCaretPosition(0); } }};
    aFileOpenANSI = new AbstractAction("Open ANSI File...")
    {{ putValue(Action.SHORT_DESCRIPTION,"Open ANSI File..."); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_P));
    public void actionPerformed(ActionEvent e)
    { ArrayList al = new ArrayList(0x400);
      if(tFrame.OpenText("Ãðàììàòèêà ANSI (*.gra)",".gra",al,0))
      { t1TextArea.selectAll();
        t1TextArea.replaceSelection(tFrame.ArrayListToString(al));
        t1TextArea.setCaretPosition(0); } }};
    aFileOpenASCII = new AbstractAction("Open ASCII File...")
    {{ putValue(Action.SHORT_DESCRIPTION,"Open ASCII File..."); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_E));
    public void actionPerformed(ActionEvent e)
    { ArrayList al = new ArrayList(0x400);
      if(tFrame.OpenText("Ãðàììàòèêà ASCII (*.grm)",".grm",al,1))
      { t1TextArea.selectAll();
        t1TextArea.replaceSelection(tFrame.ArrayListToString(al));
        t1TextArea.setCaretPosition(0); } }};
    aFileSaveProject = new AbstractAction("Save Project",new ImageIcon(Tab1.class.getResource("save.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Save Project"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_S));
    public void actionPerformed(ActionEvent e)
    { tFrame.FileSaveProject(); }};
    aFileSaveProjectAs = new AbstractAction("Save Project As...",new ImageIcon(Tab1.class.getResource("saveas.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Save Project As..."); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_A));
    public void actionPerformed(ActionEvent e)
    { tFrame.FileSaveProjectAs(); }};
    aFileSaveUnicode = new AbstractAction("Save Unicode File As...",new ImageIcon(Tab1.class.getResource("usave.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Save Unicode File As..."); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_U));
    public void actionPerformed(ActionEvent e)
    { ArrayList al = new ArrayList(t1TextArea.getLineCount());
      tFrame.TextAreaToArrayList(t1TextArea,al,true);
      tFrame.SaveText("Ãðàììàòèêà UTF-16 (*.gru)",".gru",al,-1); }};
    aFileSaveANSI = new AbstractAction("Save ANSI File As...")
    {{ putValue(Action.SHORT_DESCRIPTION,"Save ANSI File As..."); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_I));
    public void actionPerformed(ActionEvent e)
    { ArrayList al = new ArrayList(t1TextArea.getLineCount());
      tFrame.TextAreaToArrayList(t1TextArea,al,true);
      tFrame.SaveText("Ãðàììàòèêà ANSI (*.gra)",".gra",al,0); }};
    aFileSaveASCII = new AbstractAction("Save ASCII File As...")
    {{ putValue(Action.SHORT_DESCRIPTION,"Save ASCII File As..."); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_C));
    public void actionPerformed(ActionEvent e)
    { ArrayList al = new ArrayList(t1TextArea.getLineCount());
      tFrame.TextAreaToArrayList(t1TextArea,al,true);
      tFrame.SaveText("Ãðàììàòèêà ASCII (*.grm)",".grm",al,1); }};
    aFileExit = new AbstractAction("Exit")
    {{ putValue(Action.SHORT_DESCRIPTION,"Exit"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_X));
    public void actionPerformed(ActionEvent e)
    { tFrame.FileExit(); }};
    aEditUndo = new AbstractAction("Undo",new ImageIcon(Tab1.class.getResource("undo.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Undo"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_U));
    public void actionPerformed(ActionEvent e)
    { UndoableEdit ue;
      if(!t1UndoStack.empty()) { ue=(UndoableEdit)t1UndoStack.pop(); ue.undo();
      if(ue.canRedo()) t1RedoStack.push(ue); t1UndoableEditUsed(); }
      if(t1UndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
      if(t1RedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
    }};
    aEditRedo = new AbstractAction("Redo",new ImageIcon(Tab1.class.getResource("redo.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Redo"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_R));
    public void actionPerformed(ActionEvent e)
    { UndoableEdit ue;
      if(!t1RedoStack.empty()) { ue=(UndoableEdit)t1RedoStack.pop(); ue.redo();
      if(ue.canUndo()) t1UndoStack.push(ue); t1UndoableEditUsed(); }
      if(t1UndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
      if(t1RedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
    }};
    aEditCut = new AbstractAction("Cut",new ImageIcon(Tab1.class.getResource("cut.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Cut"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_T));
    public void actionPerformed(ActionEvent e)
    { t1TextArea.cut(); }};
    aEditCopy = new AbstractAction("Copy",new ImageIcon(Tab1.class.getResource("copy.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Copy"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_C));
    public void actionPerformed(ActionEvent e)
    { t1TextArea.copy(); }};
    aEditPaste = new AbstractAction("Paste",new ImageIcon(Tab1.class.getResource("paste.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Paste"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_P));
    public void actionPerformed(ActionEvent e)
    { t1TextArea.paste(); }};
    aEditDelete = new AbstractAction("Delete",new ImageIcon(Tab1.class.getResource("delete.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Delete"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_D));
    public void actionPerformed(ActionEvent e)
    { t1TextArea.replaceSelection(""); }};
    aEditSelectAll = new AbstractAction("Select All")
    {{ putValue(Action.SHORT_DESCRIPTION,"Select All"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_A));
    public void actionPerformed(ActionEvent e)
    { t1TextArea.selectAll(); }};
    aEditToLowerCase = new AbstractAction("All Text To Lower Case")
    {{ putValue(Action.SHORT_DESCRIPTION,"All Text To Lower Case"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_L));
    public void actionPerformed(ActionEvent e)
    { ArrayList al = new ArrayList(t1TextArea.getLineCount());
      tFrame.TextAreaToArrayList(t1TextArea,al,true);
      t1TextArea.selectAll();
      t1TextArea.replaceSelection(tFrame.ArrayListToString(al).toLowerCase());
      t1TextArea.setCaretPosition(0); al.clear(); }};
    aHelpHelpTopics = new AbstractAction("Help Topics",new ImageIcon(Tab1.class.getResource("help.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Help Topics"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_H));
    public void actionPerformed(ActionEvent e)
    { tFrame.HelpHelpTopics(0x1); }};
    aHelpAbout = new AbstractAction("About...")
    {{ putValue(Action.SHORT_DESCRIPTION,"About..."); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_A));
    public void actionPerformed(ActionEvent e)
    { tFrame.HelpAbout(); }};

    t1Panel.setLayout(t1BorderLayout);
    t1TLabel.setFont(tFrame.mFont);
    t1TLabel.setText("  Òåêñò Ãðàììàòèêè:");
    t1Panel.add(t1TLabel,BorderLayout.NORTH);
    t1UndoStack.ensureCapacity(0x2000);
    t1RedoStack.ensureCapacity(0x100);
    t1TextArea.setFont(tFrame.mFont);
    t1TextArea.setTabSize(0x08);
    t1TextArea.getDocument().addUndoableEditListener(new UndoableEditListener()
    { public void undoableEditHappened(UndoableEditEvent e)
      { UndoableEdit ue = e.getEdit(); if(ue.canUndo()) { t1UndoableEditHappened();
        t1UndoStack.push(ue); t1RedoStack.removeAllElements(); t1UndoableEditUsed();
        if(t1UndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
        if(t1RedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
      } }});

    t1TextArea.addCaretListener
      (
      new CaretListener()
        {
        public void caretUpdate(CaretEvent e)
          {
          DisplayCaretPosition();
         if(t1TextArea.getSelectionEnd()-t1TextArea.getSelectionStart()==0)
           {
           aEditCut.setEnabled(false);
           aEditCopy.setEnabled(false);
           aEditDelete.setEnabled(false);
           }
         else
           {
           aEditCut.setEnabled(true);
           aEditCopy.setEnabled(true);
           aEditDelete.setEnabled(true);
           }
         }
        }
      );

    t1ScrollPane.setViewportView(t1TextArea);
    t1Panel.add(t1ScrollPane,BorderLayout.CENTER);
    t1Panel.add(t1BPanel,BorderLayout.SOUTH);
    t1BPanel.setLayout(t1BBorderLayout);
    t1BLLabel.setFont(tFrame.mFont);
    DisplayCaretPosition();
    t1BPanel.add(t1BLLabel,BorderLayout.WEST);
    t1BLLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    t1BCButton.setFont(tFrame.mFont);
    t1BPanel.add(t1BCButton,BorderLayout.CENTER);
    t1BCButton.setFocusable(false);
    t1BCButton.addActionListener(new ActionListener()
    { public void actionPerformed(ActionEvent e)
      { if(tFrame.reAnalyse) tFrame.Analyse(); }});
    t1BRLabel.setFont(tFrame.mFont);
    t1BPanel.add(t1BRLabel,BorderLayout.EAST);
    t1BRLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    tFrame.reSaveMainTextAreaCounter=t1UndoStack.size();
    tFrame.reAnalyseCounter=-1;
    t1UndoableEditUsed();
  }

  public void DisplayCaretPosition()
  { int cp,cl,clso,co;
    try { cp=t1TextArea.getCaretPosition(); cl=t1TextArea.getLineOfOffset(cp);
      clso=t1TextArea.getLineStartOffset(cl); co=cp-clso; }
    catch(Exception e)  { co=0; cl=0; }
    int lx,ly; String sx,sy;
    String cxs = new String(Integer.toString(co+1)); lx=cxs.length();
    String cys = new String(Integer.toString(cl+1)); ly=cys.length();
    switch(lx)
    { case 1: sx=new String(cxs+"     "); break;
      case 2: sx=new String(cxs+ "    "); break;
      case 3: sx=new String(cxs+  "   "); break;
      case 4: sx=new String(cxs+   "  "); break;
      case 5: sx=new String(cxs+    " "); break;
      case 6: sx=new String(cxs        ); break;
      default:sx=new String(   "      "); break; }
    switch(ly)
    { case 1: sy=new String("     " +cys); break;
      case 2: sy=new String("    "  +cys); break;
      case 3: sy=new String("   "   +cys); break;
      case 4: sy=new String("  "    +cys); break;
      case 5: sy=new String(" "     +cys); break;
      case 6: sy=new String(         cys); break;
      default:sy=new String("      "    ); break; }
    t1BLLabel.setText(sy+":"+sx);
  }

  public void t1UndoableEditUsed()
  {
    if(tFrame.reSaveMainTextAreaCounter>=0)
      { if(tFrame.reSaveMainTextAreaCounter==t1UndoStack.size())
      tFrame.reSaveMainTextArea=false; else tFrame.reSaveMainTextArea=true; }
    else tFrame.reSaveMainTextArea=true;
    if(tFrame.reSaveMainTextArea) t1BRLabel.setText("  MODIFIED  ");
    else t1BRLabel.setText("            ");
    if(tFrame.reAnalyseCounter>=0)
      { if(tFrame.reAnalyseCounter==t1UndoStack.size())
      tFrame.reAnalyse=false; else tFrame.reAnalyse=true; }
    else tFrame.reAnalyse=true;
    if(tFrame.reAnalyse) t1BCButton.setText("ÑÎÑÒÎßÍÈÅ ÃÐÀÌÌÀÒÈÊÈ ÍÅ ÎÖÅÍÈÂÀËÎÑÜ");
    else switch(tFrame.AnalyseReturn)
    { case 0: t1BCButton.setText("ÑÎÑÒÎßÍÈÅ ÃÐÀÌÌÀÒÈÊÈ ÎÏÐÅÄÅËÈÒÜ ÍÅ ÓÄÀËÎÑÜ"); break;
      case 1: t1BCButton.setText("Â ÃÐÀÌÌÀÒÈÊÅ ÎÁÍÀÐÓÆÅÍÛ ÑÈÍÒÀÊÑÈ×ÅÑÊÈÅ ÎØÈÁÊÈ"); break;
      case 2: t1BCButton.setText("ÃÐÀÌÌÀÒÈÊÀ ÍÅ ÏÐÈÂÅÄÅÍÀ"); break;
      case 3: t1BCButton.setText("ÍÀÉÄÅÍÛ ÊÎÍÔËÈÊÒÛ - ÃÐÀÌÌÀÒÈÊÀ ÍÅ LL(1)"); break;
      case 4: t1BCButton.setText("ÃÐÀÌÌÀÒÈÊÀ ÎÒÍÎÑÈÒÑß Ê ÊËÀÑÑÓ LL(1)"); break; }
  }

  public void t1UndoableEditHappened()
  {
    if(tFrame.reSaveMainTextAreaCounter>=0)
      if(t1UndoStack.size()<tFrame.reSaveMainTextAreaCounter)
        tFrame.reSaveMainTextAreaCounter=-1;
    if(tFrame.reAnalyseCounter>=0)
      if(t1UndoStack.size()<tFrame.reAnalyseCounter)
        tFrame.reAnalyseCounter=-1;
  }

  public void tDeSelect()
  { if(!tFrame.isBottomComponentActive)
    { tFrame.mMenuBar.removeAll();
      tFrame.mToolBar.removeAll(); }
    tFrame.mPanel1.removeAll();
    tFrame.validate(); }

  public void tSelect()
  { tFrame.mPanel1.add(t1Panel,BorderLayout.CENTER);
    if(tFrame.isBottomComponentActive)
    { t1TextArea.setEditable(false);
      t1TextArea.getCaret().setVisible(false);
      t1TextArea.getCaret().setSelectionVisible(true); }
    else
    { t1TextArea.setEditable(true);
      t1TextArea.getCaret().setVisible(true);
      t1TextArea.getCaret().setSelectionVisible(true);
      if(t1UndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
      if(t1RedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
      if(t1TextArea.getSelectionEnd()-t1TextArea.getSelectionStart()==0)
      { aEditCut.setEnabled(false); aEditCopy.setEnabled(false); aEditDelete.setEnabled(false); }
      else { aEditCut.setEnabled(true); aEditCopy.setEnabled(true); aEditDelete.setEnabled(true); }
      JMenu jMenu;
      jMenu = new JMenu("File");
      jMenu.setMnemonic(KeyEvent.VK_F);
      tFrame.mMenuBar.add(jMenu);
      jMenu.add(aFileNewProject).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,Event.CTRL_MASK));
      jMenu.add(aFileOpenProject).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,Event.CTRL_MASK));
      jMenu.addSeparator();
      jMenu.add(aFileOpenUnicode).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U,Event.CTRL_MASK|Event.ALT_MASK));
      jMenu.add(aFileOpenANSI).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,Event.CTRL_MASK|Event.ALT_MASK));
      jMenu.add(aFileOpenASCII).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,Event.CTRL_MASK|Event.ALT_MASK));
      jMenu.addSeparator();
      jMenu.add(aFileSaveProject).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,Event.CTRL_MASK));
      jMenu.add(aFileSaveProjectAs).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,Event.CTRL_MASK|Event.SHIFT_MASK));
      jMenu.addSeparator();
      jMenu.add(aFileSaveUnicode).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U,Event.CTRL_MASK|Event.SHIFT_MASK));
      jMenu.add(aFileSaveANSI).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,Event.CTRL_MASK|Event.SHIFT_MASK));
      jMenu.add(aFileSaveASCII).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,Event.CTRL_MASK|Event.SHIFT_MASK));
      jMenu.addSeparator();
      jMenu.add(aFileExit).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,Event.ALT_MASK));
      jMenu = new JMenu("Edit");
      jMenu.setMnemonic(KeyEvent.VK_E);
      tFrame.mMenuBar.add(jMenu);
      jMenu.add(aEditUndo).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z,Event.CTRL_MASK));
      jMenu.add(aEditRedo).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z,Event.CTRL_MASK|Event.SHIFT_MASK));
      jMenu.addSeparator();
      jMenu.add(aEditCut).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,Event.CTRL_MASK));
      jMenu.add(aEditCopy).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,Event.CTRL_MASK));
      jMenu.add(aEditPaste).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,Event.CTRL_MASK));
      jMenu.add(aEditDelete).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0));
      jMenu.addSeparator();
      jMenu.add(aEditSelectAll).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,Event.CTRL_MASK));
      jMenu.addSeparator();
      jMenu.add(aEditToLowerCase).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,Event.CTRL_MASK));
      jMenu = new JMenu("Help");
      jMenu.setMnemonic(KeyEvent.VK_H);
      tFrame.mMenuBar.add(jMenu);
      jMenu.add(aHelpHelpTopics).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1,0));
      jMenu.addSeparator();
      jMenu.add(aHelpAbout);//.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,Event.ALT_MASK));
      JButton jButton; Insets jInsets=new Insets(2,2,2,2);
      jButton=tFrame.mToolBar.add(aFileNewProject);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
      jButton=tFrame.mToolBar.add(aFileOpenProject);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
      jButton=tFrame.mToolBar.add(aFileSaveProject);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
      jButton=tFrame.mToolBar.add(aFileSaveProjectAs);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
      tFrame.mToolBar.addSeparator();
      jButton=tFrame.mToolBar.add(aFileOpenUnicode);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
      jButton=tFrame.mToolBar.add(aFileSaveUnicode);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
      tFrame.mToolBar.addSeparator();
      jButton=tFrame.mToolBar.add(aEditUndo);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
      jButton=tFrame.mToolBar.add(aEditRedo);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
      tFrame.mToolBar.addSeparator();
      jButton=tFrame.mToolBar.add(aEditCut);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
      jButton=tFrame.mToolBar.add(aEditCopy);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
      jButton=tFrame.mToolBar.add(aEditPaste);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
      jButton=tFrame.mToolBar.add(aEditDelete);
      jButton.setFocusable(false); jButton.setMargin(jInsets);
    }
    tFrame.validate();
  }
}
