• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to draw directly to the monitor without a While loop

 
Arturo Gamboa
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this idea has gone round round in my head, and i can figure it out..

how do i draw a simple image to the monitor without a loop.

the common way to draw an image to the monitor as i have seen so far, is inside a while loop( active rendering i think), otherwise it wont draw


if i do it that way it get drew to the screen.

i want to know if thres a way to get something drawn out of a single sentence like the last one but wihout the loop.






 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What GUI/Graphics library are you using? Swing? If so, then your best bet is to study the Sun/Oracle 2D Graphics tutorials.

Much luck!
 
Arturo Gamboa
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for the advice, i knew it could be done with 2D.
anyway, i have the curiosity if theres a way other than using Java 2d graphics.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arturo Gamboa wrote:thank you for the advice, i knew it could be done with 2D.
anyway, i have the curiosity if theres a way other than using Java 2d graphics.


I'm having a great deal of difficulty understanding just what you're asking here. It's kind of like asking if one could prepare dinner without using food. Can you give us more details regarding just what you're trying to do?
 
Arturo Gamboa
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for not explaining myself better.

ill do it more explicitly-

ill write down the the methods i know so far to draw an image:

1.- using paint method from inside the component(passive rendering):



2.-using active rendereing(anywhere inside a while loop)


3.- and finally using Java2d graphics to draw on a bufferedimage which will be drawn on the monitor afterward(very similar to what i want)
definitly too much ado for painting an image




the thing i want to know if there is a more natural way to draw an image on the monitor;something like this or alike


Component contextcComponent
image image = myGetImage(url location);

Graphics g = contextComponent.Getgraphics();
g.drawImage(image,x,y,null);



//and ready. a simple image on the monitor. i have been surfing on the web but cant get any answer, maybe theres not any?
sorry if its still dificult to figure out what i want. your answers are very apreciated


 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think what you're looking for is a JLabel with an Icon (probably ImageIcon)
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know it's late (I seem to have been very busy over the weekend) but Ithink thisought to move to our GUIs forum.

Beware of drawing to the screen; that can take much much longer than the loop and it is possible for the loop to re-start before drawing is completed.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!