[Javanetsim-cvs] javaNetSim/guiUI MainScreen.java,1.33,1.34 TelnetEmulator.java,1.3,1.4
Status: Beta
Brought to you by:
darkkey
From: QweR <qw...@us...> - 2006-02-23 23:25:25
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23168/guiUI Modified Files: MainScreen.java TelnetEmulator.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** MainScreen.java 23 Feb 2006 15:13:53 -0000 1.33 --- MainScreen.java 23 Feb 2006 23:25:19 -0000 1.34 *************** *** 3175,3210 **** public void TelnetConnect(String inNodeName){ ! String ip = JOptionPane.showInputDialog(this, "Server IP:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); ! ! String port = JOptionPane.showInputDialog(this, "Server Port:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); ! ! if(port!=null && ip!=null){ ! ! try{ ! ! printNetworkStart(); ! ! //Timer timer = null; ! //timer=new Timer(); ! //timer.schedule(new TTask(this, 1),4000,4000); ! //=<150 ! //((Echo_tcp)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(30021)).SendEcho(msg, ip, Integer.valueOf(port).intValue(), Integer.valueOf(cnt).intValue()); ! TelnetEmulator t = new TelnetEmulator(this, ((Telnet_client)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(30023)),ip,Integer.valueOf(port).intValue()); ! t.pack(); ! t.setVisible(true); ! // ! //this.addToConsole("Trying to send echo message '" + msg + "' from " + inNodeName + " to " + ip + ":" + port + "\n"); ! ! }catch(Exception e){ ! ! addToConsole(e.toString()); ! ! } addHeader(); printLayerInfo(false); ! ! } ! } --- 3175,3202 ---- public void TelnetConnect(String inNodeName){ + String ip = JOptionPane.showInputDialog(this, "Server IP:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); + if(ip!=null){ + String port = JOptionPane.showInputDialog(this, "Server Port:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); + if(port!=null) { + try{ + printNetworkStart(); + //Timer timer = null; + //timer=new Timer(); + //timer.schedule(new TTask(this, 1),4000,4000); + //=<150 + //((Echo_tcp)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(30021)).SendEcho(msg, ip, Integer.valueOf(port).intValue(), Integer.valueOf(cnt).intValue()); + TelnetEmulator t = new TelnetEmulator(this, ((Telnet_client)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(30023)),ip,Integer.valueOf(port).intValue()); + t.pack(); + t.setVisible(true); + // + //this.addToConsole("Trying to send echo message '" + msg + "' from " + inNodeName + " to " + ip + ":" + port + "\n"); ! }catch(Exception e){ ! addToConsole(e.toString()); ! } addHeader(); printLayerInfo(false); ! } ! } } Index: TelnetEmulator.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/TelnetEmulator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TelnetEmulator.java 23 Feb 2006 15:13:53 -0000 1.3 --- TelnetEmulator.java 23 Feb 2006 23:25:19 -0000 1.4 *************** *** 23,26 **** --- 23,28 ---- import javax.swing.JTextField; + import javax.swing.JTextArea; + import java.awt.Insets; *************** *** 71,74 **** --- 73,79 ---- import core.TransportLayerException; + import java.awt.Font; + import java.awt.event.KeyListener; + /** * *************** *** 78,83 **** private final Telnet_client telnet; private JPanel panel; ! private JLabel terminal; private String text; MainScreen parent; --- 83,90 ---- private final Telnet_client telnet; private JPanel panel; ! // private JLabel terminal; ! private JTextArea terminal; private String text; + private KeyListener kl; MainScreen parent; *************** *** 90,109 **** text = ""; ! text += "Opening " + Host + ":" + Port + "..."; ! ! terminal = new JLabel(text); panel = new JPanel(); ! this.addKeyListener( new KeyAdapter(){ ! public void keyTyped(KeyEvent e) { ! ! char c = e.getKeyChar(); ! ! String s = String.valueOf(c).toString(); ! sendData(s); ! printInfo(); ! } }); --- 97,130 ---- text = ""; + text += "Opening " + Host + ":" + Port + "...\n"; ! //terminal = new JLabel(text); ! terminal = new JTextArea(text); ! terminal.setBackground(new Color(0)); ! terminal.setForeground(Color.WHITE); ! terminal.setEnabled(false); ! terminal.setFont(new Font("Courier New", Font.PLAIN, 12)); panel = new JPanel(); ! this.addKeyListener( kl = new KeyAdapter(){ ! public void keyPressed(KeyEvent e) { ! char c = e.getKeyChar(); ! if((int)c<65535) { ! String s = String.valueOf(c).toString(); ! sendData(s); ! printInfo(); ! } ! } }); + + // public void keyTyped(KeyEvent e) { + // + // char c = e.getKeyChar(); + // + // String s = String.valueOf(c).toString(); + // sendData(s); + // printInfo(); + // } + // }); *************** *** 116,120 **** panel.setLayout(new java.awt.BorderLayout()); ! panel.setPreferredSize(new java.awt.Dimension(600,100)); this.setContentPane(panel); --- 137,141 ---- panel.setLayout(new java.awt.BorderLayout()); ! panel.setPreferredSize(new java.awt.Dimension(600,500)); this.setContentPane(panel); *************** *** 155,160 **** public void recvData(String Data){ ! text += Data; ! terminal.setText(text); } --- 176,188 ---- public void recvData(String Data){ ! if(Data.compareTo("\nQUIT")==0) { ! this.removeKeyListener(kl); ! terminal.setText(text + "\nServer closed connection."); ! } ! else { ! if(Data.compareTo("\b")==0) text = text.substring(0, text.length()-1); ! else text += Data; ! terminal.setText(text + "_"); ! } } *************** *** 171,173 **** --- 199,205 ---- //!!!!!: add more headers here } + + public void exitWindow(){ + this.dispose(); + } } |