static void addTab(final JTabbedPane tp,File file) throws IOException {
    //JEditorPane ep = new JEditorPane();
    JTextArea ep = new JTextArea();
    TextLineNumber tln = new TextLineNumber(ep);
   
    ImageIcon icon;
    JLabel label;
    icon = createImageIcon("images/unsaved.png");
    label = new JLabel("New");
    ep.setFont(new Font("Courier New", 0,18));
    boolean flagOld = false;
    String urlFile = null;
    if(file!=null ){
        if(file.getName()!=""){
            icon = createImageIcon("images/saved.png");
            label = new JLabel(file.getName());
            urlFile = file.getPath();
            ep.setText(fileManagement.readFile(file));
            System.out.println(fileManagement.readFile(file));
        }
        flagOld = true;
    }
    
    ep.setEditable(true);

    
    
    DocumentListener dl;
    dl = new DocumentListener(){
        
        public void insertUpdate(DocumentEvent e) {
            JPanel pnlTab = (JPanel)some.tabs.getTabComponentAt(some.tabs.getSelectedIndex());
            ImageIcon iconjl = null;
            try {
                iconjl = iconjl = createImageIcon("images/unsaved.png");
            } catch (IOException ex) {
                Logger.getLogger(TabPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
            JPanel pnl = new JPanel();
            pnl.setOpaque(false);
            pnlTab.remove(0);
            pnl.add(new JLabel(iconjl));
            pnl.add(pnlTab.getComponent(0));
            pnl.add(pnlTab.getComponent(0));
            some.tabs.setTabComponentAt(some.tabs.getSelectedIndex(), pnl);
        }
        public void removeUpdate(DocumentEvent e) {
            JPanel pnlTab = (JPanel)some.tabs.getTabComponentAt(some.tabs.getSelectedIndex());
            ImageIcon iconjl = null;
            try {
                iconjl = iconjl = createImageIcon("images/unsaved.png");
            } catch (IOException ex) {
                Logger.getLogger(TabPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
            JPanel pnl = new JPanel();
            pnl.setOpaque(false);
            pnlTab.remove(0);
            pnl.add(new JLabel(iconjl));
            pnl.add(pnlTab.getComponent(0));
            pnl.add(pnlTab.getComponent(0));
            some.tabs.setTabComponentAt(some.tabs.getSelectedIndex(), pnl);
        }
        public void changedUpdate(DocumentEvent e) {
            //Plain text components don't fire these events.
        }
    };
    ep.getDocument().addDocumentListener(dl);
    
    
    
    JScrollPane jScroll = new JScrollPane(ep);
    jScroll.setRowHeaderView( tln );
    tp.addTab(null, jScroll);

    JButton tabCloseButton =  ButtonPro("images/closeTabButton.png","Close");
    tabCloseButton.setActionCommand("" + (tabCounter));
    hmAreas.put(tabCounter, new Triplet(urlFile,flagOld,ep));
        
    ActionListener al;
    al = new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent ae) {
        JButton btn = (JButton) ae.getSource();
        String s1 = btn.getActionCommand();
        for (int i = 0; i < tp.getTabCount(); i++) {
          JPanel pnl = (JPanel) tp.getTabComponentAt(i);
          btn = (JButton) pnl.getComponent(2);
          String s2 = btn.getActionCommand();
          System.out.println(s1 + " - " + s2);
          if (s1.equals(s2)) {
            tp.removeTabAt(i);
            break;
          }
        }
      }
    };
    tabCloseButton.addActionListener(al);
    
    if (tabCounter != 0) {
      JPanel pnl = new JPanel();
      pnl.setOpaque(false);
      
      JLabel picLabel = new JLabel(icon);
      pnl.add(picLabel);
      pnl.add(label);
      pnl.add(tabCloseButton);
      
      tp.setTabComponentAt(tp.getTabCount() - 1, pnl);
      tp.setSelectedIndex(tp.getTabCount() - 1);
    }
    
    tabCounter++;
    if(flagOld){
        final JPanel pnlTab = (JPanel)some.tabs.getTabComponentAt(some.tabs.getTabCount () - 2);
        some.tabs.remove(some.tabs.getTabCount () - 2);
        JEditorPane jEditor = new JEditorPane();
        jEditor.setEditable(false);
        some.tabs.addTab(null,new JScrollPane(jEditor));
        tabCounter++;
        some.tabs.setTabComponentAt (some.tabs.getTabCount () - 1, pnlTab);
    }
  }