Guest User

Untitled

a guest
Jun 25th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.22 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. import javax.microedition.midlet.*;
  7. import javax.microedition.lcdui.*;
  8. import java.io.*;
  9. import javax.microedition.io.*;
  10.  
  11. /**
  12.  * @author Игорь
  13.  */
  14. public class remains extends MIDlet {
  15.  
  16.  
  17.     public remains()
  18.     {
  19.         display = Display.getDisplay(this);
  20.         Pa = new paintP(this);
  21.         te = new test(this);
  22.     }
  23.  
  24.     private test te;
  25.     private paintP Pa;
  26.     private Display display;
  27.  
  28.  
  29.  
  30.     public void startApp() {
  31.         try {
  32.             StreamConnection sc = (StreamConnection) Connector.open("socket://127.0.0.1:1212");
  33.             DataInputStream dis = sc.openDataInputStream();
  34.             DataOutputStream dos = sc.openDataOutputStream();
  35.             dos.write("mobile get /chat\n".getBytes());
  36.             byte[] buffer = new byte [1024];
  37.             dis.read(buffer);
  38.             String message = new String(buffer);
  39.             int Inkk=0;
  40.             for (int i=0;i<buffer.length;i++)
  41.             {
  42.                 if(buffer[i]!=0)
  43.                 {
  44.                     Inkk++;
  45.                 }
  46.                 else
  47.                 {
  48.                     break;
  49.                 }
  50.             }
  51.             Pa.len = Inkk;
  52.             Pa.string = message;
  53. sc.close();
  54. System.out.print(message);
  55. display.setCurrent(Pa);
  56.         } catch (IOException ex) {
  57.             ex.printStackTrace();
  58.         }
  59.  
  60.  
  61.     }
  62.  
  63.     public void pauseApp() {
  64.     }
  65.  
  66.     public void destroyApp(boolean unconditional) {
  67.     }
  68. }
  69. class paintP extends Canvas implements CommandListener
  70. {
  71.     public String string;
  72.     public int offset;
  73.     public int len;
  74.  
  75.     public paintP(remains midlet)
  76.     {
  77.      //cmQuest
  78.  
  79.     }
  80.  
  81.     public void paint(Graphics g) {
  82.  
  83.  
  84. g.setColor(0xffffff);
  85. Font font = Font.getFont(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL);
  86. g.setFont(font);
  87. g.drawSubstring(string, offset, len,  10, 10, Graphics.TOP | Graphics.LEFT);
  88.  
  89.        
  90.     }
  91.  
  92.     public void commandAction(Command c, Displayable d) {
  93.  
  94.     }
  95.  
  96.  
  97. }
  98. class test
  99. {
  100.  public int ts = 10;
  101. public String stro = ("12345");
  102.     test(remains aThis) {
  103.    System.out.print(stro);
  104.    
  105.  
  106.     }
  107. }
Add Comment
Please, Sign In to add comment