#encoding: UTF-8
require 'conectaTelnet'
require 'includes'

class Main

  #puts "01class Main"
  include ActionListener
  include WindowListener
  include ChangeListener
  include java.lang.Runnable

  def initialize
    #puts "02class Main.initialize"
    @delay = 500
    @timer = Timer.new(@delay, self)
    @timer.setCoalesce(true)
    $id = 0
    $flag_download_confirm = true
    $id_download_confirm = nil
    $paused = false
    $size = ""
    $downloaded = ""
    $priority = ""
    $option = 0
    $content_pane_prev_wsize  = 0
    $content_pane_prev_hsize  = 0
    $server_all = true
    $user_index_ant = Array.new
    $group_index_ant = Array.new
    $share_index_ant = Array.new

  end # initialize

  def createContentPane
    #puts "03class Main.createContentPane"
    $content_pane = JPanel.new
    $content_pane.addComponentListener(Content_pane_event.new)
    $content_pane.setLayout nil 

    #### creamos el contenedor del mensaje de conexion   pte refactorizar
    @cadena_conected = javax.swing.JLabel.new
    @cadena_conected.setText("Connected to Mldonkey")
    @cadena_conected.setFont(Font.new "Arial", Font::BOLD, 40)

    @cadena_conected2 = javax.swing.JLabel.new
    @cadena_conected2.setText("Connected to Mldonkey")
    @cadena_conected2.setFont(Font.new "Arial", Font::BOLD, 40)


    $conected = JScrollPane.new
    $conected.setLayout nil
    $conected.setOpaque false
    $conected.add(@cadena_conected)
    @cadena_conected.setForeground(Color.white)

    $conected.add(@cadena_conected2)
    @cadena_conected2.setForeground(Color.black)



    #### creamos el contenedor de las descargas.        pte refactorizar
    $modelo = Modelo.new
    $tabla = JTable.new $modelo
    $tabla.setForeground(Color.white)
    $tabla.setFont(Font.new case RbConfig::CONFIG['host_os'] when /mswin/; "Arial Unicode MS" when /darwin/; "AppleGothic, Arial" end, Font::PLAIN, 12)
    $lista = JScrollPane.new($tabla)


    #### creamos el contenedor para el detalle de las descargas
    @net_details = javax.swing.JLabel.new
    @net_details_show = javax.swing.JLabel.new
    @id_details = javax.swing.JLabel.new
    @id_details_show = javax.swing.JLabel.new 
    @file_name_details = javax.swing.JLabel.new
    @file_name_details_show = javax.swing.JLabel.new
    @urn_link_details =  javax.swing.JLabel.new
    @urn_link_details_show =  javax.swing.JLabel.new
    @size_details = javax.swing.JLabel.new
    @size_details_show = javax.swing.JLabel.new
    @downloaded_details = javax.swing.JLabel.new
    @downloaded_details_show = javax.swing.JLabel.new
    @priority_details = javax.swing.JLabel.new
    @priority_details_show = javax.swing.JLabel.new
    @status_details = javax.swing.JLabel.new
    @status_details_points = javax.swing.JLabel.new
    @status_details_show = Canvas.new
    @probable_name_details = javax.swing.JLabel.new
    @probable_name_details_show = javax.swing.JLabel.new 
    @probable_name_details_show_s = JScrollPane.new(@probable_name_details_show)
    @probable_name_details_show_s.setOpaque false
    @probable_name_details_show.setBorder javax.swing.BorderFactory.createEmptyBorder
    @probable_name_details_show.setHorizontalAlignment(javax.swing.SwingConstants::LEFT)
    @probable_name_details_show.setVerticalAlignment(javax.swing.SwingConstants::TOP)
    @probable_name_details_show_s.setBorder javax.swing.BorderFactory.createEmptyBorder
    
    @downloads_details = JPanel.new
    @downloads_details.setLayout nil
    @downloads_details.setOpaque false
    @downloads_details.add(@net_details)
    @downloads_details.add(@net_details_show)
    @downloads_details.add(@id_details)
    @downloads_details.add(@id_details_show)
    @downloads_details.add(@file_name_details)
    @downloads_details.add(@file_name_details_show)
    @downloads_details.add(@urn_link_details)
    @downloads_details.add(@urn_link_details_show)
    @downloads_details.add(@size_details)
    @downloads_details.add(@size_details_show)
    @downloads_details.add(@downloaded_details)
    @downloads_details.add(@downloaded_details_show)
    @downloads_details.add(@priority_details)
    @downloads_details.add(@priority_details_show)
    @downloads_details.add(@status_details)
    @downloads_details.add(@status_details_points)
    @downloads_details.add(@status_details_show)
    @downloads_details.add(@probable_name_details)
    @downloads_details.add(@probable_name_details_show_s)
    
    @downloads_details.setForeground(Color.white)
    @downloads_details.setBackground(Color.black)
    
    $downloads_details_w_scroll = JScrollPane.new(@downloads_details)
    
    $downloads_details_bar_label1 = javax.swing.JLabel.new
    $downloads_details_bar_label1.setText("Actions : ")
    $downloads_details_bar_label1.setBounds 90,0,60,25
    
    $downloads_details_bar_button1 = javax.swing.JButton.new
    $downloads_details_bar_button1.setBounds 155,0,100,25
    
    $downloads_details_bar_button2 = javax.swing.JButton.new "Cancel"
    $downloads_details_bar_button2.setBounds 255,0,100,25
    
    $downloads_details_bar_button3 = javax.swing.JButton.new "Resume All"
    $downloads_details_bar_button3.setBounds 355,0,100,25
    
    $downloads_details_bar_button4 = javax.swing.JButton.new "Pause All"
    $downloads_details_bar_button4.setBounds 455,0,100,25

    $downloads_details_bar_label2 = javax.swing.JLabel.new
    $downloads_details_bar_label2.setText("Priority : ")
    $downloads_details_bar_label2.setBounds  640,0,60,25    
    
    @prio_type = javax.swing.JComboBox.new(["Normal","Low ","Very low","High","Very High"].to_java)
    @prio_type.setBounds 700,0,95,25                 
                                                     
    $downloads_details_bar = JScrollPane.new         
    $downloads_details_bar.setLayout nil

    @icon_back_downloads_details_bar = ImageIcon.new "fondo_03.png"
    @back_downloads_details_bar = JLabel.new @icon_back_downloads_details_bar
    
    $downloads_details_bar.add($downloads_details_bar_label1)
    $downloads_details_bar.add($downloads_details_bar_label2)
    
    $downloads_details_bar.add($downloads_details_bar_button1)
    $downloads_details_bar_button1.add_action_listener do |e|
      if $paused
         if $conexion.ctdescarga_resume($id.to_s)
            $option = 1
            @pulsado1_details = true
         else
            JOptionPane.showMessageDialog $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
         end #if $conexion.ctdescarga_pause($id.to_s)
      else
         if $conexion.ctdescarga_pause($id.to_s)
            $option = 1 
            @pulsado1_details = true
         else
            JOptionPane.showMessageDialog $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
         end #if $conexion.ctdescarga_pause($id.to_s)      
      end #if $paused     
      @pulsado11_details = true
    end #$downloads_details_bar_button1.add_action_listener do |e|

    $downloads_details_bar.add($downloads_details_bar_button2)
    $downloads_details_bar_button2.add_action_listener do |e|
      if $conexion.ctdescarga_cancel($id.to_s)
         really_cancel = JOptionPane.showConfirmDialog $content_pane, "Delete the download?", "Confirmation...",  JOptionPane::YES_NO_OPTION, JOptionPane::QUESTION_MESSAGE
         if  really_cancel == javax.swing.JOptionPane::YES_OPTION
             $conexion.ctdescarga_cancel_confirm('s')
             $option = 1
             @pulsado1_details = true
         else
             $conexion.ctdescarga_cancel_confirm('n')
             $option = 1
             @pulsado1_details = true
         end #really_exit == javax.swing.JOptionPane::YES_OPTION
      else
         JOptionPane.showMessageDialog $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
      end #if conexion.ctdescarga_cancel($id.to_s)
      @pulsado11_details = true
    end #$downloads_details_bar_button2.add_action_listener do |e|
    
    $downloads_details_bar.add($downloads_details_bar_button3)
    $downloads_details_bar_button3.add_action_listener do |e|
      if $conexion.ctdescarga_resume("all")
         $option = 1
         @pulsado1_details = true
      else
         JOptionPane.showMessageDialog $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
      end #if $conexion.ctdescarga_resume("all")
      @pulsado11_details = true
    end #$downloads_details_bar_button3.add_action_listener do |e|
    
    $downloads_details_bar.add($downloads_details_bar_button4)
    $downloads_details_bar_button4.add_action_listener do |e|
      if $conexion.ctdescarga_pause("all")
         $option = 1
         @pulsado1_details = true
      else
         JOptionPane.showMessageDialog $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
      end #if $conexion.ctdescarga_pause("all")
      @pulsado11_details = true
    end #$downloads_details_bar_button4.add_action_listener do |e|

    $downloads_details_bar.add(@prio_type)
    
    @prio_type.add_action_listener do |e|
      if @prio_type.getSelectedItem.to_s != $priority 
         case @prio_type.getSelectedItem.to_s
            when "Normal"
              new_value = 0
            when "Very High"
              new_value = 20
            when "High"
              new_value = 10
            when "Very low"
              new_value = -20
            when "Low "
              new_value = -10
         end #case @prio_type.getSelectedItem.to_s
         actual_value = prio_to_number($priority)
         value = (actual_value - new_value) * -1

         if $conexion.ctdescarga_prioridad(value.to_s,$id.to_s)
            $option = 1
            @pulsado1_details = true
         else
            JOptionPane.showMessageDialog $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
         end #if $conexion.ctdescarga_pause("all")
      end #if @prio_type.getSelectedItem.to_s != $priority          
    end #@prio_type.add_action_listener do |e|
    
    $downloads_details_bar.add(@back_downloads_details_bar)
    $downloads_details_bar.setForeground(Color.white)
    $downloads_details_bar.setBackground(Color.black)


    #### creamos el contenedor de las busquedas     pte refactorizar

    $modelo_lbusq = JTableModelSearch.new
    $tabla_lbusq = JTable.new $modelo_lbusq
    $tabla_lbusq.setForeground(Color.white)
    $lista_lbusq = JScrollPane.new($tabla_lbusq)
    $tabla_lbusqRenderer = JTableButtonRendererSearch.new
    $tabla_lbusq.getColumn("Actions").setCellRenderer($tabla_lbusqRenderer)

    $tabla_lbusqListener = JTableButtonMouseListenerSearch.new
    $tabla_lbusqListener.getTable($tabla_lbusq)
    $tabla_lbusq.addMouseListener($tabla_lbusqListener)

    $tabla_lbusqEditor = JTableButtonEditorSearch.new
    $tabla_lbusqEditor.init
    $tabla_lbusq.setDefaultEditor($tabla_lbusq.getColumnClass(0).to_java, $tabla_lbusqEditor)

    @search_text1 = javax.swing.JTextField.new
    @search_text1.setBounds 10,3,240,25

    @search_button = javax.swing.JButton.new "Search"
    @search_button.setBounds 260,0,80,30

    @search_label1 = javax.swing.JLabel.new
    @search_label1.setText("Min.")
    @search_label1.setBounds 350,0,30,25

    @search_text2 = javax.swing.JFormattedTextField.new(0.to_java)
    @search_text2.setBounds 380,3,55,25

    @min_size_type = javax.swing.JComboBox.new(["Bytes", "KBytes","MBytes","GBytes"].to_java)
    @min_size_type .setBounds 440,3,75,25

    @search_label2 = javax.swing.JLabel.new
    @search_label2.setText("Max.")
    @search_label2.setBounds 530,0,30,25

    @search_text3 = javax.swing.JFormattedTextField.new(0.to_java)
    @search_text3.setBounds 560,3,55,25

    @max_size_type = javax.swing.JComboBox.new(["Bytes", "KBytes","MBytes","GBytes"].to_java)
    @max_size_type .setBounds 620,3,75,25

    @ed2k_button = javax.swing.JButton.new "Ed2k"
    @ed2k_button.setBounds 705,0,80,30

    @torrent_button = javax.swing.JButton.new "Bittorrent"
    @torrent_button.setBounds 800,0,80,30

    $busquedas = JScrollPane.new
    $busquedas.setLayout nil

    $icon_back_search = ImageIcon.new "fondo_03.png"
    $back_search = JLabel.new $icon_back_search


    $busquedas.add(@search_text1)
    $busquedas.add(@search_button)
    @search_button.add_action_listener do |e|

      #debug - purpose only - init
      #          JOptionPane.showMessageDialog $busquedas, "Search Launched...\n" +  "busqueda :"+
      #          @search_text1.getText  + "  Minsize :" + @search_text2.getText + " " + @min_size_type.getSelectedItem.to_s  +
      #          " Maxsize :"+ @search_text3.getText  + " " + @max_size_type.getSelectedItem.to_s,
      #        "Information", JOptionPane::INFORMATION_MESSAGE
      #debug - pupose only - ending

      minimo = 0
      if @search_text2.getText.to_i != 0
        case  @min_size_type.getSelectedItem.to_s
        when "Bytes"
          minimo = @search_text2.getText.to_i * 1
        when "KBytes"
          minimo = @search_text2.getText.to_i * 1024
        when "MBytes"
          minimo = @search_text2.getText.to_i * 1024 * 1024
        when "GBytes"
          minimo = @search_text2.getText.to_i * 1024 * 1024 * 1024
        end # @min_size_type.getSelectedItem.to_s
      end  #@search_text2.getText.to_i != 0

      maximo = 0
      if @search_text3.getText.to_i != 0
        case  @max_size_type.getSelectedItem.to_s
        when "Bytes"
          maximo = @search_text3.getText.to_i * 1
        when "KBytes"
          maximo = @search_text3.getText.to_i * 1024
        when "MBytes"
          maximo = @search_text3.getText.to_i * 1024 * 1024
        when "GBytes"
          maximo = @search_text3.getText.to_i * 1024 * 1024 * 1024
        end # @max_size_type.getSelectedItem.to_s
      end  #@search_text3.getText.to_i != 0


      $conexion.ctbusqueda(@search_text1.getText,minimo,maximo)
      
      if $conexion.ctlista_busqueda
         cuerpo = Array.new
         i  = 0
         $conexion.ctlista_busqueda_retorno_msg.each do |valor|
            y = 0
            subcuerpo = Array.new
            subcuerpo[y] = valor.to_s
            cuerpo[i]  = subcuerpo
            i  +=1
            y +=1
         end #if $conexion.ctlista_busqueda

         $modelo_lbusq.actualiza(cuerpo)
         $tabla_lbusq.getColumnModel.getColumn(0).setPreferredWidth($content_pane.getWidth/6)
      else
         JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
      end  #if $conexion.cestado

      $pulsado02_carga  = true
    end #@search_button.add_action_listaner do |e|


    $busquedas.add(@search_label1)
    $busquedas.add(@search_label2)
    $busquedas.add(@search_text2)
    $busquedas.add(@search_text3)
    $busquedas.add(@min_size_type)
    $busquedas.add(@max_size_type)

    $busquedas.add(@ed2k_button)
    @ed2k_button.add_action_listener do |e|
      @ed2kPanelIcon = ImageIcon.new "icon.gif"
      name = JOptionPane.showInputDialog  $busquedas, "Your Ed2k Link Here...", "Ed2k Link", JOptionPane::INFORMATION_MESSAGE, @ed2kPanelIcon, nil ,nil 
      if name != nil
         $conexion.ctdownurl(name)
         JOptionPane.showMessageDialog $content_pane, "Download has been added...", "Information", JOptionPane::INFORMATION_MESSAGE
      end #if name != nil
    end #@ed2k_button.add_action_listaner do |e|

    $busquedas.add(@torrent_button)
    @torrent_button.add_action_listener do |e|
      @torrentPanelIcon = ImageIcon.new "iconb.png"
      nameb = JOptionPane.showInputDialog  $busquedas, "Your Torrent url Here...", "Torrent Url", JOptionPane::INFORMATION_MESSAGE, @torrentPanelIcon, nil ,nil 
      if nameb != nil
         $conexion.ctdownurl(nameb)
         JOptionPane.showMessageDialog $content_pane, "Download has been added...", "Information", JOptionPane::INFORMATION_MESSAGE
      end #if name != nil
      ##JOptionPane.showMessageDialog $busquedas, "Your Torrent url Here...", "Information", JOptionPane::INFORMATION_MESSAGE
    end #@torrent_button.add_action_listaner do |e|

    $busquedas.add($back_search)
    $busquedas.setForeground(Color.white)
    $busquedas.setBackground(Color.black)

    #### creamos el contenedos para el listado de detalles de la busqueda     pte de refactorizar
    
    @pulsado21_details  = true 
    @search_details_modelo = Modelo.new
    @search_details_tabla = JTable.new @search_details_modelo
    @search_details_tabla.setForeground(Color.white)
    @search_details_tabla.setFont(Font.new case RbConfig::CONFIG['host_os'] when /mswin/; "Arial Unicode MS" when /darwin/; "AppleGothic, Arial" end, Font::PLAIN, 12)
    $search_details_lista = JScrollPane.new(@search_details_tabla)

    #### creamos el contenedor de los servidores    pte refactorizar
    
    $modelo_lserve = JTableModelServer.new
    $tabla_lserve = JTable.new $modelo_lserve
    $tabla_lserve.setForeground(Color.white)
    $lista_lserve= JScrollPane.new($tabla_lserve)
    $tabla_lserveRenderer = JTableButtonRendererServer.new
    $tabla_lserve.getColumn("Actions allowed").setCellRenderer($tabla_lserveRenderer)
    $tabla_lserve.getColumn(" ").setCellRenderer($tabla_lserveRenderer)

    $tabla_lserveListener = JTableButtonMouseListenerServer.new
    $tabla_lserveListener.getTable($tabla_lserve)
    $tabla_lserve.addMouseListener($tabla_lserveListener)

    $tabla_lserveEditor = JTableButtonEditorServer.new
    $tabla_lserveEditor.init
    $tabla_lserve.setDefaultEditor($tabla_lserve.getColumnClass(0).to_java, $tabla_lserveEditor)
    
    $icon_back_server = ImageIcon.new "fondo_03.png"
    $back_server = JLabel.new $icon_back_server
    
    @server_string = javax.swing.JLabel.new
    @server_string.setText("Servers ")
    @server_string.setBounds 60,0,80,25
    
    @server_all_button = javax.swing.JButton.new "All"
    @server_all_button.setBounds 120,0,120,25
    @server_all_button.add_action_listener do |e|
        $server_all = true
    end #@server_all_button..add_action_listener do |e|
    
    @server_con_button = javax.swing.JButton.new "Connected"
    @server_con_button.setBounds 240,0,120,25
    @server_con_button.add_action_listener do |e|
        $server_all = false
    end #@server_con_button.add_action_listener do |e|
    
    $server_bar = JScrollPane.new
    $server_bar.setLayout nil
    
    $server_bar.add(@server_string)
    $server_bar.add(@server_all_button)
    $server_bar.add(@server_con_button)
    
    $server_bar.add($back_server)
    $server_bar.setForeground(Color.white)
    $server_bar.setBackground(Color.black)
  
    #### creamos el contenedor de las Estadisticas     pte refactorizar
    $icon_back_statistics = ImageIcon.new "fondo_03.png"
    $back_statistics = JLabel.new $icon_back_statistics
    
    $statistics_string = javax.swing.JLabel.new
    $statistics_string.setText("Statistics ")
    $statistics_string.setBounds 60,0,80,25
    
    $statistics_op1_button = javax.swing.JButton.new "Bandwidth"
    $statistics_op1_button.setBounds 120,0,120,25
    $statistics_op1_button.add_action_listener do |e|
        $option = 4
        $pulsado04 = true
    end #@server_all_button..add_action_listener do |e|
    
    $statistics_op2_button = javax.swing.JButton.new "Clients"
    $statistics_op2_button.setBounds 240,0,120,25
    $statistics_op2_button.add_action_listener do |e|
        $option = 41
        $modelo_stats_client = Modelo.new
        $tabla_stats_client = JTable.new $modelo_stats_client
        $tabla_stats_client.setForeground(Color.white)
        $tabla_stats_client.setFont(Font.new case RbConfig::CONFIG['host_os'] when /mswin/; "Arial Unicode MS" when /darwin/; "AppleGothic, Arial" end, Font::PLAIN, 12)
        $lista_stats_client = JScrollPane.new($tabla_stats_client)
        
        
        clients = Array.new
        i = 0
        if $conexion.ctstats
           $conexion.cver_valores_estadistiva_msg.each do |value|
              if value =~ /Session/
                 j = 0
                 value.split('|').each do |piece|
                   j += 1
                   if j == 1
                      clients[i] = [piece.to_s]
                      i += 1
                      #debug
                      #puts piece.to_s
                      #debug
                   end #if j == 1
                 end #value.split('|').each do |piece|
              end #if value =~ /Session/
           end #$conexion.cver_valores_estadistiva_msg.each do |value|
        end #if $conexion.ctstats()
        
        $modelo_stats_client.actualiza(clients,["Clients"])
        $tabla_stats_client.getSelectionModel.addListSelectionListener(RowListener.new($tabla_stats_client))

        
    end #@server_con_button.add_action_listener do |e|
    
    
    
    $statistics_op3_button = javax.swing.JButton.new "Uploads"
    $statistics_op3_button.setBounds 360,0,120,25
    $statistics_op3_button.add_action_listener do |e|
        $option = 4
