#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Line Generatation after one by one (J2SE & J2ME)


    Can u please help me to draw a line in java.and then after another lines should be generated automatically after 1 minute delay.caan u plz help me to generate these lines.
    Code either in J2ME or J2SE.
    Thank you.
  2. #2
  3. No Profile Picture
    Choose Life...
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2006
    Location
    Scotland
    Posts
    461
    Rep Power
    513
    Show us what you have so far.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Unhappy Moving line


    i am not able to develop code.so i have nothing to show you.
    I want an application in which i can show a moving line and this line should show an arrow in moving direction.
    ...
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Exclamation Code...


    Here is the code...that i have develop but sleep thread is not working in it..



    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package Pack;
    import java.util.Timer;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    /**
    *
    * @author Rhitz
    */
    public class LineDemo extends MIDlet{

    private Display display;
    private DrawingCanvas canvas;
    private Timer timer;
    public LineDemo(){

    display=Display.getDisplay(this);
    timer=new Timer();
    canvas=new DrawingCanvas(this);
    // timer.schedule(timer,0,100);

    }
    protected void destroyApp(boolean unconditional){
    notifyDestroyed();
    }

    protected void pauseApp() {
    throw new UnsupportedOperationException("Not supported yet.");
    }

    protected void startApp() throws MIDletStateChangeException {
    display.setCurrent(canvas);
    Thread thread=new Thread();
    thread.start();
    }

    void exitMIDlet() {
    destroyApp(true);

    }
    }
    public class DrawingCanvas extends Canvas implements CommandListener {

    Timer timer=new Timer();

    private LineDemo a_midlet;
    private Command exit;
    int x1,y1,x2,y2;
    private Random random;

    public DrawingCanvas(LineDemo a_midlet){
    this.a_midlet=a_midlet;
    random=new java.util.Random();
    exit=new Command("Exit",Command.EXIT,1);
    addCommand(exit);
    setCommandListener(this);

    }
    protected void paint(Graphics g) {
    x1=50;
    y1=101;
    x2=85;
    y2=101;
    g.setColor(255, 255, 255);
    g.drawLine(x1, y1, x2, y2); //Starting position..
    // Starting positions (50,101,85,101)...
    for(int i=0;i<5;i++){
    try{
    Thread.sleep(5000);
    g.setColor(255, 255, 255);
    g.drawLine(x1, y1, x2, y2); //Starting position..
    g.drawLine(x1, y1, x1 + 5, y1 - 5);
    g.drawLine(x1, y1, x1 + 5, y1 + 5);
    x1 = x1 + 10;
    y1 = y1 + 10;
    x2 = x2 - 5;
    y2 = y2 - 2;

    }
    catch(Exception e)
    {
    System.out.println("Exception::"+e);
    }
    }
    }
    public void commandAction(Command c, Displayable d) {
    String label = c.getLabel();
    if (label.equals("Exit"))
    a_midlet.exitMIDlet(); }
    }

IMN logo majestic logo threadwatch logo seochat tools logo