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

public class Tab6A
{ private MainFrame tFrame;
  private Tab6 tTab6;

  private Action aFileGenerateFunctions;
  private Action aFileSaveFunctions;
  private Action aFileOpenUnicode;
  private Action aFileOpenANSI;
  private Action aFileOpenASCII;
  private Action aFileSaveUnicode;
  private Action aFileSaveANSI;
  private Action aFileSaveASCII;
  private Action aFileChangeWindowMode;
  private Action aFileClose;
  private Action aEditUndo;
  private Action aEditRedo;
  private Action aEditCut;
  private Action aEditCopy;
  private Action aEditPaste;
  private Action aEditDelete;
  private Action aEditSelectAll;
  private Action aHelpHelpTopics;
  private Action aHelpAbout;

  private JPanel t6APanel = new JPanel();
  private JLabel t6ATLabel = new JLabel();
  private Stack t6AUndoStack = new Stack();
  private Stack t6ARedoStack = new Stack();
  private JTextArea t6ATextArea = new JTextArea();
  private JScrollPane t6AScrollPane = new JScrollPane();
  private JPanel t6ABPanel = new JPanel();
  private JLabel t6ABLLabel = new JLabel();
  private JPanel t6ABCPanel = new JPanel();
  private JLabel t6ABCLabel = new JLabel();
  private JTextField t6ABCTextField = new JTextField();
  private JLabel t6ABRLabel = new JLabel();

  private String   reSaveFunctionTextAreaName;
  private int      reSaveFunctionTextAreaCounter;
  private boolean  reSaveFunctionTextArea;

