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 Tab4A
{ private MainFrame tFrame;
  private Tab4 tTab4;

  private Action aFileGenerateChain;
  private Action aFileSaveChain;
  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 t4APanel = new JPanel();
  private JPanel t4ATPanel = new JPanel();
  private JLabel t4ATLabel = new JLabel();
  private JPanel t4ATCPanel = new JPanel();
  private JLabel t4ATCLabel = new JLabel();
  public  JTextField t4ATCTextField = new JTextField();

  private Stack t4AUndoStack = new Stack();
  private Stack t4ARedoStack = new Stack();
  private JTextArea t4ATextArea = new JTextArea();
  private JScrollPane t4AScrollPane = new JScrollPane();
  private JPanel t4ABPanel = new JPanel();
  private JLabel t4ABLLabel = new JLabel();
  private JPanel t4ABCPanel = new JPanel();
  private JLabel t4ABCLabel = new JLabel();
  private JTextField t4ABCTextField = new JTextField();
  private JLabel t4ABRLabel = new JLabel();

  private String   reSaveChainTextAreaName;
  private int      reSaveChainTextAreaCounter;
  private boolean  reSaveChainTextArea;

  Tab4A(MainFrame pMainFrame,Tab4 pTab4)
  { tFrame=pMainFrame; tTab4=pTab4;

    aFileGenerateChain = new AbstractAction("Generate Chain",new ImageIcon(Tab4A.class.getResource("generate.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Generate Chain"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_G));
    public void actionPerformed(ActionEvent e)
    { String s; boolean r=true; int i=0; try {
        s=tFrame.StringToBegin(tFrame.StringNormalize(t4ATCTextField.getText(),false));
        i=Integer.parseInt(s); if(i<0) i=-i;
      } catch(NumberFormatException ex) { r=false; }
      t4ATextArea.selectAll(); if(r) { if(tFrame.mWasp.GenerateChain(i))
        t4ATextArea.replaceSelection(tFrame.ArrayListToString(tFrame.alCurrentChain));
        else t4ATextArea.replaceSelection("Цепочку С Указаной Длиной Получить Не Удалось");
      } else t4ATextArea.replaceSelection("Ошибка При Анализе Минимальной Длины Цепочки");
      t4ATextArea.setCaretPosition(0); tFrame.alCurrentChain.clear(); }};
    aFileSaveChain = new AbstractAction("Save Chain",new ImageIcon(Tab4A.class.getResource("save.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Save Chain"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_S));
    public void actionPerformed(ActionEvent e)
    { t4ASaveChain(); }};
    aFileOpenUnicode = new AbstractAction("Open Unicode File...",new ImageIcon(Tab4A.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 (*.tsu)",".tsu",al,-1))
      { t4ATextArea.selectAll();
        t4ATextArea.replaceSelection(tFrame.ArrayListToString(al));
        t4ATextArea.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 (*.tsa)",".tsa",al,0))
      { t4ATextArea.selectAll();
        t4ATextArea.replaceSelection(tFrame.ArrayListToString(al));
        t4ATextArea.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 (*.tst)",".tst",al,1))
      { t4ATextArea.selectAll();
        t4ATextArea.replaceSelection(tFrame.ArrayListToString(al));
        t4ATextArea.setCaretPosition(0); } }};
    aFileSaveUnicode = new AbstractAction("Save Unicode File As...",new ImageIcon(Tab4A.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(t4ATextArea.getLineCount());
      tFrame.TextAreaToArrayList(t4ATextArea,al,true);
      tFrame.SaveText("Цепочка UTF-16 (*.tsu)",".tsu",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(t4ATextArea.getLineCount());
      tFrame.TextAreaToArrayList(t4ATextArea,al,true);
      tFrame.SaveText("Цепочка ANSI (*.tsa)",".tsa",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(t4ATextArea.getLineCount());
      tFrame.TextAreaToArrayList(t4ATextArea,al,true);
      tFrame.SaveText("Цепочка ASCII (*.tst)",".tst",al,1); }};
    aFileChangeWindowMode = new AbstractAction("Change Window Mode",new ImageIcon(Tab4A.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(Tab4A.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(Tab4A.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(!t4AUndoStack.empty()) { ue=(UndoableEdit)t4AUndoStack.pop(); ue.undo();
      if(ue.canRedo()) t4ARedoStack.push(ue); t4AUndoableEditUsed(); }
      if(t4AUndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
      if(t4ARedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
    }};
    aEditRedo = new AbstractAction("Redo",new ImageIcon(Tab4A.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(!t4ARedoStack.empty()) { ue=(UndoableEdit)t4ARedoStack.pop(); ue.redo();
      if(ue.canUndo()) t4AUndoStack.push(ue); t4AUndoableEditUsed(); }
      if(t4AUndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
      if(t4ARedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
    }};
    aEditCut = new AbstractAction("Cut",new ImageIcon(Tab4A.class.getResource("cut.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Cut"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_T));
    public void actionPerformed(ActionEvent e)
    { t4ATextArea.cut(); }};
    aEditCopy = new AbstractAction("Copy",new ImageIcon(Tab4A.class.getResource("copy.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Copy"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_C));
    public void actionPerformed(ActionEvent e)
    { t4ATextArea.copy(); }};
    aEditPaste = new AbstractAction("Paste",new ImageIcon(Tab4A.class.getResource("paste.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Paste"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_P));
    public void actionPerformed(ActionEvent e)
    { t4ATextArea.paste(); }};
    aEditDelete = new AbstractAction("Delete",new ImageIcon(Tab4A.class.getResource("delete.gif")))
    {{ putValue(Action.SHORT_DESCRIPTION,"Delete"); }
    // putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_D));
    public void actionPerformed(ActionEvent e)
    { t4ATextArea.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)
    { t4ATextArea.selectAll(); }};
    aHelpHelpTopics = new AbstractAction("Help Topics",new ImageIcon(Tab4A.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(0x4A); }};
    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(); }};

    t4APanel.setLayout(new BorderLayout());
    t4ATPanel.setLayout(new BorderLayout());
    t4APanel.add(t4ATPanel,BorderLayout.NORTH);
    t4ATLabel.setFont(tFrame.mFont);
    t4ATLabel.setText("  Текст Цепочки:  ");
    t4ATPanel.add(t4ATLabel,BorderLayout.WEST);
    t4ATCPanel.setLayout(new BorderLayout());
    t4ATPanel.add(t4ATCPanel,BorderLayout.CENTER);
    t4ATCLabel.setFont(tFrame.mFont);
    t4ATCLabel.setText("  Минимальная Длина Для Генерации: ");
    t4ATCPanel.add(t4ATCLabel,BorderLayout.WEST);
    t4ATCTextField.setFont(tFrame.mFont);
    t4ATCTextField.setEditable(true);
    t4ATCTextField.getCaret().setVisible(true);
    t4ATCTextField.getCaret().setSelectionVisible(true);
    t4ATCPanel.add(t4ATCTextField,BorderLayout.CENTER);
    t4AUndoStack.ensureCapacity(0x200);
    t4ARedoStack.ensureCapacity(0x10);
    t4ATextArea.setFont(tFrame.mFont);
    t4ATextArea.setTabSize(0x08);
    t4ATextArea.setEditable(true);
    t4ATextArea.getCaret().setVisible(true);
    t4ATextArea.getCaret().setSelectionVisible(true);
    t4ATextArea.getDocument().addUndoableEditListener(new UndoableEditListener()
    { public void undoableEditHappened(UndoableEditEvent e)
      { UndoableEdit ue = e.getEdit(); if(ue.canUndo()) { t4AUndoableEditHappened();
        t4AUndoStack.push(ue); t4ARedoStack.removeAllElements(); t4AUndoableEditUsed();
        if(t4AUndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
        if(t4ARedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
      } }});
    t4ATextArea.addCaretListener(new CaretListener()
    { public void caretUpdate(CaretEvent e) { DisplayCaretPosition();
      if(t4ATextArea.getSelectionEnd()-t4ATextArea.getSelectionStart()==0)
      { aEditCut.setEnabled(false); aEditCopy.setEnabled(false); aEditDelete.setEnabled(false); }
      else { aEditCut.setEnabled(true); aEditCopy.setEnabled(true); aEditDelete.setEnabled(true); } }});
    t4AScrollPane.setViewportView(t4ATextArea);
    t4APanel.add(t4AScrollPane,BorderLayout.CENTER);
    t4APanel.add(t4ABPanel,BorderLayout.SOUTH);
    t4ABPanel.setLayout(new BorderLayout());
    t4ABLLabel.setFont(tFrame.mFont);
    DisplayCaretPosition();
    t4ABPanel.add(t4ABLLabel,BorderLayout.WEST);
    t4ABLLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    t4ABPanel.add(t4ABCPanel,BorderLayout.CENTER);
    t4ABCPanel.setLayout(new BorderLayout());
    t4ABCLabel.setFont(tFrame.mFont);
    t4ABCLabel.setText("  Chain Name: ");
    t4ABCPanel.add(t4ABCLabel,BorderLayout.WEST);
    t4ABCTextField.setFont(tFrame.mFont);
    t4ABCTextField.setEditable(true);
    t4ABCTextField.getCaret().setVisible(true);
    t4ABCTextField.getCaret().setSelectionVisible(true);
    t4ABCPanel.add(t4ABCTextField,BorderLayout.CENTER);
    t4ABRLabel.setFont(tFrame.mFont);
    t4ABPanel.add(t4ABRLabel,BorderLayout.EAST);
    t4ABRLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    reSaveChainTextAreaName="";
    reSaveChainTextAreaCounter=t4AUndoStack.size();
    t4AUndoableEditUsed();
  }

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

  public void t4AUndoableEditUsed()
  {
    if(reSaveChainTextAreaCounter>=0)
      { if(reSaveChainTextAreaCounter==t4AUndoStack.size())
      reSaveChainTextArea=false; else reSaveChainTextArea=true; }
    else reSaveChainTextArea=true;
    if(reSaveChainTextArea) t4ABRLabel.setText("  MODIFIED  ");
    else t4ABRLabel.setText("            ");
  }

  public void t4AUndoableEditHappened()
  {
    if(reSaveChainTextAreaCounter>=0)
      if(t4AUndoStack.size()<reSaveChainTextAreaCounter)
        reSaveChainTextAreaCounter=-1;
  }

  public void t4ASaveChain()
  { String s; ArrayList al = new ArrayList(t4ATextArea.getLineCount());
    tFrame.TextAreaToArrayList(t4ATextArea,al,true);
    s=tFrame.StringToBegin(tFrame.StringNormalize(t4ABCTextField.getText(),false));
    if(tTab4.SaveChain(reSaveChainTextAreaName,s,al))
    { if((reSaveChainTextArea)||(!s.equals(reSaveChainTextAreaName)))
        tFrame.reSaveChains=true;
      reSaveChainTextAreaName=s;
      reSaveChainTextAreaCounter=t4AUndoStack.size();
      t4AUndoableEditUsed();
    }
  }

  public boolean tClose()
  { boolean r=true; int op; String s;
    s=tFrame.StringToBegin(tFrame.StringNormalize(t4ABCTextField.getText(),false));
    if((reSaveChainTextArea)||((!s.equals(reSaveChainTextAreaName))
      &&(!reSaveChainTextAreaName.equals("\t"))))
    { op=JOptionPane.showConfirmDialog(tFrame,
        "The current chain or its name in chain editor has been modified.\n"
        +"Do you really want to close chain 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;
      reSaveChainTextAreaName="";
      t4ATextArea.selectAll(); t4ATextArea.replaceSelection("");
      t4ABCTextField.selectAll(); t4ABCTextField.replaceSelection("");
      t4AUndoStack.removeAllElements();
      t4ARedoStack.removeAllElements();
      reSaveChainTextAreaCounter=t4AUndoStack.size();
      t4AUndoableEditUsed();
      tFrame.validate();
    } return(r);
  }

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

    i=tFrame.CurrentChainIndex;
    if((tFrame.isNew==false)&&(i>=0)
      &&(i<tFrame.alChainName.size())&&(i<tFrame.alChainText.size()))
    { reSaveChainTextAreaName=(String)tFrame.alChainName.get(i);
      t4ABCTextField.selectAll();
      t4ABCTextField.replaceSelection(reSaveChainTextAreaName);
      t4ABCTextField.setCaretPosition(0);
      t4ATextArea.selectAll();
      t4ATextArea.replaceSelection(
        tFrame.ArrayListToString((ArrayList)tFrame.alChainText.get(i)));
      t4ATextArea.setCaretPosition(0);
    } else {
      reSaveChainTextAreaName = "\t";
      t4ABCTextField.selectAll();
      t4ABCTextField.replaceSelection("New Chain");
      t4ABCTextField.setCaretPosition(0);
      t4ATextArea.selectAll();
      t4ATextArea.replaceSelection(""); }
    t4AUndoStack.removeAllElements();
    t4ARedoStack.removeAllElements();
    reSaveChainTextAreaCounter=t4AUndoStack.size();
    t4AUndoableEditUsed();
    if(t4AUndoStack.empty()) aEditUndo.setEnabled(false); else aEditUndo.setEnabled(true);
    if(t4ARedoStack.empty()) aEditRedo.setEnabled(false); else aEditRedo.setEnabled(true);
    if(t4ATextArea.getSelectionEnd()-t4ATextArea.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(aFileSaveChain).setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,Event.CTRL_MASK));
    jMenu.addSeparator();
    jMenu.add(aFileGenerateChain).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(aFileSaveChain);
    jButton.setFocusable(false); jButton.setMargin(jInsets);
    tFrame.mToolBar.addSeparator();
    jButton=tFrame.mToolBar.add(aFileGenerateChain);
    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();
  }
}