#debug        
#        #puts "uploads"
#debug
        if $conexion.cupstats
           text_upload_details = "<table style=\"text-align: right; font-family: Arial; margin-left: 60px;\"><tbody>"
           i = 0
           $conexion.cver_valores_estadistica_carga_msg.each do |piece|
                if i == 0 || i == 1
                   text_upload_details += "<tr><td><b><p>"
                   text_upload_details += piece.to_s.chomp.gsub("\|","</p></b></td><td><b><p>")
                   text_upload_details += "</p></b></td></tr>"
                else   
                   text_upload_details += "<tr><td>"
                   text_upload_details += piece.to_s.chomp.gsub("\|","</td><td>")
                   text_upload_details += "</td></tr>"
                end #if i == 0 || i == 1
#debug                
#                #puts piece.to_s
#debug
                i += 1
           end #$conexion.cver_valores_estadistica_carga_msg.each do |piece|
           text_upload_details += "</tbody></table>"
        else
           JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
        end #$conexion.cupstats()
        
         $lista_stats_upload_details = JPanel.new
         $lista_stats_upload_details.setOpaque false
         
         $lista_stats_upload_details.setForeground(Color.white)
         $lista_stats_upload_details.setBackground(Color.black)

         $upload_details_string = JLabel.new
         text_upload_details = "<html><head><style type=\"text/css\">p {color:#659EC7;} </style></head><body>" + text_upload_details + "</body></html>"
         $upload_details_string.setText(text_upload_details)
         $upload_details_string.setBounds 0,168,$content_pane.getWidth,$content_pane.getHeight - 168
         $upload_details_string.setOpaque false
         $lista_stats_upload_details.add($upload_details_string)
         
         $lista_stats_upload_details_w_scroll = JScrollPane.new($lista_stats_upload_details)
         $lista_stats_upload_details_w_scroll.getViewport.setOpaque false
         
         
         $option = 43
    end #@server_con_button.add_action_listener do |e|
    
    $statistics_bar = JScrollPane.new
    $statistics_bar.setLayout nil
    
    $statistics_bar.add($statistics_string)
    $statistics_bar.add($statistics_op1_button)
    $statistics_bar.add($statistics_op2_button)
    $statistics_bar.add($statistics_op3_button)

    
    $statistics_bar.add($back_statistics)
    $statistics_bar.setForeground(Color.white)
    $statistics_bar.setBackground(Color.black)

    ChartFactory.setChartTheme(StandardChartTheme.createDarknessTheme)

    @down_series = TimeSeries.new("Download",)
    
    down_xyDataset = TimeSeriesCollection.new(@down_series)
    down_chart = ChartFactory.createTimeSeriesChart("Download Rate","Time","Kb",down_xyDataset,false, true, true)
    down_chart.setBackgroundPaint(nil)

    down_chart.getPlot.setBackgroundPaint(Color.gray)
    down_chart.getPlot.setOutlinePaint(nil)
    down_chart.getPlot.getRenderer.setSeriesPaint(0, Color.new(0,100,0))
    
    down_chart.getPlot.getDomainAxis.setAutoRange(true)
    down_chart.getPlot.getDomainAxis.setFixedAutoRange(60000.0 * 15)  # 60 seconds x 12 minutos
    $down_graphic = org.jfree.chart.ChartPanel.new(down_chart)
    $down_graphic.setOpaque false

    @upload_series = TimeSeries.new("Upload",)
    
    upload_xyDataset = TimeSeriesCollection.new(@upload_series)
    upload_chart = ChartFactory.createTimeSeriesChart("  Upload Rate","Time","Kb",upload_xyDataset,false, true, true)
    upload_chart.setBackgroundPaint(nil)

    upload_chart.getPlot.setBackgroundPaint(Color.gray)
    upload_chart.getPlot.setOutlinePaint(nil)
    upload_chart.getPlot.getRenderer.setSeriesPaint(0, Color.new(105,37,37))
    
    upload_chart.getPlot.getDomainAxis.setAutoRange(true)
    upload_chart.getPlot.getDomainAxis.setFixedAutoRange(60000.0 * 15)  # 60 seconds x 12 minutos
    $upload_graphic = org.jfree.chart.ChartPanel.new(upload_chart)
    $upload_graphic.setOpaque false

    
    $statistics = JScrollPane.new
    $statistics.setLayout nil
    $statistics.setOpaque false
    $statistics.add($down_graphic)
    $statistics.add($upload_graphic)
    $statistics.setForeground(Color.white)
    $statistics.setBackground(Color.black)


    #### creamos el contenedor de las opciones     pte refactorizar
    
    $modelo_options_client = Modelo.new
    $tabla_options_client = JTable.new $modelo_options_client
    $tabla_options_client.setForeground(Color.white)
    $tabla_options_client.setFont(Font.new case RbConfig::CONFIG['host_os'] when /mswin/; "Arial Unicode MS" when /darwin/; "AppleGothic, Arial" end, Font::PLAIN, 12)
    $list_options = JScrollPane.new($tabla_options_client)
    
    $modelo_options_details = Modelo.new
    $tabla_options_details = JTable.new $modelo_options_details
    $tabla_options_details.setForeground(Color.white)
    $tabla_options_details.setFont(Font.new case RbConfig::CONFIG['host_os'] when /mswin/; "Arial Unicode MS" when /darwin/; "AppleGothic, Arial" end, Font::PLAIN, 12)
    $list_options_details = JScrollPane.new($tabla_options_details)
    
    $modelo_user = JTableModelUser.new
    $tabla_user = JTable.new $modelo_user
    $tabla_user.setForeground(Color.white)
    $tabla_user.getTableHeader.getDefaultRenderer.setHorizontalAlignment(javax.swing.SwingConstants::LEFT)
    $list_user = JScrollPane.new($tabla_user)
    $tabla_userRenderer = JTableButtonRendererUser.new
    $tabla_user.getColumn($tabla_user.getColumnName(9)).setCellRenderer($tabla_userRenderer)
    $tabla_user.getColumn($tabla_user.getColumnName(8)).setCellRenderer($tabla_userRenderer)
    
    $tabla_userListener = JTableButtonMouseListenerUser.new
    $tabla_userListener.getTable($tabla_user)
    $tabla_user.addMouseListener($tabla_userListener)

    $tabla_userEditor = JTableButtonEditorUser.new
    $tabla_userEditor.init
    $tabla_user.setDefaultEditor($tabla_user.getColumnClass(0).to_java, $tabla_userEditor)


    $modelo_group = JTableModelGroup.new
    $tabla_group = JTable.new $modelo_group
    $tabla_group.setForeground(Color.white)
    $tabla_group.getTableHeader.getDefaultRenderer.setHorizontalAlignment(javax.swing.SwingConstants::LEFT)
    $list_group = JScrollPane.new($tabla_group)
    $tabla_groupRenderer = JTableButtonRendererGroup.new
    $tabla_group.getColumn($tabla_group.getColumnName(5)).setCellRenderer($tabla_groupRenderer)
    $tabla_group.getColumn($tabla_group.getColumnName(4)).setCellRenderer($tabla_groupRenderer)
    
    $tabla_groupListener = JTableButtonMouseListenerGroup.new
    $tabla_groupListener.getTable($tabla_group)
    $tabla_group.addMouseListener($tabla_groupListener)

    $tabla_groupEditor = JTableButtonEditorGroup.new
    $tabla_groupEditor.init
    $tabla_group.setDefaultEditor($tabla_group.getColumnClass(0).to_java, $tabla_groupEditor)
    
    $modelo_share = JTableModelShare.new
    $tabla_share = JTable.new $modelo_share
    $tabla_share.setForeground(Color.white)
    $tabla_share.getTableHeader.getDefaultRenderer.setHorizontalAlignment(javax.swing.SwingConstants::LEFT)
    $list_share = JScrollPane.new($tabla_share)
    $tabla_shareRenderer = JTableButtonRendererShare.new
    $tabla_share.getColumn($tabla_share.getColumnName(3)).setCellRenderer($tabla_shareRenderer)
    
    $tabla_shareListener = JTableButtonMouseListenerShare.new
    $tabla_shareListener.getTable($tabla_share)
    $tabla_share.addMouseListener($tabla_shareListener)

    $tabla_shareEditor = JTableButtonEditorShare.new
    $tabla_shareEditor.init
    $tabla_share.setDefaultEditor($tabla_share.getColumnClass(0).to_java, $tabla_shareEditor)
    
    
    $options_op1_button = javax.swing.JButton.new "Options"
    $options_op1_button.setBounds 120,0,120,25
    $options_op1_button.addMouseListener Action05.new
    
    $options_op2_button = javax.swing.JButton.new "Users"
    $options_op2_button.setBounds 240,0,120,25
    $options_op2_button.add_action_listener do |e|
 #       $option = 4
 #       $pulsado04 = true
         $option = 52
         #puts "pulsado $options op2_button"
         
         if $conexion.ctusers
         
            user_index = $conexion.cusers_as_matrix
            $modelo_user.actualiza(user_index)
            group_index = $conexion.cgroups_as_matrix             
            $modelo_group.actualiza(group_index)           
            
            $tabla_user.getSelectionModel.clearSelection
            $modelo_user.fireTableDataChanged
            
            $tabla_group.getSelectionModel.clearSelection
            $modelo_group.fireTableDataChanged

            
            $content_pane.remove($conected)
            $content_pane.remove($lista)
            $content_pane.remove($downloads_details_bar)
            $content_pane.remove($downloads_details_w_scroll)
            $content_pane.remove($busquedas)
            $content_pane.remove($lista_lbusq)
            $content_pane.remove($search_details_lista)
            $content_pane.remove($search_details_panel)
            $content_pane.remove($lista_lserve)
            $content_pane.remove($server_bar)
            $content_pane.remove($statistics)
            $content_pane.remove($lista_stats_client)
            $content_pane.remove($lista_stats_client_details)
            $content_pane.remove($lista_stats_client_details_w_scroll)
            $content_pane.remove($lista_stats_upload_details_w_scroll)
            $content_pane.remove($statistics_bar)
            $content_pane.remove($options_bar)
            $content_pane.remove($list_options)
            $content_pane.remove($list_user)
            $content_pane.remove($list_group)
            $content_pane.remove($list_share)
            $content_pane.remove($list_options_details)         
            $content_pane.remove($ayuda)
            $content_pane.remove($fondo_principal)

            $content_pane.add($options_bar)
            $content_pane.add($list_user)
            $content_pane.add($list_group)
      
            $content_pane.add($fondo_principal)
            $content_pane.revalidate()
            $content_pane.repaint()
         else
            JOptionPane.showMessageDialog panel, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
         end #if $conexion.ctusers
    end #$options_op2_button.add_action_listener do |e|

    $options_op3_button = javax.swing.JButton.new "Shares"
    $options_op3_button.setBounds 360,0,120,25
    $options_op3_button.add_action_listener do |e|
 #       $option = 4
 #       $pulsado04 = true
         #puts "pulsado $options op3_button"
         $option = 53
         if $conexion.ctshares
            i = 0
            @share_matrix = Array.new
            $conexion.cver_valores_shares_msg.each do |line| 
              if i > 0
                 @share_submatrix = Array.new
                 y = 0
                line.split(' ').each do | word|
                   @share_submatrix[y] = word
                   y += 1
                end #line.split(' ') do | word|
                @share_matrix[i - 1] = @share_submatrix
              end #if i > 0
              i += 1
            end #$conexion.cver_valores_shares_msg.each do |line| 
            
            #group_index = $conexion.cgroups_as_matrix
            $modelo_share.actualiza(@share_matrix)
             
            $tabla_share.getSelectionModel.clearSelection
            $modelo_share.fireTableDataChanged
            
            $content_pane.remove($conected)
            $content_pane.remove($lista)
            $content_pane.remove($downloads_details_bar)
            $content_pane.remove($downloads_details_w_scroll)
            $content_pane.remove($busquedas)
            $content_pane.remove($lista_lbusq)
            $content_pane.remove($search_details_lista)
            $content_pane.remove($search_details_panel)
            $content_pane.remove($lista_lserve)
            $content_pane.remove($server_bar)
            $content_pane.remove($statistics)
            $content_pane.remove($lista_stats_client)
            $content_pane.remove($lista_stats_client_details)
            $content_pane.remove($lista_stats_client_details_w_scroll)
            $content_pane.remove($lista_stats_upload_details_w_scroll)
            $content_pane.remove($statistics_bar)
            $content_pane.remove($options_bar)
            $content_pane.remove($list_options)
            $content_pane.remove($list_user)
            $content_pane.remove($list_group)
            $content_pane.remove($list_share)
            $content_pane.remove($list_options_details)         
            $content_pane.remove($ayuda)
            $content_pane.remove($fondo_principal)

            $content_pane.add($options_bar)
            $content_pane.add($list_share)
      
            $content_pane.add($fondo_principal)
            $content_pane.revalidate()
            $content_pane.repaint()
            
         else
             JOptionPane.showMessageDialog panel, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
         end #if $conexion.ctshares
         
    end #$options_op3_button.add_action_listener do |e|

    $options_op4_button = javax.swing.JButton.new "Console"
    $options_op4_button.setBounds 480,0,120,25
    $options_op4_button.add_action_listener do |e|
 #       $option = 4
 #       $pulsado04 = true
         #puts "pulsado $options op4_button"
         JFrameNc.new
    end #$options_op4_button.add_action_listener do |e|
    
    $options_op5_button = javax.swing.JButton.new "New Users/Groups"
    $options_op5_button.setBounds 620,0,180,25
    $options_op5_button.add_action_listener do |e|
         JFrameNug.new 
    end #$options_op5_button.add_action_listener do |e|
    
    $options_op6_button = javax.swing.JButton.new "New Share"
    $options_op6_button.setBounds 620,0,180,25
    $options_op6_button.add_action_listener do |e|
         JFrameNs.new 
    end #$options_op6_button.add_action_listener do |e|
    

    $options_bar = JScrollPane.new
    $options_bar.setLayout nil
    $options_op5_button.setVisible false
    $options_op6_button.setVisible false

    
    $options_bar.add($options_op1_button)
    $options_bar.add($options_op2_button)
    $options_bar.add($options_op3_button)
    $options_bar.add($options_op4_button)
    $options_bar.add($options_op5_button)
    $options_bar.add($options_op6_button)
    
    $icon_back_options = ImageIcon.new "fondo_03.png"
    $back_options = JLabel.new $icon_back_options

    
    $options_bar.add($back_options)
    $options_bar.setForeground(Color.white)
    $options_bar.setBackground(Color.black)

    #### creamos el contenedor de las ayuda     pte refactorizar
    $cadena_ayuda = JTextPane.new
    lyrics =  
      "<html>
      <div style=\"text-align: center;\"><img style=\"width: 529px; height: 255px;\" alt=\"Rmldonkey 0.5\" src=\"file:Log5.png\"><br>
      </div>
      <div style=\"text-align: center;\"><a style=\"font-family: Comic Sans MS; font-weight: bold; text-shadow: black 0.1em 0.1em 0.2em;\" href=\"http://sourceforge.net/projects/rmldonkey\">http://sourceforge.net/projects/rmldonkey</a></div><br>
      <div style=\"text-align: center; text-shadow: black 0.1em 0.1em 0.2em; text-decoration: none; height: 120px;\"><span style=\"font-family: Comic Sans MS; color: white;\">
      This software is publish</span><br>
      <span style=\"font-family: Comic Sans MS; color: white;\">under the terms of</span><br>
      <span style=\"font-family: Comic Sans MS; color: white;\">GNU Public Licence.</span><br>
      <span style=\"font-family: Comic Sans MS; color: white;\">Copyrigth 2009-2013
      Manuel Ramos Caro</span><br>
      <span style=\"font-family: Comic Sans MS; color: white; font-weight: bold; text-shadow: black 0.1em 0.1em 0.2em;\">Contact &amp; Support:<a href=\"mailto:manuelramoscaro@yahoo.es\">manuelramoscaro@yahoo.es</a><br>
      </span>
      </div>
      </html>"
      
    kit=HTMLEditorKit.new 
    $cadena_ayuda.setEditorKit(kit)
    $cadena_ayuda.setEditable(false)
    $cadena_ayuda.setOpaque false
    $cadena_ayuda.setContentType("text/html") 
    $cadena_ayuda.setText lyrics
    $cadena_ayuda.addHyperlinkListener(HTMLListener.new)

    
    $ayuda = JPanel.new
    $ayuda.setOpaque false
    $ayuda.setLayout BorderLayout.new( 10, 10)

    
    $ayuda.add $cadena_ayuda, BorderLayout::CENTER
    $ayuda.setBorder BorderFactory.createEmptyBorder( 0, 0, 0, 0)



    #        $content_pane.add $lista


    $icono_04 = ImageIcon.new "04.png"
    $boton_04 = JLabel.new $icono_04
    $boton_04.addMouseListener Action04.new
    $content_pane.add($boton_04)

    $icono_03 = ImageIcon.new "03.png"
    $boton_03 = JLabel.new $icono_03
    $boton_03.addMouseListener Action03.new
    $content_pane.add($boton_03)

    $icono_02 = ImageIcon.new "02.png"
    $boton_02 = JLabel.new $icono_02
    $boton_02.addMouseListener Action02.new
    $content_pane.add($boton_02)

    $icono_05 = ImageIcon.new "05.png"
    $boton_05 = JLabel.new $icono_05
    $boton_05.addMouseListener Action05.new
    $content_pane.add($boton_05)

    $icono_06 = ImageIcon.new "06.png"
    $boton_06 = JLabel.new $icono_06
    $boton_06.addMouseListener Action06.new
    $content_pane.add($boton_06)

    $icono_07 = ImageIcon.new "07.png"
    $boton_07 = JLabel.new $icono_07
    $boton_07.addMouseListener Action07.new
    $content_pane.add($boton_07)

    $icono_01 = ImageIcon.new "01.png"
    $boton_01 = JLabel.new $icono_01
    $boton_01.addMouseListener Action01.new
    $content_pane.add($boton_01)

    $boton_01.setBounds((($content_pane.getWidth/2) - 40)  - 180, 0, $icono_01.getIconWidth, $icono_01.getIconHeight)
    $boton_02.setBounds((($content_pane.getWidth/2) - 40)  - 120, 0, $icono_02.getIconWidth, $icono_02.getIconHeight)
    $boton_03.setBounds((($content_pane.getWidth/2) - 40)  -  60, 0, $icono_03.getIconWidth, $icono_03.getIconHeight)
    $boton_04.setBounds((($content_pane.getWidth/2) - 40)       , 0, $icono_04.getIconWidth, $icono_04.getIconHeight)
    $boton_05.setBounds((($content_pane.getWidth/2) - 40)  +  60, 0, $icono_05.getIconWidth, $icono_05.getIconHeight)
    $boton_06.setBounds((($content_pane.getWidth/2) - 40)  + 120, 0, $icono_06.getIconWidth, $icono_06.getIconHeight)
    $boton_07.setBounds((($content_pane.getWidth/2) - 40)  + 180, 0, $icono_07.getIconWidth, $icono_07.getIconHeight)


    $menu_fondo = JLabel.new
    $content_pane.add($menu_fondo)

    $picture = JLabel.new
    $picture.setForeground(Color.white)
    $content_pane.add($picture)

    $icono_fondo_estado = ImageIcon.new "fondo_01.png"
    $picture_fondo = JLabel.new $icono_fondo_estado

    $content_pane.add($picture_fondo)

    $icono_fondo_principal  = ImageIcon.new "fondo_00.png"
    $fondo_principal = JLabel.new $icono_fondo_principal
    
    return $content_pane
  end #createContentPane

  def addWindowListener(w)
    #puts "04class Main.addWindowListener"
    w.addWindowListener(self)
  end #addWindowListener(w)

  def windowIconified(e)
    #puts "05class Main.windowIconified"
  end #windowIconified(e)
  def windowDeiconified(e)
    #puts "06class Main.windowDeiconified"
    startAnimation
  end #windowDeiconified(e)

  def windowOpened(e); end
  def windowClosing(e); end
  def windowClosed(e); end
  def windowActivated(e); end
  def windowDeactivated(e); end

  def stateChanged(e)
    #puts "07class Main.stateChanged"
    source = e.getSource
    source.getValueIsAdjusting and return
    fps = source.getValue
    if fps == 0
      if !@frozen
        stopAnimation
      end
    else
      @delay = 1000 / fps
      @timer.setDelay(@delay)
      @timer.setInitialDelay(@delay * 10)
      if @frozen
        startAnimation
      end
    end
  end #stateChanged(e)

  def startAnimation
    #puts "08class Main.startAnimation "
    @timer.start
    @frozen = false

  end #startAnimation

  def stopAnimation
    #puts "09class Main.stopAnimation"
    @timer.stop
    @frozen = true
  end #stopAnimation

  def actionPerformed(e)
    
    #puts "10class Main.actionPerformed"

    if $conexion.ctestado
      barra_estado = String.new
      $conexion.ctestado_retorno_msg.each do |mensaje|
        mensaje = mensaje.gsub("\n","")
        barra_estado += mensaje
      end #conexion.ctestado_retorno_msg.each
      $picture.setText(barra_estado)
      $picture.setHorizontalAlignment(javax.swing.SwingConstants::CENTER)
      
      tiempo = Millisecond.new
      @down_series.add(tiempo, $conexion.ctestado_down_msg.to_f)
      @upload_series.add(tiempo, $conexion.ctestado_up_msg.to_f)
      
    else
      JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
    end #conexion.ctestado


    case $option
    when 0
      #puts "Todavia no ha pulsado nada"
      $pulsado02_carga  = true
      @pulsado11_details = true
      @pulsado21_details  = true
      @pulsado42_details = true
      @pulsado43_details = true
      $pulsado05 = true

      $conected.setBounds(0,128,$content_pane.getWidth,$content_pane.getHeight - 128)
      
      @cadena_conected.setBounds( $content_pane.getWidth/2 - 250,150,500,80)
      @cadena_conected2.setBounds( ($content_pane.getWidth/2 - 250)+5,150,500,80)

      $content_pane.add($conected)
      $content_pane.add($fondo_principal)
      
      $content_pane.revalidate()
      $content_pane.repaint()

    when 1
      #puts "Pulsado01"
      $pulsado02_carga   = true
      @pulsado11_details = true
      @pulsado21_details  = true 
      @pulsado42_details = true      
      @pulsado43_details = true
      $pulsado05 = true
      
      if @pulsado1_details || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight
          
         @pulsado1_details = false
         $content_pane.remove($conected)
         $content_pane.remove($busquedas)
         $content_pane.remove($downloads_details_bar)
         $content_pane.remove($downloads_details_w_scroll)
         $content_pane.remove($lista_lbusq)
         $content_pane.remove($search_details_lista)
         $content_pane.remove($search_details_panel)
         $content_pane.remove($server_bar)
         $content_pane.remove($lista_lserve)
         $content_pane.remove($statistics_bar)
         $content_pane.remove($statistics)
         $content_pane.remove($lista_stats_client)
         $content_pane.remove($lista_stats_client_details)
         $content_pane.remove($lista_stats_client_details_w_scroll)
         $content_pane.remove($lista_stats_upload_details_w_scroll)
         $content_pane.remove($opciones)
         $content_pane.remove($options_bar)
         $content_pane.remove($list_options)
         $content_pane.remove($list_user)
         $content_pane.remove($list_group)
         $content_pane.remove($list_share)
         $content_pane.remove($list_options_details)               
         $content_pane.remove($ayuda)
         $content_pane.remove($fondo_principal)

         $content_pane.add($lista)
         $content_pane.add($fondo_principal)
         $content_pane.revalidate()
         $content_pane.repaint()
         
      end  #if @pulsado11_details || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight   
      
      if $conexion.ctdescargas("")
          matrix = $conexion.ctdescargas_retorno_as_matrix
          columns = $conexion.ctdescargas_retorno_as_matrix_columns
          $modelo.actualiza(matrix,columns)
          $tabla.getSelectionModel.addListSelectionListener(RowListener.new($tabla))
          $tabla.getColumnModel.getColumn(0).setMaxWidth(0)
          $tabla.getColumnModel.getColumn(0).setMinWidth(0)
          $tabla.getColumnModel.getColumn(0).setPreferredWidth(0)
          $tabla.getColumnModel.getColumn(1).setPreferredWidth($content_pane.getWidth/3)
      else
        JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
      end #conexion.ctestado

      $lista.setBounds(0,128,$content_pane.getWidth,$content_pane.getHeight - 128)
    when 11
      #puts "Pulsado11"
      if $paused
         $downloads_details_bar_button1.setText("Resume")
      else
         $downloads_details_bar_button1.setText("Pause")
      end #if $paused
      $pulsado02_carga = true
      $pulsado05 = true      
      @pulsado21_details  = true

      $tabla.getSelectionModel.clearSelection
      $modelo.fireTableDataChanged
      $tabla_lbusq.getSelectionModel.clearSelection
      $modelo_lbusq.fireTableDataChanged
      if @pulsado11_details || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight
          
         @pulsado11_details = false
         $content_pane.remove($conected)
         $content_pane.remove($lista)
         $content_pane.remove($busquedas)
         $content_pane.remove($lista_lbusq)
         $content_pane.remove($search_details_lista)
         $content_pane.remove($search_details_panel)
         $content_pane.remove($server_bar)
         $content_pane.remove($lista_lserve)
         $content_pane.remove($statistics_bar)
         $content_pane.remove($statistics)
         $content_pane.remove($lista_stats_client)
         $content_pane.remove($lista_stats_client_details)
         $content_pane.remove($lista_stats_client_details_w_scroll)
         $content_pane.remove($lista_stats_upload_details_w_scroll)
         $content_pane.remove($opciones)
         $content_pane.remove($options_bar)
         $content_pane.remove($list_options)
         $content_pane.remove($list_user)
         $content_pane.remove($list_group)
         $content_pane.remove($list_share)
         $content_pane.remove($list_options_details)         
         $content_pane.remove($ayuda)
         $content_pane.remove($fondo_principal)

         
         $content_pane.add($downloads_details_bar)
         @downloads_details.setPreferredSize Dimension.new $content_pane.getWidth - 40, $content_pane.getHeight
         $content_pane.add($downloads_details_w_scroll)
         $content_pane.add($fondo_principal)
         $content_pane.revalidate()
         $content_pane.repaint()

         @back_downloads_details_bar.setBounds(0,0,$content_pane.getWidth,40)
         @icon_back_downloads_details_bar = ImageIcon.new(@icon_back_downloads_details_bar.getImage.getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
         @back_downloads_details_bar.setIcon(@icon_back_downloads_details_bar)
         $downloads_details_bar.setBounds(0,127,$content_pane.getWidth,40)
        
        
         if $conexion.ctdescargas($id.to_s)
            details_array = Array.new
            details_array = $conexion.ctdescargas_retorno_msg
            details_array[1]=details_array[1].gsub("0","")
            details_array[1]=details_array[1].gsub("1","")
            details_array[1]=details_array[1].gsub("2","")
            details_array[1]=details_array[1].gsub("3","")
            details_array[1]=details_array[1].gsub("4","")
            details_array[1]=details_array[1].gsub("5","")
            details_array[1]=details_array[1].gsub("6","")
            details_array[1]=details_array[1].gsub("7","")
            details_array[1]=details_array[1].gsub("8","")
            details_array[1]=details_array[1].gsub("9","")
            details_array[1]=details_array[1].gsub("\[","")
            details_array[1]=details_array[1].gsub("\]","")
            @net_details_value = details_array[1]
            @id_details_value = $id.to_s
            @file_name_details_value = details_array[2]
         
            ban_probable = false
            probable_name_value = ""

            details_array.each do |evaluate_detail|
               if evaluate_detail =~ /urn:/
                  @urn_link_details_value = evaluate_detail[4..evaluate_detail.length]
               end #if detalle_evaluado =~ /urn:/
               if evaluate_detail =~ /Chunks:/
                  evaluate_detail = evaluate_detail.gsub("Chunks:","")
                  evaluate_detail = evaluate_detail.gsub("\[","")
                  evaluate_detail = evaluate_detail.gsub("\]","")
                  evaluate_detail = evaluate_detail.gsub(" ","")
                  @status_details_value = evaluate_detail
               end #if detalle_evaluado =~ /Chunks:/
               if evaluate_detail =~ /Probable name:/ || ban_probable
                  ban_probable = true
                  if evaluate_detail =~ /sources:/ || evaluate_detail =~ /Comment/
                     ban_probable = false
                  else
                     evaluate_detail = evaluate_detail.to_s.gsub("Probable name:","")
                     escaped = UnicodeEscape.new(evaluate_detail)
                     probable_name_value += escaped.return_unicode_escape + "\n"
                  end  #if evaluate_detail =~ /sources:/ || valor =~ /Comment/
               end #if evaluate_detail =~ /Probable name:/
            end #details_array.each do |detalle_evaluado|
         #debug purpose
         #        #puts "probable name:"
         #        #puts probable_name_value
         #debug purpose
            @size_details_value = $size
            @downloaded_details_value = $downloaded
            @priority_details_value = $priority
            @prio_type.setSelectedItem(@priority_details_value)
         else
            JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
            System.exit 0
         end #if conexion.ctdescargas($id.to_s)
      
         @net_details.setText("Net")
         @net_details.setBounds 90,10,90,20
  
         @net_details_show.setText(":  " + @net_details_value)
         @net_details_show.setBounds 180,10,$content_pane.getWidth / 2,20

         @id_details.setText("Id")
         @id_details.setBounds 90,60,90,20
  
         @id_details_show.setText(":  " + @id_details_value)
         @id_details_show.setBounds 180,60,$content_pane.getWidth / 2,20

         @file_name_details.setText("File Name")
         @file_name_details.setBounds 90,110,90,20

         escaped = UnicodeEscape.new(@file_name_details_value)
         @file_name_details_show.setText(":  " + escaped.return_unicode_escape)
         @file_name_details_show.setBounds 180,110,$content_pane.getWidth - 500,20
         @file_name_details_show.setFont(Font.new case RbConfig::CONFIG['host_os'] when /mswin/; "Arial Unicode MS" when /darwin/; "AppleGothic, Arial"  end, Font::PLAIN, 12)
 
         @urn_link_details.setText("Urn link")
         @urn_link_details.setBounds 90,160,90,20
  
         @urn_link_details_show.setText(":  " + @urn_link_details_value)
         @urn_link_details_show.setBounds 180,160,$content_pane.getWidth / 2,20
  
         @size_details.setText("Size")
         @size_details.setBounds 90,210,90,20
  
         @size_details_show.setText(":  " + @size_details_value)
         @size_details_show.setBounds 180,210,$content_pane.getWidth / 2,20
  
         @downloaded_details.setText("Downloaded")
         @downloaded_details.setBounds 90,260,90,20
  
         @downloaded_details_show.setText(":  " + @downloaded_details_value)
         @downloaded_details_show.setBounds 180,260,$content_pane.getWidth / 2,20

         @priority_details.setText("Priority")
         @priority_details.setBounds 90,310,90,20

         @priority_details_show.setText(":  " + @priority_details_value)
         @priority_details_show.setBounds 180,310,$content_pane.getWidth / 2,20
  
         @status_details.setText("Status")
         @status_details.setBounds 90,360,90,20
  
         @status_details_points.setText(":  ")
         @status_details_points.setBounds 180,360,20,20
         @status_details_show.getDetails(@status_details_value)
         @status_details_show.setBounds 190,360,$content_pane.getWidth - 500,20

         @probable_name_details.setText("Probable Names :")
         @probable_name_details.setBounds 90,410,$content_pane.getWidth / 2,20
         num_lines = 0
         probable_name_value_ww = "<html>"
         probable_name_value.each_line do |line|
           num_lines += 1
           i = 0
           while i <= line.length - 1 && line[i..i] ==  " "
              line = line[i..line.length]
              i += 1
           end #while i <= line.length
           #puts "index:" + i.to_s
           #puts "line:" + num_lines.to_s
           probable_name_value_ww +=  line + "<BR>"
         end #probable_name_value.each_line do |line|
         probable_name_value_ww += "</html>"
         #puts probable_name_value_ww
         @probable_name_details_show.setText(probable_name_value_ww)
         @probable_name_details_show_s.setBounds 90,440,$content_pane.getWidth / 2 + $content_pane.getWidth / 4,160
                           
         @downloads_details.setBounds(0,168,$content_pane.getWidth - 80,$content_pane.getHeight - 168)
         $downloads_details_w_scroll.setBounds(0,168,$content_pane.getWidth,$content_pane.getHeight - 168 )
      
         $content_pane_prev_wsize = $content_pane.getWidth 
         $content_pane_prev_hsize = $content_pane.getHeight
         
         $downloads_details_w_scroll.setPreferredSize(Dimension.new(@downloads_details.getWidth, @downloads_details.getHeight))
         
         
      end  #if @pulsado11_details || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight

    when 2
      #puts "Pulsado02"
      #puts $pulsado02_carga.to_s
      @pulsado11_details = true
      @pulsado21_details  = true
      @pulsado42_details = true      
      @pulsado43_details = true
      $pulsado05 = true

      $back_search.setBounds(0,0,$content_pane.getWidth,40)
      $icon_back_search = ImageIcon.new($icon_back_search.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
      $back_search.setIcon($icon_back_search)
      $busquedas.setBounds(0,127,$content_pane.getWidth,40)

      $tabla_lbusq.getSelectionModel.clearSelection
      $modelo_lbusq.fireTableDataChanged

      $lista_lbusq.setBounds(0,165,$content_pane.getWidth,$content_pane.getHeight - 165)
  
    when 21
      $pulsado02_carga = true
      @pulsado11_details = true
      @pulsado42_details = true      
      @pulsado43_details = true
      $pulsado05 = true      
         
      if @pulsado21_details
	  
         @pulsado21_details = false  
         $content_pane_prev_wsize = nil 
         $content_pane_prev_hsize = nil
		 
         if $conexion.ctver_resultado_busqueda($id)
            
            i = 0 
            f = 99  
             is = 0
            @search_details_main_matrix = Array.new
            while $conexion.cver_resultado_busqueda_msg(i,f)[0] != nil 
               ip = 0
               @search_details_sub_matrix = Array.new
               $conexion.cver_resultado_busqueda_msg(i,f).each do |element|
                    @search_details_sub_matrix[ip] = element.to_s
                    #puts "valor:" + ip.to_s + "###" + element.to_s
                    ip += 1
                    
                  if ip > 3
                    @search_details_main_matrix[is] = @search_details_sub_matrix
                    ip = 0
                    @search_details_sub_matrix = Array.new
                    is += 1
                  end #if ip > 3
               end # $conexion.cver_resultado_busqueda_msg(i,f).each_line do |element|
               i += 100
               f += 100 
            end # while $conexion.cver_resultado_busqueda_msg(i,f)
         
         else
           JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
         end #if $conexion.ctver_resultado_busqueda($id)
      end #if @pulsado21_details
	  
	  if $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight 
	  
	     @search_details_tabla.getSelectionModel.clearSelection
         @search_details_modelo.fireTableDataChanged
         $content_pane.revalidate()
         $content_pane.repaint()
         
         $content_pane.remove($conected)
         $content_pane.remove($lista)
         $content_pane.remove($downloads_details_bar)
         $content_pane.remove($downloads_details_w_scroll)
         $content_pane.remove($busquedas)
         $content_pane.remove($lista_lbusq)
         $content_pane.remove($search_details_lista)
         $content_pane.remove($search_details_panel)
         $content_pane.remove($server_bar)
         $content_pane.remove($lista_lserve)
         $content_pane.remove($statistics_bar)
         $content_pane.remove($statistics)
         $content_pane.remove($lista_stats_client)
         $content_pane.remove($lista_stats_client_details)
         $content_pane.remove($lista_stats_client_details_w_scroll)
         $content_pane.remove($lista_stats_upload_details_w_scroll)
         $content_pane.remove($opciones)
         $content_pane.remove($options_bar)
         $content_pane.remove($list_options)
         $content_pane.remove($list_user)
         $content_pane.remove($list_group)
         $content_pane.remove($list_share)
         $content_pane.remove($list_options_details)                  
         $content_pane.remove($ayuda)
         $content_pane.remove($fondo_principal)
         
         $content_pane.add($search_details_lista)
         $content_pane.add($fondo_principal)
         
         @search_details_tabla.getSelectionModel.clearSelection
         @search_details_modelo.fireTableDataChanged
         
         $content_pane.revalidate()
         $content_pane.repaint()
              
         $content_pane_prev_wsize = $content_pane.getWidth 
         $content_pane_prev_hsize = $content_pane.getHeight
	     
	     matrix = @search_details_main_matrix
         columns = ["Id", "Size","Availability","File"]
         @search_details_modelo.actualiza(matrix,columns)
         @search_details_tabla.getSelectionModel.addListSelectionListener(RowListener.new(@search_details_tabla))
         @search_details_tabla.getColumnModel.getColumn(0).setMaxWidth(0)
         @search_details_tabla.getColumnModel.getColumn(0).setMinWidth(0)
         @search_details_tabla.getColumnModel.getColumn(0).setPreferredWidth(0)
         @search_details_tabla.getColumnModel.getColumn(1).setPreferredWidth($content_pane.getWidth/10)        
         @search_details_tabla.getColumnModel.getColumn(2).setPreferredWidth($content_pane.getWidth/10)
         @search_details_tabla.getColumnModel.getColumn(3).setPreferredWidth($content_pane.getWidth/2)
         $search_details_lista.setBounds(0,128,$content_pane.getWidth,$content_pane.getHeight - 128)
      end # if $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight 
	  
	  
    when 3
      #puts "Pulsado03"
      $pulsado02_carga = true
      @pulsado11_details = true
      @pulsado21_details  = true
      @pulsado42_details = true
      @pulsado43_details = true
      $pulsado05 = true

      
      $content_pane_prev_wsize = nil 
      $content_pane_prev_hsize = nil
      
      if $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight 


         $tabla_lserve.getSelectionModel.clearSelection
         $modelo_lserve.fireTableDataChanged
         
         $back_server.setBounds(0,0,$content_pane.getWidth,40)
         $icon_back_server = ImageIcon.new($icon_back_server.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
         $back_server.setIcon($icon_back_server)
         
         $server_bar.setBounds(0,127,$content_pane.getWidth,40)
         
         $content_pane_prev_wsize = $content_pane.getWidth 
         $content_pane_prev_hsize = $content_pane.getHeight
         
         
         if $server_all
            if $conexion.ctlista_server 
               matrix = $conexion.ctserver_return_as_matrix 
               columns = $conexion.ctserver_return_as_matrix_columns
               $modelo_lserve.actualiza(matrix)
            else
               JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
            end #if $conexion.ctlista_server
         else
            if $conexion.ctlista_server_conected
               matrix = $conexion.ctserver_connected_return_as_matrix
               columns = $conexion.ctserver_return_as_matrix_columns
               $modelo_lserve.actualiza(matrix)
            else
               JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
            end #if $conexion.ctlista_server_conected
         end # if $server_all

         $tabla_lserve.getColumnModel.getColumn(1).setMaxWidth(0)
         $tabla_lserve.getColumnModel.getColumn(1).setMinWidth(0)
         $tabla_lserve.getColumnModel.getColumn(1).setPreferredWidth(0)
         
         $tabla_lserve.getColumnModel.getColumn(0).setMaxWidth($content_pane.getWidth/12)
         $tabla_lserve.getColumnModel.getColumn(0).setMinWidth($content_pane.getWidth/12)
         $tabla_lserve.getColumnModel.getColumn(0).setPreferredWidth($content_pane.getWidth/12)        
         $tabla_lserve.getColumnModel.getColumn(2).setPreferredWidth($content_pane.getWidth/6)
         $tabla_lserve.getColumnModel.getColumn(3).setPreferredWidth($content_pane.getWidth/4)
         $tabla_lserve.getColumnModel.getColumn(9).setMaxWidth($content_pane.getWidth/2000)
         $tabla_lserve.getColumnModel.getColumn(9).setMinWidth($content_pane.getWidth/2000)
         $tabla_lserve.getColumnModel.getColumn(9).setPreferredWidth($content_pane.getWidth/2000)
         
         $lista_lserve.setBounds(0,165,$content_pane.getWidth,$content_pane.getHeight - 165)         
         
       end #if $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight 

    when 4
      #puts "Pulsado04"
      $pulsado02_carga = true
      @pulsado11_details = true
      @pulsado21_details  = true
      @pulsado42_details = true
      @pulsado43_details = true
      $pulsado05 = true

      
      if $pulsado04
         $pulsado04 = false
         $content_pane.remove($conected)
         $content_pane.remove($lista)
         $content_pane.remove($downloads_details_bar)
         $content_pane.remove($downloads_details_w_scroll)
         $content_pane.remove($busquedas)
         $content_pane.remove($lista_lbusq)
         $content_pane.remove($search_details_lista)
         $content_pane.remove($search_details_panel)
         $content_pane.remove($server_bar)
         $content_pane.remove($lista_lserve)
         $content_pane.remove($lista_stats_client)
         $content_pane.remove($lista_stats_client_details)
         $content_pane.remove($lista_stats_client_details_w_scroll)
         $content_pane.remove($lista_stats_upload_details_w_scroll)
         $content_pane.remove($opciones)
         $content_pane.remove($options_bar)
         $content_pane.remove($list_options)
         $content_pane.remove($list_user)
         $content_pane.remove($list_group)
         $content_pane.remove($list_share)
         $content_pane.remove($list_options_details)                  
         $content_pane.remove($ayuda)
         $content_pane.remove($fondo_principal)

         $content_pane.add($statistics_bar)
         $content_pane.add($statistics)
         $content_pane.add($fondo_principal)

         $back_statistics.setBounds(0,0,$content_pane.getWidth,40)
         $icon_back_statistics = ImageIcon.new($icon_back_statistics.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
         $back_statistics.setIcon($icon_back_statistics)
         $statistics_bar.setBounds(0,127,$content_pane.getWidth,40)

         $content_pane.revalidate()
         $content_pane.repaint()
         $statistics.setBounds(0,168,$content_pane.getWidth,$content_pane.getHeight - 168)
      
         $down_graphic.setBounds 0,0,$content_pane.getWidth,($content_pane.getHeight - 168) /2
         $upload_graphic.setBounds 0,($content_pane.getHeight - 168 )/2,$content_pane.getWidth,($content_pane.getHeight - 168)/2
      end 

      $back_statistics.setBounds(0,0,$content_pane.getWidth,40)
      $icon_back_statistics = ImageIcon.new($icon_back_statistics.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
      $back_statistics.setIcon($icon_back_statistics)
      
      $statistics_bar.setBounds(0,127,$content_pane.getWidth,40)
      $statistics.setBounds(0,168,$content_pane.getWidth,$content_pane.getHeight - 168)
      
      $down_graphic.setBounds 0,0,$content_pane.getWidth,($content_pane.getHeight - 168) /2
      $upload_graphic.setBounds 0,($content_pane.getHeight - 168 )/2,$content_pane.getWidth,($content_pane.getHeight - 168)/2
      
    when 41  
    
      #puts "Pulsado04"
      $pulsado02_carga = true
      @pulsado11_details = true
      @pulsado21_details  = true
      @pulsado42_details = true
      @pulsado43_details = true
      $pulsado05 = true


      $content_pane.remove($conected)
      $content_pane.remove($busquedas)
      $content_pane.remove($downloads_details_bar)
      $content_pane.remove($downloads_details_w_scroll)
      $content_pane.remove($lista_lbusq)
      $content_pane.remove($search_details_lista)
      $content_pane.remove($search_details_panel)
      $content_pane.remove($server_bar)
      $content_pane.remove($lista_lserve)
      $content_pane.remove($statistics_bar)
      $content_pane.remove($statistics)
      $content_pane.remove($lista_stats_client)
      $content_pane.remove($lista_stats_client_details)
      $content_pane.remove($lista_stats_client_details_w_scroll)
      $content_pane.remove($lista_stats_upload_details_w_scroll)
      $content_pane.remove($opciones)
      $content_pane.remove($options_bar)
      $content_pane.remove($list_options)
      $content_pane.remove($list_user)
      $content_pane.remove($list_group)
      $content_pane.remove($list_share)
      $content_pane.remove($list_options_details)               
      $content_pane.remove($ayuda)
      $content_pane.remove($fondo_principal)

      $content_pane.add($statistics_bar)
      $content_pane.add($lista_stats_client)
      $content_pane.add($fondo_principal)
      $content_pane.revalidate()
      $content_pane.repaint()
      
      $statistics_bar.setBounds(0,127,$content_pane.getWidth,40)
      $lista_stats_client.setBounds(0,168,$content_pane.getWidth,$content_pane.getHeight - 168)
      
    when 42  
      
      #puts "Pulsado04"
      $pulsado02_carga = true
      @pulsado11_details = true
      @pulsado21_details  = true
      @pulsado43_details = true
      $pulsado05 = true

      if @pulsado42_details || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight
          
          @pulsado42_details = false
          $content_pane.remove($conected)
          $content_pane.remove($busquedas)
          $content_pane.remove($downloads_details_bar)
          $content_pane.remove($downloads_details_w_scroll)
          $content_pane.remove($lista_lbusq)
          $content_pane.remove($search_details_lista)
          $content_pane.remove($search_details_panel)
          $content_pane.remove($server_bar)
          $content_pane.remove($lista_lserve)
          $content_pane.remove($statistics_bar)
          $content_pane.remove($statistics)
          $content_pane.remove($lista_stats_client)
          $content_pane.remove($lista_stats_client_details)
          $content_pane.remove($lista_stats_upload_details_w_scroll)
          $content_pane.remove($opciones)
          $content_pane.remove($options_bar)
          $content_pane.remove($list_options)
          $content_pane.remove($list_user)
          $content_pane.remove($list_group)
          $content_pane.remove($list_share)
          $content_pane.remove($list_options_details)                   
          $content_pane.remove($ayuda)
          $content_pane.remove($fondo_principal)

          $content_pane.add($statistics_bar)
          $content_pane.add($lista_stats_client_details_w_scroll)
          $content_pane.add($fondo_principal)
      
          $content_pane.revalidate()
          $content_pane.repaint()
      
          $statistics_bar.setBounds(0,127,$content_pane.getWidth,40)
          $lista_stats_client_details_w_scroll.setBounds(0,168,$content_pane.getWidth,$content_pane.getHeight - 168 )
      
          $content_pane_prev_wsize = $content_pane.getWidth 
          $content_pane_prev_hsize = $content_pane.getHeight

          $lista_stats_client_details.setLayout(GridLayout.new)  
          $lista_stats_client_details_w_scroll.setPreferredSize(Dimension.new($lista_stats_client_details.getWidth,$lista_stats_client_details.getHeight - 168 ))
          
          
          $back_statistics.setBounds(0,0,$content_pane.getWidth,40)
          $icon_back_statistics = ImageIcon.new($icon_back_statistics.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
          $back_statistics.setIcon($icon_back_statistics)
          $statistics_bar.setBounds(0,127,$content_pane.getWidth,40)

      end #if @pulsado11_details || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight

    when 43
    
      $pulsado02_carga = true
      @pulsado11_details = true
      @pulsado21_details  = true
      
      if @pulsado43_details || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight
         @pulsado43_details = false
         
          $content_pane.remove($conected)
          $content_pane.remove($busquedas)
          $content_pane.remove($downloads_details_bar)
          $content_pane.remove($downloads_details_w_scroll)
          $content_pane.remove($lista_lbusq)
          $content_pane.remove($search_details_lista)
          $content_pane.remove($search_details_panel)
          $content_pane.remove($server_bar)
          $content_pane.remove($lista_lserve)
          $content_pane.remove($statistics_bar)
          $content_pane.remove($statistics)
          $content_pane.remove($lista_stats_client)
          $content_pane.remove($lista_stats_client_details)
          $content_pane.remove($statistics_bar)
          $content_pane.remove($lista_stats_client_details_w_scroll)
          $content_pane.remove($lista_stats_upload_details_w_scroll)
          $content_pane.remove($opciones)
          $content_pane.remove($options_bar)
          $content_pane.remove($list_options)
          $content_pane.remove($list_user)
          $content_pane.remove($list_group)
          $content_pane.remove($list_share)
          $content_pane.remove($list_options_details)                   
          $content_pane.remove($ayuda)
          $content_pane.remove($fondo_principal)
          
          $content_pane.add($statistics_bar)
          $content_pane.add($lista_stats_upload_details_w_scroll)
          $content_pane.add($fondo_principal)
          
          $content_pane.revalidate()
          $content_pane.repaint()
          
          $statistics_bar.setBounds(0,127,$content_pane.getWidth,40)
          $lista_stats_upload_details_w_scroll.setBounds(0,168,$content_pane.getWidth,$content_pane.getHeight - 168 )

          
          $content_pane_prev_wsize = $content_pane.getWidth 
          $content_pane_prev_hsize = $content_pane.getHeight

          $lista_stats_upload_details.setLayout(GridLayout.new)  
          $lista_stats_upload_details_w_scroll.setPreferredSize(Dimension.new($lista_stats_upload_details.getWidth, $lista_stats_upload_details.getHeight - 168))

          $back_statistics.setBounds(0,0,$content_pane.getWidth,40)
          $icon_back_statistics = ImageIcon.new($icon_back_statistics.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
          $back_statistics.setIcon($icon_back_statistics)
          $statistics_bar.setBounds(0,127,$content_pane.getWidth,40)
          
      end #if @pulsado43_details || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight

    when 5
      #puts "Pulsado05"
      $pulsado02_carga = true
      @pulsado11_details = true
      @pulsado21_details  = true
      @pulsado42_details = true
      @pulsado43_details = true
      $pulsado51 = true
      $pulsado52 = true
      $pulsado53 = true
      $options_op5_button.setVisible false
      $options_op6_button.setVisible false
           
      if $pulsado5 || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight

         if $conexion.ctsecciones_lista
            sections = Array.new
            op_list = Array.new
            ranges = Array.new
            sections =$conexion.cver_valores_secciones_msg
            i = 0
            sections.each do |line|
                   op_list[i] = [line]
                   i += 1  
            end #sections.each do |line|
         end #if conexion.ctsecciones_lista
         $pulsado5 = false

         
         $modelo_options_client.actualiza(op_list,["Options"])
         $tabla_options_client.getSelectionModel.addListSelectionListener(RowListener.new($tabla_options_client))
  
         $content_pane.remove($conected)
         $content_pane.remove($lista)
         $content_pane.remove($downloads_details_bar)
         $content_pane.remove($downloads_details_w_scroll)
         $content_pane.remove($busquedas)
         $content_pane.remove($lista_lbusq)
         $content_pane.remove($search_details_lista)
         $content_pane.remove($search_details_panel)
         $content_pane.remove($lista_lserve)
         $content_pane.remove($server_bar)
         $content_pane.remove($statistics)
         $content_pane.remove($lista_stats_client)
         $content_pane.remove($lista_stats_client_details)
         $content_pane.remove($lista_stats_client_details_w_scroll)
         $content_pane.remove($lista_stats_upload_details_w_scroll)
         $content_pane.remove($statistics_bar)
         $content_pane.remove($options_bar)
         $content_pane.remove($list_options)
         $content_pane.remove($list_user)
         $content_pane.remove($list_group)
         $content_pane.remove($list_share)
         $content_pane.remove($list_options_details)                  
         $content_pane.remove($ayuda)
         $content_pane.remove($fondo_principal)

         $content_pane.add($options_bar)
         $content_pane.add($list_options)
      
         $content_pane.add($fondo_principal)
         $content_pane.revalidate()
         $content_pane.repaint()


         $content_pane_prev_wsize = $content_pane.getWidth 
         $content_pane_prev_hsize = $content_pane.getHeight
         
         $back_options.setBounds(0,0,$content_pane.getWidth,40)
         $icon_back_options = ImageIcon.new($icon_back_options.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
         $back_options.setIcon($icon_back_options)
         $options_bar.setBounds(0,127,$content_pane.getWidth,40)
         
         $list_options.setBounds(0,168,$content_pane.getWidth,$content_pane.getHeight - 168)
        
      end #if @pulsado5_details || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight

    when 51
      #puts "opcion51"
      $pulsado02_carga = true
      @pulsado11_details = true
      @pulsado21_details  = true
      $pulsado52 = true
      $pulsado53 = true

      if $pulsado51 || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight
      
         $pulsado51 = false
         $safe_cancel = true
      
         $modelo_options_details.actualiza($op_details,["Options"])
         $tabla_options_details.getSelectionModel.addListSelectionListener(RowListener_options.new($tabla_options_details))
         
         $content_pane.remove($conected)
         $content_pane.remove($lista)
         $content_pane.remove($downloads_details_bar)
         $content_pane.remove($downloads_details_w_scroll)
         $content_pane.remove($busquedas)
         $content_pane.remove($lista_lbusq)
         $content_pane.remove($search_details_lista)
         $content_pane.remove($search_details_panel)
         $content_pane.remove($lista_lserve)
         $content_pane.remove($server_bar)
         $content_pane.remove($statistics)
         $content_pane.remove($lista_stats_client)
         $content_pane.remove($lista_stats_client_details)
         $content_pane.remove($lista_stats_client_details_w_scroll)
         $content_pane.remove($lista_stats_upload_details_w_scroll)
         $content_pane.remove($statistics_bar)
         $content_pane.remove($options_bar)
         $content_pane.remove($list_options)   
         $content_pane.remove($list_user) 
         $content_pane.remove($list_group)
         $content_pane.remove($list_share)
         $content_pane.remove($list_options_details)
         $content_pane.remove($ayuda)
         $content_pane.remove($fondo_principal)

         $content_pane.add($options_bar)
         $content_pane.add($list_options_details)
      
         $content_pane.add($fondo_principal)
         $content_pane.revalidate()
         $content_pane.repaint()

         $content_pane_prev_wsize = $content_pane.getWidth 
         $content_pane_prev_hsize = $content_pane.getHeight
         
         $back_options.setBounds(0,0,$content_pane.getWidth,40)
         $icon_back_options = ImageIcon.new($icon_back_options.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
         $back_options.setIcon($icon_back_options)
         $options_bar.setBounds(0,127,$content_pane.getWidth,40)
      
         $list_options_details.setBounds(0,168,$content_pane.getWidth,$content_pane.getHeight - 168)


      end #if $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight

    when 52      
    
      $pulsado02_carga = true
      @pulsado11_details = true
      @pulsado21_details  = true
      $pulsado51 = true
      $pulsado53 = true

      $options_op5_button.setVisible true
      $options_op6_button.setVisible false
            
      if $conexion.ctusers
            user_index = $conexion.cusers_as_matrix
            $modelo_user.actualiza(user_index)
            group_index = $conexion.cgroups_as_matrix             
            $modelo_group.actualiza(group_index)
      else
            JOptionPane.showMessageDialog panel, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE                    
      end #if $conexion.ctusers


      if $pulsado52 || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight ||  $user_index_ant != user_index || $group_index_ant != group_index
      
         $tabla_user.getSelectionModel.clearSelection
         $modelo_user.fireTableDataChanged
         
         $tabla_group.getSelectionModel.clearSelection
         $modelo_group.fireTableDataChanged
      
         $pulsado52 = false
         $safe_cancel = true
      

            
            $tabla_user.getSelectionModel.clearSelection
            $modelo_user.fireTableDataChanged          
            
            $tabla_group.getSelectionModel.clearSelection
            $modelo_group.fireTableDataChanged          
           
            $content_pane.remove($conected)
            $content_pane.remove($lista)
            $content_pane.remove($downloads_details_bar)
            $content_pane.remove($downloads_details_w_scroll)
            $content_pane.remove($busquedas)
            $content_pane.remove($lista_lbusq)
            $content_pane.remove($search_details_lista)
            $content_pane.remove($search_details_panel)
            $content_pane.remove($lista_lserve)
            $content_pane.remove($server_bar)
            $content_pane.remove($statistics)
            $content_pane.remove($lista_stats_client)
            $content_pane.remove($lista_stats_client_details)
            $content_pane.remove($lista_stats_client_details_w_scroll)
            $content_pane.remove($lista_stats_upload_details_w_scroll)
            $content_pane.remove($statistics_bar)
            $content_pane.remove($options_bar)
            $content_pane.remove($list_options)
            $content_pane.remove($list_user)
            $content_pane.remove($list_group)
            $content_pane.remove($list_share)
            $content_pane.remove($list_options_details)         
            $content_pane.remove($ayuda)
            $content_pane.remove($fondo_principal)

            $content_pane.add($options_bar)
            $content_pane.add($list_user)
            $content_pane.add($list_group)

      
            $content_pane.add($fondo_principal)
            $content_pane.revalidate()
            $content_pane.repaint()
            
         $content_pane_prev_wsize = $content_pane.getWidth 
         $content_pane_prev_hsize = $content_pane.getHeight
         $user_index_ant = user_index
         $group_index_ant = group_index
         
         $back_options.setBounds(0,0,$content_pane.getWidth,40)
         $icon_back_options = ImageIcon.new($icon_back_options.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
         $back_options.setIcon($icon_back_options)
         $options_bar.setBounds(0,127,$content_pane.getWidth,40)
         
         $tabla_user.getColumnModel.getColumn(10).setMaxWidth($content_pane.getWidth/2000)
         $tabla_user.getColumnModel.getColumn(10).setMinWidth($content_pane.getWidth/2000)
         $tabla_user.getColumnModel.getColumn(10).setPreferredWidth($content_pane.getWidth/2000)
         
         $tabla_group.getColumnModel.getColumn(6).setMaxWidth($content_pane.getWidth/2000)
         $tabla_group.getColumnModel.getColumn(6).setMinWidth($content_pane.getWidth/2000)
         $tabla_group.getColumnModel.getColumn(6).setPreferredWidth($content_pane.getWidth/2000)
      
         $list_user.setBounds(0,168,$content_pane.getWidth,($content_pane.getHeight - 168)/2)
         $list_group.setBounds(0,$list_user.getHeight + 168 ,$content_pane.getWidth, $content_pane.getHeight - 168 - $list_user.getHeight)

         
         
      end #if $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight
    
    when 53  
    
      $pulsado02_carga = true
      @pulsado11_details = true
      @pulsado21_details  = true
      $options_op5_button.setVisible false
      $options_op6_button.setVisible true
      $pulsado51 = true
      $pulsado52 = true
            
      $tabla_share.getSelectionModel.clearSelection
      $modelo_share.fireTableDataChanged
      
      
      if $conexion.ctshares
         i = 0
         @share_matrix = Array.new
         $conexion.cver_valores_shares_msg.each do |line| 
           if i > 0
              @share_submatrix = Array.new
              y = 0
              line.split(' ').each do | word|
                 @share_submatrix[y] = word
                 y += 1
              end #line.split(' ') do | word|
              @share_matrix[i - 1] = @share_submatrix
           end #if i > 0
            i += 1
          end #$conexion.cver_valores_shares_msg.each do |line| 
                      
      else
          JOptionPane.showMessageDialog panel, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
      end #if $conexion.ctshares
            
      $modelo_share.actualiza(@share_matrix)

      if $pulsado53 || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight || $share_index_ant != @share_matrix
      
         
            $tabla_share.getSelectionModel.clearSelection
            $modelo_share.fireTableDataChanged
       
            $pulsado53 = false
            $safe_cancel = true
      
            $tabla_share.getSelectionModel.clearSelection
            $modelo_share.fireTableDataChanged          
           
            $content_pane.remove($conected)
            $content_pane.remove($lista)
            $content_pane.remove($downloads_details_bar)
            $content_pane.remove($downloads_details_w_scroll)
            $content_pane.remove($busquedas)
            $content_pane.remove($lista_lbusq)
            $content_pane.remove($search_details_lista)
            $content_pane.remove($search_details_panel)
            $content_pane.remove($lista_lserve)
            $content_pane.remove($server_bar)
            $content_pane.remove($statistics)
            $content_pane.remove($lista_stats_client)
            $content_pane.remove($lista_stats_client_details)
            $content_pane.remove($lista_stats_client_details_w_scroll)
            $content_pane.remove($lista_stats_upload_details_w_scroll)
            $content_pane.remove($statistics_bar)
            $content_pane.remove($options_bar)
            $content_pane.remove($list_options)
            $content_pane.remove($list_user)
            $content_pane.remove($list_group)
            $content_pane.remove($list_share)
            $content_pane.remove($list_options_details)         
            $content_pane.remove($ayuda)
            $content_pane.remove($fondo_principal)

            $content_pane.add($options_bar)
            $content_pane.add($list_share)
      
            $content_pane.add($fondo_principal)
            $content_pane.revalidate()
            $content_pane.repaint()
            
         $content_pane_prev_wsize = $content_pane.getWidth 
         $content_pane_prev_hsize = $content_pane.getHeight
         $share_index_ant = @share_matrix
         
         $back_options.setBounds(0,0,$content_pane.getWidth,40)
         $icon_back_options = ImageIcon.new($icon_back_options.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
         $back_options.setIcon($icon_back_options)
         $options_bar.setBounds(0,127,$content_pane.getWidth,40)
         
         $tabla_share.getColumnModel.getColumn(4).setMaxWidth($content_pane.getWidth/2000)
         $tabla_share.getColumnModel.getColumn(4).setMinWidth($content_pane.getWidth/2000)
         $tabla_share.getColumnModel.getColumn(4).setPreferredWidth($content_pane.getWidth/2000)
      
         $list_share.setBounds(0,168,$content_pane.getWidth,$content_pane.getHeight - 168)

         
         
      end #if $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight
    
    when 6
      #puts "Pulsado06"
      $pulsado02_carga = true
      @pulsado11_details = true
      @pulsado21_details  = true
      $pulsado05 = true
      $ayuda.setBounds(0,128,$content_pane.getWidth,$content_pane.getHeight - 128)
    when 7
      #puts "PulsadoExit"
      really_exit = JOptionPane.showConfirmDialog $content_pane, "Has been pressed out. Are You?", "Confirmation...",  JOptionPane::YES_NO_OPTION, JOptionPane::QUESTION_MESSAGE
      if  really_exit == javax.swing.JOptionPane::YES_OPTION
        System.exit 0
      else
        $option = $option_prev
      end #really_exit == javax.swing.JOptionPane::YES_OPTION

    end #$option


  end  #actionPerformed(e)

  def createAndShowGUI
    #puts "13class Main.createAndShowGUI"
    $conexion.ctversion
    $frame = JFrame.new(" Connected to - " + $conexion.cver_ip_value + "    Client Version - " + $conexion.ctversion_retorno_msg[0].to_s )
    $frame.setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
    animator = createContentPane
    $frame.add(animator, BorderLayout::CENTER)
    $frame.setSize 900,650
    @app_icon = Toolkit.getDefaultToolkit().getImage("01.png");
    $frame.setIconImage(@app_icon)

    $frame.setVisible(true)
    startAnimation
  end #createAndShowGUI

  def run
    if $conexion.estado_conectatelnet == true
       #puts "14class Main.run"
       createAndShowGUI
    end #if $conexion.estado_conectatelnet == true
  end #run
  
  def prio_to_number(prio)
    case prio
    when "Normal"
        return 0
    when "Low "
        return -10
    when "Very low"
        return -20
    when "High"
        return 10
    when "Very High"
        return 20
    else
        return prio.to_i
    end
  end #def prio_to_number(prio)
 
end #Main

class Action01 < MouseAdapter
  def mouseClicked e
      $option = 1
      $content_pane.remove($conected)
      $content_pane.remove($busquedas)
      $content_pane.remove($downloads_details_bar)
      $content_pane.remove($downloads_details_w_scroll)
      $content_pane.remove($lista_lbusq)
      $content_pane.remove($search_details_lista)
      $content_pane.remove($search_details_panel)
      $content_pane.remove($server_bar)
      $content_pane.remove($lista_lserve)
      $content_pane.remove($statistics_bar)
      $content_pane.remove($statistics)
      $content_pane.remove($lista_stats_client)
      $content_pane.remove($lista_stats_client_details)
      $content_pane.remove($lista_stats_client_details_w_scroll)
      $content_pane.remove($lista_stats_upload_details_w_scroll)
      $content_pane.remove($opciones)
      $content_pane.remove($options_bar)
      $content_pane.remove($list_options)
      $content_pane.remove($list_user)
      $content_pane.remove($list_group)
      $content_pane.remove($list_share)
      $content_pane.remove($list_options_details)               
      $content_pane.remove($ayuda)
      $content_pane.remove($fondo_principal)

      $content_pane.add($lista)
      $content_pane.add($fondo_principal)
      $content_pane.revalidate()
      $content_pane.repaint()

      if $conexion.ctestado
        if $conexion.ctdescargas("")
          matrix = $conexion.ctdescargas_retorno_as_matrix
          columns = $conexion.ctdescargas_retorno_as_matrix_columns
          $modelo.actualiza(matrix,columns)
          $tabla.getSelectionModel.addListSelectionListener(RowListener.new($tabla))
          $tabla.getColumnModel.getColumn(0).setMaxWidth(0)
          $tabla.getColumnModel.getColumn(0).setMinWidth(0)
          $tabla.getColumnModel.getColumn(0).setPreferredWidth(0)
          $tabla.getColumnModel.getColumn(1).setPreferredWidth($content_pane.getWidth/3)
        end
      else
        JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
      end #conexion.ctestado

      $lista.setBounds(0,128,$content_pane.getWidth,$content_pane.getHeight - 128)
  end #mouseClicked
  def mouseEntered e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::HAND_CURSOR)
  end #mouseEntered
  def mouseExited e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::DEFAULT_CURSOR)
  end # mouseExited

end #SalirAction < MouseAdapter

class Action02 < MouseAdapter
  def mouseClicked e
      $option = 2
      if $pulsado02_carga || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight 
        $pulsado02_carga = false
        $content_pane.remove($conected)
        $content_pane.remove($lista)
        $content_pane.remove($downloads_details_bar)
        $content_pane.remove($downloads_details_w_scroll)
        $content_pane.remove($search_details_lista)
        $content_pane.remove($search_details_panel)
        $content_pane.remove($server_bar)
        $content_pane.remove($lista_lserve)
        $content_pane.remove($statistics_bar)
        $content_pane.remove($statistics)
        $content_pane.remove($lista_stats_client)
        $content_pane.remove($lista_stats_client_details)
        $content_pane.remove($lista_stats_client_details_w_scroll)
        $content_pane.remove($lista_stats_upload_details_w_scroll)
        $content_pane.remove($opciones)
        $content_pane.remove($options_bar)
        $content_pane.remove($list_options)
        $content_pane.remove($list_user)
        $content_pane.remove($list_group)
        $content_pane.remove($list_share)
        $content_pane.remove($list_options_details)                 
        $content_pane.remove($ayuda)
        $content_pane.remove($fondo_principal)

        $content_pane.add($busquedas)
        $content_pane.add($lista_lbusq)
        $content_pane.add($fondo_principal)
        $content_pane.revalidate()
        $content_pane.repaint()
        $back_search.setBounds(0,0,$content_pane.getWidth,40)
        $icon_back_search = ImageIcon.new($icon_back_search.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
        $back_search.setIcon($icon_back_search)
        $busquedas.setBounds(0,127,$content_pane.getWidth,40)
    

        $content_pane_prev_wsize = $content_pane.getWidth
        $content_pane_prev_hsize = $content_pane.getHeight
      end  # if $pulsado02_carga || $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight 
      if $conexion.ctlista_busqueda
        cuerpo = Array.new
        i  = 0
        $conexion.ctlista_busqueda_retorno_msg.each do |valor|
          y = 0
          subcuerpo = Array.new
          subcuerpo[y] = valor.to_s
          cuerpo[i]  = subcuerpo
          i  +=1
          y +=1
        end #if $conexion.ctlista_busqueda

        $modelo_lbusq.actualiza(cuerpo)
        $tabla_lbusq.getColumnModel.getColumn(0).setPreferredWidth($content_pane.getWidth/6)
      else
        JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
      end  #if $conexion.cestado

      $lista_lbusq.setBounds(0,165,$content_pane.getWidth,$content_pane.getHeight - 165)
  end #mouseClicked
  def mouseEntered e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::HAND_CURSOR)
  end #mouseEntered
  def mouseExited e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::DEFAULT_CURSOR)
  end # mouseExited

end #SalirAction < MouseAdapter

class Action03 < MouseAdapter
  def mouseClicked e
      $option = 3
      $content_pane_prev_wsize = nil 
      $content_pane_prev_hsize = nil
      
      if $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight 


         $tabla_lserve.getSelectionModel.clearSelection
         $modelo_lserve.fireTableDataChanged
         $content_pane.revalidate()
         $content_pane.repaint()
         
         $content_pane.remove($conected)
         $content_pane.remove($lista)
         $content_pane.remove($downloads_details_bar)
         $content_pane.remove($downloads_details_w_scroll)
         $content_pane.remove($busquedas)
         $content_pane.remove($lista_lbusq)
         $content_pane.remove($search_details_lista)
         $content_pane.remove($search_details_panel)
         $content_pane.remove($statistics)
         $content_pane.remove($lista_stats_client)
         $content_pane.remove($lista_stats_client_details)
         $content_pane.remove($lista_stats_client_details_w_scroll)
         $content_pane.remove($lista_stats_upload_details_w_scroll)
         $content_pane.remove($statistics_bar)
         $content_pane.remove($opciones)
         $content_pane.remove($options_bar)
         $content_pane.remove($list_options)
         $content_pane.remove($list_user)
         $content_pane.remove($list_group)
         $content_pane.remove($list_share)
         $content_pane.remove($list_options_details)                  
         $content_pane.remove($ayuda)
         $content_pane.remove($fondo_principal)

         $content_pane.add($server_bar)
         $content_pane.add($lista_lserve)
         $content_pane.add($fondo_principal)
         
         $back_server.setBounds(0,0,$content_pane.getWidth,40)
         $icon_back_server = ImageIcon.new($icon_back_server.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
         $back_server.setIcon($icon_back_server)
         
         $server_bar.setBounds(0,127,$content_pane.getWidth,40)
         $content_pane.revalidate()
         $content_pane.repaint()

         $content_pane_prev_wsize = $content_pane.getWidth 
         $content_pane_prev_hsize = $content_pane.getHeight
         
         
         if $server_all
            if $conexion.ctlista_server 
               matrix = $conexion.ctserver_return_as_matrix 
               columns = $conexion.ctserver_return_as_matrix_columns
               $modelo_lserve.actualiza(matrix)
            else
               JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
            end #if $conexion.ctlista_server
         else
            if $conexion.ctlista_server_conected
               matrix = $conexion.ctserver_connected_return_as_matrix
               columns = $conexion.ctserver_return_as_matrix_columns
               $modelo_lserve.actualiza(matrix)
            else
               JOptionPane.showMessageDialog  $content_pane, $conexion.conectatelnet_error_msg.to_s, "Error", JOptionPane::ERROR_MESSAGE
            end #if $conexion.ctlista_server_conected
         end # if $server_all

         $tabla_lserve.getColumnModel.getColumn(1).setMaxWidth(0)
         $tabla_lserve.getColumnModel.getColumn(1).setMinWidth(0)
         $tabla_lserve.getColumnModel.getColumn(1).setPreferredWidth(0)
         
         $tabla_lserve.getColumnModel.getColumn(0).setMaxWidth($content_pane.getWidth/12)
         $tabla_lserve.getColumnModel.getColumn(0).setMinWidth($content_pane.getWidth/12)
         $tabla_lserve.getColumnModel.getColumn(0).setPreferredWidth($content_pane.getWidth/12)        
         $tabla_lserve.getColumnModel.getColumn(2).setPreferredWidth($content_pane.getWidth/6)
         $tabla_lserve.getColumnModel.getColumn(3).setPreferredWidth($content_pane.getWidth/4)
         $tabla_lserve.getColumnModel.getColumn(9).setMaxWidth($content_pane.getWidth/2000)
         $tabla_lserve.getColumnModel.getColumn(9).setMinWidth($content_pane.getWidth/2000)
         $tabla_lserve.getColumnModel.getColumn(9).setPreferredWidth($content_pane.getWidth/2000)
         
         $lista_lserve.setBounds(0,165,$content_pane.getWidth,$content_pane.getHeight - 165)         
         
       end #if $content_pane_prev_wsize != $content_pane.getWidth || $content_pane_prev_hsize != $content_pane.getHeight 
  end #mouseClicked
  def mouseEntered e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::HAND_CURSOR)
  end #mouseEntered
  def mouseExited e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::DEFAULT_CURSOR)
  end # mouseExited

end #SalirAction < MouseAdapter

class Action04 < MouseAdapter
  def mouseClicked e
      $option = 4
      $content_pane.remove($conected)
      $content_pane.remove($lista)
      $content_pane.remove($downloads_details_bar)
      $content_pane.remove($downloads_details_w_scroll)
      $content_pane.remove($busquedas)
      $content_pane.remove($lista_lbusq)
      $content_pane.remove($search_details_lista)
      $content_pane.remove($search_details_panel)
      $content_pane.remove($server_bar)
      $content_pane.remove($lista_lserve)
      $content_pane.remove($lista_stats_client)
      $content_pane.remove($lista_stats_client_details)
      $content_pane.remove($lista_stats_client_details_w_scroll)
      $content_pane.remove($lista_stats_upload_details_w_scroll)
      $content_pane.remove($opciones)
      $content_pane.remove($options_bar)
      $content_pane.remove($list_options)
      $content_pane.remove($list_user)
      $content_pane.remove($list_group)
      $content_pane.remove($list_share)
      $content_pane.remove($list_options_details)               
      $content_pane.remove($ayuda)
      $content_pane.remove($fondo_principal)

      $content_pane.add($statistics_bar)
      $content_pane.add($statistics)
      $content_pane.add($fondo_principal)

      $back_statistics.setBounds(0,0,$content_pane.getWidth,40)
      $icon_back_statistics = ImageIcon.new($icon_back_statistics.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
      $back_statistics.setIcon($icon_back_statistics)
      $statistics_bar.setBounds(0,127,$content_pane.getWidth,40)

      $content_pane.revalidate()
      $content_pane.repaint()
      $statistics.setBounds(0,168,$content_pane.getWidth,$content_pane.getHeight - 168)
      
      $down_graphic.setBounds 0,0,$content_pane.getWidth,($content_pane.getHeight - 168) /2
      $upload_graphic.setBounds 0,($content_pane.getHeight - 168 )/2,$content_pane.getWidth,($content_pane.getHeight - 168)/2
  end #mouseClicked
  def mouseEntered e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::HAND_CURSOR)
  end #mouseEntered
  def mouseExited e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::DEFAULT_CURSOR)
  end # mouseExited

end #SalirAction < MouseAdapter

class Action05 < MouseAdapter
  def mouseClicked e
      if $option == 51
         $pulsado51 = false
      else
         $pulsado51 = true
      end #if $option == 51
      $option = 5
      $pulsado5 = true
      
      if $conexion.ctsecciones_lista
         sections = Array.new
         op_list = Array.new
         ranges = Array.new
         sections =$conexion.cver_valores_secciones_msg
         i = 0
         sections.each do |line|
                 op_list[i] = [line]
                 i += 1  
         end #sections.each do |line|
      end #if conexion.ctsecciones_lista

      $modelo_options_client.actualiza(op_list,["Options"])
      $tabla_options_client.getSelectionModel.addListSelectionListener(RowListener.new($tabla_options_client))
      
      $content_pane.remove($conected)
      $content_pane.remove($lista)
      $content_pane.remove($downloads_details_bar)
      $content_pane.remove($downloads_details_w_scroll)
      $content_pane.remove($busquedas)
      $content_pane.remove($lista_lbusq)
      $content_pane.remove($search_details_lista)
      $content_pane.remove($search_details_panel)
      $content_pane.remove($lista_lserve)
      $content_pane.remove($server_bar)
      $content_pane.remove($statistics)
      $content_pane.remove($lista_stats_client)
      $content_pane.remove($lista_stats_client_details)
      $content_pane.remove($lista_stats_client_details_w_scroll)
      $content_pane.remove($lista_stats_upload_details_w_scroll)
      $content_pane.remove($statistics_bar)
      $content_pane.remove($options_bar)
      $content_pane.remove($list_options)
      $content_pane.remove($list_user)
      $content_pane.remove($list_group)
      $content_pane.remove($list_share)
      $content_pane.remove($list_options_details)         
      $content_pane.remove($ayuda)
      $content_pane.remove($fondo_principal)

      $content_pane.add($options_bar)
      $content_pane.add($list_options)
      
      $content_pane.add($fondo_principal)
      $content_pane.revalidate()
      $content_pane.repaint()

      
      $back_options.setBounds(0,0,$content_pane.getWidth,40)
      $icon_back_options = ImageIcon.new($icon_back_options.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
      $back_options.setIcon($icon_back_options)
      $options_bar.setBounds(0,127,$content_pane.getWidth,40)
      
      $list_options.setBounds(0,168,$content_pane.getWidth,$content_pane.getHeight - 168)
      
            
  end #mouseClicked
  def mouseEntered e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::HAND_CURSOR)
  end #mouseEntered
  def mouseExited e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::DEFAULT_CURSOR)
  end # mouseExited

end #SalirAction < MouseAdapter

class Action06 < MouseAdapter
  def mouseClicked e
      $option = 6
      $content_pane.remove($conected)
      $content_pane.remove($lista)
      $content_pane.remove($downloads_details_bar)
      $content_pane.remove($downloads_details_w_scroll)
      $content_pane.remove($busquedas)
      $content_pane.remove($lista_lbusq)
      $content_pane.remove($search_details_lista)
      $content_pane.remove($search_details_panel)
      $content_pane.remove($lista_lserve)
      $content_pane.remove($server_bar)
      $content_pane.remove($statistics)
      $content_pane.remove($lista_stats_client)
      $content_pane.remove($lista_stats_client_details)
      $content_pane.remove($lista_stats_client_details_w_scroll)
      $content_pane.remove($lista_stats_upload_details_w_scroll)
      $content_pane.remove($statistics_bar)
      $content_pane.remove($opciones)
      $content_pane.remove($options_bar)
      $content_pane.remove($list_options)
      $content_pane.remove($list_user)
      $content_pane.remove($list_group)
      $content_pane.remove($list_share)
      $content_pane.remove($list_options_details)               
      $content_pane.remove($fondo_principal)

      $content_pane.add($ayuda)
      $content_pane.add($fondo_principal)
      $content_pane.revalidate()
      $content_pane.repaint()

      $ayuda.setBounds(0,128,$content_pane.getWidth,$content_pane.getHeight - 128)
      $cadena_ayuda.setBounds(0,128,$content_pane.getWidth,$content_pane.getHeight - 128)
      
  end #mouseClicked
  def mouseEntered e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::HAND_CURSOR)
  end #mouseEntered
  def mouseExited e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::DEFAULT_CURSOR)
  end # mouseExited

end #SalirAction < MouseAdapter

class Action07 < MouseAdapter
  def mouseClicked e
      #puts "PulsadoExit"
      really_exit = JOptionPane.showConfirmDialog $content_pane, "Has been pressed out. Are You?", "Confirmation...",  JOptionPane::YES_NO_OPTION, JOptionPane::QUESTION_MESSAGE
      if  really_exit == javax.swing.JOptionPane::YES_OPTION
        System.exit 0
      else
      
      end #really_exit == javax.swing.JOptionPane::YES_OPTION
  end #mouseClicked
  def mouseEntered e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::HAND_CURSOR)
  end #mouseEntered
  def mouseExited e
    $frame.setCursor java.awt.Cursor.new(java.awt.Cursor::DEFAULT_CURSOR)
  end # mouseExited
end #SalirAction < MouseAdapter

class Content_pane_event 
include ComponentListener
 def componentResized e
    
    $icono_fondo_principal = ImageIcon.new($icono_fondo_principal.getImage().getScaledInstance( $content_pane.getWidth, $content_pane.getHeight, java.awt.Image::SCALE_FAST) )
    $fondo_principal.setIcon($icono_fondo_principal)
    $fondo_principal.setBounds(0,0,$content_pane.getWidth,$content_pane.getHeight)
    $content_pane.setBounds(0,0,$content_pane.getWidth,$content_pane.getHeight)
   
    $boton_01.setBounds((($content_pane.getWidth/2) - 40)  - 180, 0, $icono_01.getIconWidth, $icono_01.getIconHeight)
    $boton_02.setBounds((($content_pane.getWidth/2) - 40)  - 120, 0, $icono_02.getIconWidth, $icono_02.getIconHeight)
    $boton_03.setBounds((($content_pane.getWidth/2) - 40)  -  60, 0, $icono_03.getIconWidth, $icono_03.getIconHeight)
    $boton_04.setBounds((($content_pane.getWidth/2) - 40)       , 0, $icono_04.getIconWidth, $icono_04.getIconHeight)
    $boton_05.setBounds((($content_pane.getWidth/2) - 40)  +  60, 0, $icono_05.getIconWidth, $icono_05.getIconHeight)
    $boton_06.setBounds((($content_pane.getWidth/2) - 40)  + 120, 0, $icono_06.getIconWidth, $icono_06.getIconHeight)
    $boton_07.setBounds((($content_pane.getWidth/2) - 40)  + 180, 0, $icono_07.getIconWidth, $icono_07.getIconHeight)
    
    $picture.setBounds($content_pane.getWidth/2 - 900/2, 80, 900 ,50)
    $menu_fondo.setBounds(0,0,$content_pane.getWidth, 87)
    $picture_fondo.setBounds(0,87,$content_pane.getWidth,40)
    $icono_fondo_estado = ImageIcon.new($icono_fondo_estado.getImage().getScaledInstance( $content_pane.getWidth,40 , java.awt.Image::SCALE_FAST) )
    $icono_menu_fondo = ImageIcon.new($icono_fondo_principal.getImage().getScaledInstance($content_pane.getWidth,87, java.awt.Image::SCALE_FAST))
    $menu_fondo.setIcon($icono_menu_fondo)
    $picture_fondo.setIcon($icono_fondo_estado)

 end #def componentResized e
end # < class Content_pane_event < ComponentListener
