Chunky by FelipeFS
Chunky by FelipeFS
GPWiki.org
It is currently Thu Jul 24, 2014 4:57 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Java Noob
PostPosted: Thu Dec 22, 2011 9:39 am 
Shake'n'Baker
User avatar

Joined: Mon Jun 14, 2010 3:51 pm
Posts: 62
Code:
import java.awt.Canvas;
import java.awt.Graphics;
public class Project{   
    public static void main(String[] args) {
        javax.swing.JFrame Win = new javax.swing.JFrame("J-App");
        Win.setDefaultCloseOperation(Win.EXIT_ON_CLOSE);
        Win.setSize(400, 300);
        Win.setVisible(true);
       
        Canvas Cnvs = new Canvas();
        Win.add(Cnvs);
        Graphics g = Cnvs.getGraphics();
        g.drawLine(100, 100, 300, 200);
    }
}

If I run it normally I dont see the line.
But I run it in debug mode, I see the line.
What am I doing wrong?


Top
 Profile  
 
 Post subject: Re: Java Noob
PostPosted: Sun Jun 30, 2013 8:01 pm 
Level 1 Cleric

Joined: Sun Jun 30, 2013 7:54 pm
Posts: 11
Well I'm new myself, just looking through these old post in the first page : /

public static void main(String[] args) {
javax.swing.JFrame Win = new javax.swing.JFrame("J-App");
Win.setDefaultCloseOperation(Win.EXIT_ON_CLOSE);
Win.setSize(400, 300);
Win.setVisible(true);

Canvas Cnvs = new Canvas();
Win.add(Cnvs);
Graphics g = Cnvs.getGraphics();

while(true){
g.drawLine(100, 100, 300, 200);
}
}

I noticed that when run in either mode it does draw the line but just for a moment then it disappears, adding the infinite loop I got it to show the line, granted it's redrawing it non-stop haha.

Hope it helps.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group