JInternalFrame on top?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: JInternalFrame on top?

  1. #1
    Join Date
    Oct 2004
    Posts
    9

    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!

  2. #2
    Join Date
    Oct 2004
    Posts
    9
    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?

  3. #3
    Join Date
    Sep 2004
    Posts
    223
    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

  4. #4
    Join Date
    Oct 2004
    Posts
    9
    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!

  5. #5
    Join Date
    Sep 2004
    Posts
    223
    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

  6. #6
    Join Date
    Oct 2004
    Posts
    9
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center