  Tab6A(MainFrame pMainFrame,Tab6 pTab6)
  { tFrame=pMainFrame; tTab6=pTab6;

  aFileGenerateFunctions = new AbstractAction("Generate Functions",new ImageIcon(Tab6A.class.getResource("generate.gif")))
  {{ putValue(Action.SHORT_DESCRIPTION,"Generate Functions"); }
  // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_G));
  public void actionPerformed(ActionEvent e)
  { tFrame.mWasp.GenerateFunctions(tFrame.fk); t6ATextArea.selectAll();
    t6ATextArea.replaceSelection(
    tFrame.ArrayListToString(tFrame.alGeneratedFinctions));
    t6ATextArea.setCaretPosition(0);
    tFrame.alGeneratedFinctions.clear(); }};
    aFileSaveFunctions = new AbstractAction("Save Functions",new ImageIcon(Tab6A.class.getResource("save.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Save Finctions"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_S));
    public void actionPerformed(ActionEvent e)
    { t6ASaveFunction(); }};
    aFileOpenUnicode = new AbstractAction("Open Unicode File...",new ImageIcon(Tab6A.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(0x10);
      if(tFrame.OpenText("Функции Переходов UTF-16 (*.fnu)",".fnu",al,-1))
      { t6ATextArea.selectAll();
        t6ATextArea.replaceSelection(tFrame.ArrayListToString(al));
        t6ATextArea.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(0x10);
      if(tFrame.OpenText("Функции Переходов ANSI (*.fna)",".fna",al,0))
      { t6ATextArea.selectAll();
        t6ATextArea.replaceSelection(tFrame.ArrayListToString(al));
        t6ATextArea.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(0x10);
      if(tFrame.OpenText("Функции Переходов ASCII (*.fnc)",".fnc",al,1))
      { t6ATextArea.selectAll();
        t6ATextArea.replaceSelection(tFrame.ArrayListToString(al));
        t6ATextArea.setCaretPosition(0); } }};
    aFileSaveUnicode = new AbstractAction("Save Unicode File As...",new ImageIcon(Tab6A.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(t6ATextArea.getLineCount());
      tFrame.TextAreaToArrayList(t6ATextArea,al,true);
      tFrame.SaveText("Функции Переходов UTF-16 (*.fnu)",".fnu",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(t6ATextArea.getLineCount());
      tFrame.TextAreaToArrayList(t6ATextArea,al,true);
      tFrame.SaveText("Функции Переходов ANSI (*.fna)",".fna",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(t6ATextArea.getLineCount());
      tFrame.TextAreaToArrayList(t6ATextArea,al,true);
      tFrame.SaveText("Функции Переходов ASCII (*.fnc)",".fnc",al,1); }};
    aFileChangeWindowMode = new AbstractAction("Change Window Mode",new ImageIcon(Tab6A.class.getResource("window.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Change Window Mode"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_W));
    public void actionPerformed(ActionEvent e)
    { if(tFrame.ShowTop) { tFrame.ShowTop=false; tFrame.TopHide(); }
      else { tFrame.ShowTop=true; tFrame.TopShow(); } }};
    aFileClose = new AbstractAction("Close",new ImageIcon(Tab6A.class.getResource("close.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Close"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_L));
    public void actionPerformed(ActionEvent e)
    { tFrame.CloseBottom(); }};
    aEditUndo = new AbstractAction("Undo",new ImageIcon(Tab6A.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(!t6AUndoStack.empty()) { ue=(UndoableEdit)t6AUndoStack.pop(); ue.undo();
      if(ue.canRedo()) t6ARedoStack.push(ue); t6AUndoableEditUsed(); }
      if(t6AUndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
      if(t6ARedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
    }};
    aEditRedo = new AbstractAction("Redo",new ImageIcon(Tab6A.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(!t6ARedoStack.empty()) { ue=(UndoableEdit)t6ARedoStack.pop(); ue.redo();
      if(ue.canUndo()) t6AUndoStack.push(ue); t6AUndoableEditUsed(); }
      if(t6AUndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
      if(t6ARedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
    }};
    aEditCut = new AbstractAction("Cut",new ImageIcon(Tab6A.class.getResource("cut.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Cut"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_T));
    public void actionPerformed(ActionEvent e)
    { t6ATextArea.cut(); }};
    aEditCopy = new AbstractAction("Copy",new ImageIcon(Tab6A.class.getResource("copy.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Copy"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_C));
    public void actionPerformed(ActionEvent e)
    { t6ATextArea.copy(); }};
    aEditPaste = new AbstractAction("Paste",new ImageIcon(Tab6A.class.getResource("paste.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Paste"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_P));
    public void actionPerformed(ActionEvent e)
    { t6ATextArea.paste(); }};
    aEditDelete = new AbstractAction("Delete",new ImageIcon(Tab6A.class.getResource("delete.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Delete"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_D));
    public void actionPerformed(ActionEvent e)
    { t6ATextArea.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)
    { t6ATextArea.selectAll(); }};
    aHelpHelpTopics = new AbstractAction("Help Topics",new ImageIcon(Tab6A.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(0x6A); }};
    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(); }};

    t6APanel.setLayout(new BorderLayout());
    t6ATLabel.setFont(tFrame.mFont);
    t6ATLabel.setText("  Набор Функций Переходов:");
    t6APanel.add(t6ATLabel,BorderLayout.NORTH);
    t6AUndoStack.ensureCapacity(0x200);
    t6ARedoStack.ensureCapacity(0x10);
    t6ATextArea.setFont(tFrame.mFont);
    t6ATextArea.setTabSize(0x08);
    t6ATextArea.setEditable(true);
    t6ATextArea.getCaret().setVisible(true);
    t6ATextArea.getCaret().setSelectionVisible(true);
    t6ATextArea.getDocument().addUndoableEditListener(new UndoableEditListener()
    { public void undoableEditHappened(UndoableEditEvent e)
      { UndoableEdit ue = e.getEdit(); if(ue.canUndo()) { t6AUndoableEditHappened();
        t6AUndoStack.push(ue); t6ARedoStack.removeAllElements(); t6AUndoableEditUsed();
        if(t6AUndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
        if(t6ARedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
      } }});
    t6ATextArea.addCaretListener(new CaretListener()
    { public void caretUpdate(CaretEvent e) { DisplayCaretPosition();
      if(t6ATextArea.getSelectionEnd()-t6ATextArea.getSelectionStart()==0)
      { aEditCut.setEnabled(false); aEditCopy.setEnabled(false); aEditDelete.setEnabled(false); }
      else { aEditCut.setEnabled(true); aEditCopy.setEnabled(true); aEditDelete.setEnabled(true); } }});
    t6AScrollPane.setViewportView(t6ATextArea);
    t6APanel.add(t6AScrollPane,BorderLayout.CENTER);
    t6APanel.add(t6ABPanel,BorderLayout.SOUTH);
    t6ABPanel.setLayout(new BorderLayout());
    t6ABLLabel.setFont(tFrame.mFont);
    DisplayCaretPosition();
    t6ABPanel.add(t6ABLLabel,BorderLayout.WEST);
    t6ABLLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    t6ABPanel.add(t6ABCPanel,BorderLayout.CENTER);
    t6ABCPanel.setLayout(new BorderLayout());
    t6ABCLabel.setFont(tFrame.mFont);
    t6ABCLabel.setText("  Functions Name: ");
    t6ABCPanel.add(t6ABCLabel,BorderLayout.WEST);
    t6ABCTextField.setFont(tFrame.mFont);
    t6ABCTextField.setEditable(true);
    t6ABCTextField.getCaret().setVisible(true);
    t6ABCTextField.getCaret().setSelectionVisible(true);
    t6ABCPanel.add(t6ABCTextField,BorderLayout.CENTER);
    t6ABRLabel.setFont(tFrame.mFont);
    t6ABPanel.add(t6ABRLabel,BorderLayout.EAST);
    t6ABRLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    reSaveFunctionTextAreaName="";
    reSaveFunctionTextAreaCounter=t6AUndoStack.size();
    t6AUndoableEditUsed();
  }

  public void DisplayCaretPosition()
  { int cp,cl,clso,co;
    try { cp=t6ATextArea.getCaretPosition(); cl=t6ATextArea.getLineOfOffset(cp);
      clso=t6ATextArea.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; }
    t6ABLLabel.setText(sy+":"+sx);
  }

  public void t6AUndoableEditUsed()
  {
    if(reSaveFunctionTextAreaCounter>=0)
      { if(reSaveFunctionTextAreaCounter==t6AUndoStack.size())
      reSaveFunctionTextArea=false; else reSaveFunctionTextArea=true; }
    else reSaveFunctionTextArea=true;
    if(reSaveFunctionTextArea) t6ABRLabel.setText("  MODIFIED  ");
    else t6ABRLabel.setText("            ");
  }

  public void t6AUndoableEditHappened()
  {
    if(reSaveFunctionTextAreaCounter>=0)
      if(t6AUndoStack.size()<reSaveFunctionTextAreaCounter)
        reSaveFunctionTextAreaCounter=-1;
  }

  public void t6ASaveFunction()
  { String s; ArrayList al = new ArrayList(t6ATextArea.getLineCount());
    tFrame.TextAreaToArrayList(t6ATextArea,al,true);
    s=tFrame.StringToBegin(tFrame.StringNormalize(t6ABCTextField.getText(),false));
    if(tTab6.SaveFunction(reSaveFunctionTextAreaName,s,al))
    { if((reSaveFunctionTextArea)||(!s.equals(reSaveFunctionTextAreaName)))
        tFrame.reSaveFunctions=true;
      reSaveFunctionTextAreaName=s;
      reSaveFunctionTextAreaCounter=t6AUndoStack.size();
      t6AUndoableEditUsed();
    }
  }

  public boolean tClose()
  { boolean r=true; int op; String s;
    s=tFrame.StringToBegin(tFrame.StringNormalize(t6ABCTextField.getText(),false));
    if((reSaveFunctionTextArea)||((!s.equals(reSaveFunctionTextAreaName))
      &&(!reSaveFunctionTextAreaName.equals("\t"))))
    { op=JOptionPane.showConfirmDialog(tFrame,
        "The current functions or theirs name in function editor have been modified.\n"
        +"Do you really want to close function editor?","Close",
        JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
      if(op!=JOptionPane.YES_OPTION) r=false;
    } if(r) {
      tFrame.mMenuBar.removeAll();
      tFrame.mToolBar.removeAll();
      tFrame.mSplitPane.setBottomComponent(null);
      tFrame.isNew=true;
      reSaveFunctionTextAreaName="";
      t6ATextArea.selectAll(); t6ATextArea.replaceSelection("");
      t6ABCTextField.selectAll(); t6ABCTextField.replaceSelection("");
      t6AUndoStack.removeAllElements();
      t6ARedoStack.removeAllElements();
      reSaveFunctionTextAreaCounter=t6AUndoStack.size();
      t6AUndoableEditUsed();
      tFrame.validate();
    } return(r);
  }

  public void tOpen()
  { int i;
    tFrame.mSplitPane.setBottomComponent(t6APanel);

    i=tFrame.CurrentFunctionIndex;
    if((tFrame.isNew==false)&&(i>=0)
      &&(i<tFrame.alFunctionName.size())&&(i<tFrame.alFunctionText.size()))
    { reSaveFunctionTextAreaName=(String)tFrame.alFunctionName.get(i);
      t6ABCTextField.selectAll();
      t6ABCTextField.replaceSelection(reSaveFunctionTextAreaName);
      t6ABCTextField.setCaretPosition(0);
      t6ATextArea.selectAll();
      t6ATextArea.replaceSelection(
        tFrame.ArrayListToString((ArrayList)tFrame.alFunctionText.get(i)));
      t6ATextArea.setCaretPosition(0);
    } else {
      reSaveFunctionTextAreaName = "\t";
      t6ABCTextField.selectAll();
      t6ABCTextField.replaceSelection("New Functions");
      t6ABCTextField.setCaretPosition(0);
      t6ATextArea.selectAll();
      t6ATextArea.replaceSelection(""); }
    t6AUndoStack.removeAllElements();
    t6ARedoStack.removeAllElements();
    reSaveFunctionTextAreaCounter=t6AUndoStack.size();
    t6AUndoableEditUsed();
    if(t6AUndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
    if(t6ARedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
    if(t6ATextArea.getSelectionEnd()-t6ATextArea.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(aFileSaveFunctions).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,Event.CTRL_MASK));
    jMenu.addSeparator();
    jMenu.add(aFileGenerateFunctions).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G,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(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(aFileChangeWindowMode).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W,Event.ALT_MASK));
    jMenu.addSeparator();
    jMenu.add(aFileClose).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,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 = 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(aFileSaveFunctions);
    jButton.setFocusable(false); jButton.setMargin(jInsets);
    tFrame.mToolBar.addSeparator();
    jButton=tFrame.mToolBar.add(aFileGenerateFunctions);
    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(aFileChangeWindowMode);
    jButton.setFocusable(false); jButton.setMargin(jInsets);
    tFrame.mToolBar.addSeparator();
    jButton=tFrame.mToolBar.add(aFileClose);
    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();
  }
}
