powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / Очень нужна помощь
6 сообщений из 31, страница 2 из 2
Очень нужна помощь
    #33295776
Фотография peter6636
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Как работать с командной строкой я разобрался, а вот как мне работать с telnet через jTextArea не могу понять.Короче мне нужно сделать все через GUI.
Пока что так:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
 import  com.jscape.inet.telnet.*;
 import  java.io.*;

 public   class  Telnet_Peter  extends  TelnetAdapter {

         private  Telnet telnet =  null ;
         private  OutputStream output =  null ;
         private   static  BufferedReader reader =  null ;
         private   boolean  connected = false;
         public  TelnetExample(String hostname)  throws  IOException, TelnetException {
          try {
                String input =  null ;
                telnet =  new  Telnet(hostname);
                telnet.addTelnetListener( this );
                telnet.connect();
                connected = true;
                output = telnet.getOutputStream();
                while  ((input = reader.readLine()) !=  null ) {
                         if  (connected) {
                                ((TelnetOutputStream) output).println(input);
                        }  else  {
                                 break ;
                        }
                }
         } catch (Exception e){
           System.out.println("exc="+e.toString());
         }
        }

         public   void  connected(TelnetConnectedEvent event) {
                System.out.println("Connected");
        }

         public   void  disconnected(TelnetDisconnectedEvent event) {
                connected = false;
                System.out.print("Разсоединение.  Нажмите Enter для выхода.");
        }

         public   void  doOption(DoOptionEvent event) {
                telnet.sendWontOption(event.getOption());
        }

         public   void  willOption(WillOptionEvent event) {
                telnet.sendDontOption(event.getOption());
        }

         public   void  dataReceived(TelnetDataReceivedEvent event) {
                System.out.print(event.getData());
        }

         public   static   void  main(String[] args) {
                 try  {
                    reader =  new  BufferedReader( new  InputStreamReader(System.in));
                        System.out.print("Введите имя хоста: ");
                        String hostname = reader.readLine();
                        Telnet_Peter example =  new  Telnet_Peter(hostname);
                }  catch  (Exception e) {
                        e.printStackTrace(System.out);
                }
        }
}
...
Рейтинг: 0 / 0
Очень нужна помощь
    #33295845
wessen
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
System.out.print(" Разсоединение. Нажмите Enter для выхода.");

:))
...
Рейтинг: 0 / 0
Очень нужна помощь
    #33295864
Фотография peter6636
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
wessen System.out.print(" Разсоединение. Нажмите Enter для выхода.");

:))
да хер с ним,как сделать то,что я описал выше
...
Рейтинг: 0 / 0
Очень нужна помощь
    #33296029
wessen
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
peter6636 wessen System.out.print(" Разсоединение. Нажмите Enter для выхода.");

:))
да хер с ним,как сделать то,что я описал выше

есть форма, на ней текстовое поле и кнобка, вводишь в текстовое поле команду, жмешь кнобку, в обработчике событий считываешь значение поля и передаешь это значение в свой класс Telnet-peter.
Какие ешо неясности? :)
...
Рейтинг: 0 / 0
Очень нужна помощь
    #33296091
Фотография Timm
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
ЗашедшийА вот от самого сана рекомендация в девелоперз тренингах:
тынц , тоже цитата: "A Vector is an historical collection class that acts like a growable array, but can store heterogeneous data elements. With the Java 2 SDK, version 2, the Vector class has been retrofitted into the Collections Framework hierarchy to implement the List interface. However, if you are using the new framework, you should use ArrayList, instead."

should Lingvo :
употребляется для выражения морального долга /* */ или совета и имеет в этом случае значение "должен", "следует", "следовало бы"


из первой ссылкиThe standard implementations of the Collections API interfaces (HashMap, TreeMap and the like) are defined with no built-in synchronization mechanisms. That way, single-thread applications do not pay the performance cost of unnecessary synchronization, and multithreaded applications that are already using synchronization do not incur the performance penalty that results from multiple synchronization.

For simple multithreading applications, an application can use the synchronized "wrapper" classes. For example, instead of creating a object using HashMap(), the app could use SynchronizedHashMap(). That implementation "wraps" a HashMap inside of an object which is synchronized.

Developers of multithreading will note that the wrapper classes provide relatively "unsophisticated" synchronization. It allows only one thread at a time to access the HashMap, even though multiple threads could be allowed to do so (if they were using different keys). The "wrapper" implementation also requires an extra method call. To achieve maximum parallelism or maximum performance, therefore, you would subclass one of the existing implementations and add synchronization mechanisms within them.

Whether you use the simple synchronized wrappers or provide your own more sophisticated synchronization mechanisms, the bottom line is that now you can choose when to incur the cost of synchronization, instead of having it foisted off on you. To developers obsessed with performance, that will come as great news.
...
Рейтинг: 0 / 0
Очень нужна помощь
    #33296122
Фотография peter6636
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
wessen peter6636 wessen System.out.print(" Разсоединение. Нажмите Enter для выхода.");

:))
да хер с ним,как сделать то,что я описал выше

есть форма, на ней текстовое поле и кнобка, вводишь в текстовое поле команду, жмешь кнобку, в обработчике событий считываешь значение поля и передаешь это значение в свой класс Telnet-peter.
Какие ешо неясности? :)
Ну что я совсем уже,так и есть у меня, но я не вижу в jTextArea приглашения для ввода логина и пароля, делаю таким макаром:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
 package  ptsist;

 import  com.jscape.inet.telnet.*;
 import  java.io.*;

 public   class  Telnet_Peter  extends  TelnetAdapter {

         private  Telnet telnet =  null ;
         private  OutputStream output =  null ;
         private   static  BufferedReader reader =  null ;
         private   boolean  connected = false;
         private  String host;
         private  Glavnoe ob;

         public  Telnet_Peter(String hostname,Glavnoe g)  throws  IOException {
           try  {
            host=hostname;
            ob=g;
            reader =  new  BufferedReader( new  InputStreamReader(System.in));
                     }  catch  (Exception e) {
                             e.printStackTrace(System.out);
                }
          try {
                String input =  null ;
 
                telnet =  new  Telnet(hostname);

                telnet.addTelnetListener( this );

                telnet.connect();
                connected = true;

                output = telnet.getOutputStream();

                 while  ((input = reader.readLine()) !=  null ) {
                         if  (connected) {
                                ((TelnetOutputStream) output).println(input);
                                ob.jTextArea1.setText(input);
                        }  else  {
                                 break ;
                        }
                }
         } catch (Exception e){
           System.out.println("exc="+e.toString());
         }
        }


         public   void  connected(TelnetConnectedEvent event) {
          ob.statusBar.setText("Соединение установлено");
               }

         public   void  disconnected(TelnetDisconnectedEvent event) {
                connected = false;
                ob.jTextArea1.setText("нажми энтэр");
        }

         public   void  doOption(DoOptionEvent event) {
                telnet.sendWontOption(event.getOption());
        }

         public   void  willOption(WillOptionEvent event) {
                telnet.sendDontOption(event.getOption());
        }

         public   void  dataReceived(TelnetDataReceivedEvent event) {
          ob.jTextArea1.setText(event.getData());
        }
}
...
Рейтинг: 0 / 0
6 сообщений из 31, страница 2 из 2
Форумы / Java [игнор отключен] [закрыт для гостей] / Очень нужна помощь
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]