Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- import javax.microedition.midlet.*;
- import javax.microedition.lcdui.*;
- import java.io.*;
- import javax.microedition.io.*;
- /**
- * @author Игорь
- */
- public class remains extends MIDlet {
- public remains()
- {
- display = Display.getDisplay(this);
- Pa = new paintP(this);
- te = new test(this);
- }
- private test te;
- private paintP Pa;
- private Display display;
- public void startApp() {
- try {
- StreamConnection sc = (StreamConnection) Connector.open("socket://127.0.0.1:1212");
- DataInputStream dis = sc.openDataInputStream();
- DataOutputStream dos = sc.openDataOutputStream();
- dos.write("mobile get /chat\n".getBytes());
- byte[] buffer = new byte [1024];
- dis.read(buffer);
- String message = new String(buffer);
- int Inkk=0;
- for (int i=0;i<buffer.length;i++)
- {
- if(buffer[i]!=0)
- {
- Inkk++;
- }
- else
- {
- break;
- }
- }
- Pa.len = Inkk;
- Pa.string = message;
- sc.close();
- System.out.print(message);
- display.setCurrent(Pa);
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
- public void pauseApp() {
- }
- public void destroyApp(boolean unconditional) {
- }
- }
- class paintP extends Canvas implements CommandListener
- {
- public String string;
- public int offset;
- public int len;
- public paintP(remains midlet)
- {
- //cmQuest
- }
- public void paint(Graphics g) {
- g.setColor(0xffffff);
- Font font = Font.getFont(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL);
- g.setFont(font);
- g.drawSubstring(string, offset, len, 10, 10, Graphics.TOP | Graphics.LEFT);
- }
- public void commandAction(Command c, Displayable d) {
- }
- }
- class test
- {
- public int ts = 10;
- public String stro = ("12345");
- test(remains aThis) {
- System.out.print(stro);
- }
- }
Add Comment
Please, Sign In to add comment