public TelnetEmulator(MainScreen parent, Telnet_client telnet, String Host, int Port) {
        super("Telnet client");
        this.telnet = telnet;
        this.parent = parent;
        this.Host = Host;
        this.Port = Port;
        cmdline = "";
        
               
        text = "";
        text += "Opening " + Host + ":" + Port + "...\r\n";
        
        //terminal = new JLabel(text);
        terminal = new JTextArea(text);
        terminal.setEnabled(false);
        terminal.setEditable(false);
        terminal.setBackground(Color.BLACK);
        terminal.setForeground(Color.WHITE);
        terminal.setFont(new Font("Courier New", Font.PLAIN, 12));
        panel = new JPanel();
        scrollpane = new JScrollPane();
        
        this.addKeyListener( kl = new KeyAdapter(){
//        terminal.addKeyListener( kl = new KeyAdapter(){
            @Override
			public void keyPressed(KeyEvent e) {
                char c = e.getKeyChar();
                if(c<65535) {
                    String s;
                    switch(c){
                        case 0x4:{
                            cmdline = "quit";
                            s = "\r\n";
                            break;
                        }
                        case 0xD:
                        case 0xA:   {
                            s = "\r\n";
                            break;
                        }
                        default: s = String.valueOf(c).toString();
                    }
                    sendData(s);
                }
                else {
//                    String s = String.valueOf(e.getKeyCode()).toString();
//                    sendData(s);
//                    printInfo();
                }
            }
        });
         
        
        this.addWindowListener( new java.awt.event.WindowAdapter() {
            @Override
			public void windowClosing(WindowEvent winEvt) {
                exitWindow();
            }
        });
        
        panel.setLayout(new java.awt.BorderLayout());
        
        panel.setPreferredSize(new java.awt.Dimension(600,500));
        
        this.setContentPane(panel);
        panel.add(scrollpane);  
        scrollpane.setViewportView(terminal);    
        

    }