-
JInternalFrame on top?
Hmm..I am trying to get a JInternalFrame to always be on top, but it seems to always go behind my "canvas". Any ideas?
///////////////////////////Declarations/////////////////////////////
Container container = null;
DisplayCanvas canvas;//DisplayCanvas extends Canvas
Image backbuffer;
JInternalFrame frame = new JInternalFrame();
JDesktopPane desktop = new JDesktopPane();
//////////////////////////init()/////////////////////////////////////
container = getContentPane();
container.setLayout(null);
desktop.setBounds(0,0,900,700);
frame.setBounds(100, 100, 100, 100);
container.add(desktop, null);
desktop.add(frame);
frame.setVisible(true);
frame.moveToFront();
canvas = new DisplayCanvas(backbuffer);
canvas.setBounds(200,25,630,630);
desktop.add(canvas);
////////////////////////////////////////////////////////////////
I tried to get out all the important parts from my code.
I am continually drawing the backbuffer image on the canvas. My problem, is I want my "frame" to be on top of the canvas when I drag it over, but I can't seem to figure it out.
Thanks!
-
Anyone have any ideas? I have tried messing with it some more, but I cant seem to get it. The 'canvas' is going to the default layer. I have tried modifying the layer of the 'frame', but it doesnt seem to make a difference. For some reason, nothing seems to be able to go over the canvas. I know that there is a way to do it though. Someone has to know something about this...Anyone?
-
Ok, try re-arranging the order of your code to this:
container = getContentPane();
container.setLayout(null);
canvas = new DisplayCanvas(backbuffer);
canvas.setBounds(200,25,630,630);
desktop.setBounds(0,0,900,700);
frame.setBounds(100, 100, 100, 100);
container.add(desktop, null);
desktop.add(frame);
desktop.add(canvas);
frame.setVisible(true);
frame.moveToFront();
not too sure, but it could be the ordering and default settings that java has...
A kram a day keeps the doctor......guessing
-
Thanks for the reply. I gave it a shot, but no luck
Upon further investigating, I think this may be a slight incompatibility problem, which stems from using Swing components with the AWT Canvas class. Apparently JPanels are supposed to replace the AWT Canvas class. When I have the time, I am going to see if i can figure that out. I suspect it just might work.
If anyone know of a really good site that explains how to use JPanels with examples that would help. I have tried looking, and havent really found anything clear enough. Or if you can confirm my suspicions, that would also be nice.
Thanks!
-
i had a quick look, you are right not too many good ones but here are a few that are ok:
http://java.sun.com/docs/books/tutor...out/using.html
http://www.apl.jhu.edu/~hall/java/Sw...al-JPanel.html
(^^^ good for experienced users of java)
let me know if they are any good...
A kram a day keeps the doctor......guessing
-
Well, I didnt find any better tutorials, but I did figure it out. By replacing the canvas with a Jpanel, everything worked great! Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks