Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  JDesktopPane and Canvas  (Read 1527 times)
0 Members and 1 Guest are viewing this topic.
Offline Shagroth

Senior Newbie




EQ Freak


« Posted 2005-12-22 05:02:24 »

Hello all,

  Long time reader, but first time poster.  Smiley 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

Thanks!
-Mike
Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #1 - Posted 2005-12-22 05:09:10 »

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.

Offline Shagroth

Senior Newbie




EQ Freak


« Reply #2 - Posted 2005-12-22 05:20:13 »

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

Thanks!
-Mike
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Shagroth

Senior Newbie




EQ Freak


« Reply #3 - Posted 2005-12-22 05:22:16 »

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

Thank you much,
-Mike 

Thanks!
-Mike
Offline Shagroth

Senior Newbie




EQ Freak


« Reply #4 - Posted 2005-12-22 05:36:45 »

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

Thanks!
-Mike
Offline Mr_Light

Senior Member




shiny.


« Reply #5 - Posted 2005-12-22 09:34:46 »

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.

do not mix Lightweight Swing components with AWT components  Undecided

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

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

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

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline Shagroth

Senior Newbie




EQ Freak


« Reply #6 - Posted 2005-12-22 10:35:11 »

Thanks Mr. Light, I will look into thisĀ  Smiley

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

-Mike

Thanks!
-Mike
Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #7 - Posted 2005-12-22 20:17:18 »

It is "paintComponent(...)"! "print" is used to print on an actual printer! You won't really need "print".

Offline Mr_Light

Senior Member




shiny.


« Reply #8 - Posted 2005-12-23 08:05:27 »

Thanks Mr. Light, I will look into this  Smiley

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

-Mike

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

(so yes paintComponent(...))

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (12 views)
2014-08-28 18:26:30

CopyableCougar4 (24 views)
2014-08-22 19:31:30

atombrot (37 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (29 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (28 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (33 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!