JDesktopPane and Canvas

Hello all,

Long time reader, but first time poster. :slight_smile: Anyhow, I have a question for you all. I am working with internal frames. I want to have the big desktop frame contain the items drawn by a Canvas. I can successfully get the Canvas to draw when I use AWT. To clarify my problem, here is what I am doing using AWT for drawing of the Canvas in a frame (pseudo-code):

//----------------
Canvas s = new Canvas
Frame f = new Frame
f.add(s) //add the Canvas to the Frame

while(true) s.update(…)
//-----------------

This works for me, but since I would like to add internal frames, I need to start using JDesktopPane. How would I add the Canvas to the main JDesktopPane and have it constantly call update on the Canvas inside of it? And when I get that up and running, after I add stuff to internal frames, how can I get it to constantly redraw itself?

Thanks in advance!!
-Mike

Yes, just add your canvas to a JInternalFrame. Then add the JInternalFrame to the JDesktopPane. The “redraw” is done automatically, you won’t need to worry about that.

Kingaschi –

Thanks for the reply. I try this, but all that comes out on the internal frame is black. Does my Canvas need to implement another method besides update(…)? Like paint or something?

Thank you
-Mike

Ok, yes I am an idiot. The problem was that I was using update instead of paint in the Canvas.

Thank you much,
-Mike

Last question about this. For the JInternalFrame is there any way to get rid of or modify the title bar (not the text, the actual bar. I don’t want it there).

-Mike

do not mix Lightweight Swing components with AWT components :-\

I’d go with converting to JPanel and printComponent()

have a looky at this: http://java.sun.com/products/jfc/tsc/articles/sce/

Thanks Mr. Light, I will look into this :slight_smile:

By the way, did you mean paintComponent(…) as opposed to printComponent(…)?

-Mike

It is “paintComponent(…)”! “print” is used to print on an actual printer! You won’t really need “print”.

ah yes early morning forum-checkign gets the best of me :wink:

(so yes paintComponent(…))