?
Solved

Urgent : Overlapping JInternalFrame + JPanel

Posted on 2001-07-10
2
Medium Priority
?
878 Views
Last Modified: 2012-05-04
Dear Expert,
   I got a problem and here is the complete details of the problem.
   I have a Jwindow and in that i will show some drawings.
Then i have a JPanel over it and in that panel i will do some animation.
  Then i have a JInternalFrame and which has some queries regarding the animation.

My problem is :
    Then animation stuff and the JInternalFrame  are overlapped and hence i am not able to show the JInternalFrame completely. I can move the JInternalFrame to some other location, but i don't want it.

My need is :
     Some drawings/pictures in the bottom most layer. Then the animation over it and then the JInternal frame as the top-most layer.

    Any suggestion or solution ???

Herewith i have attached the code also.

To get the JInternalFrame click on the JWindow and then resize the JInternalFrame. ( I don't know why JInternalFrame's size is so big).

Kind Regards,
Prem.

Code:

package test;

import javax.swing.*;
import java.awt.*;
import java.util.*;

public class LastPanel extends JWindow
{
     private static Dimension _dimension = null;
     
     public LastPanel( Dimension d)
     {
          _dimension = d;
     }
     public void paint (Graphics g)
     {
          g.setColor( Color.black);
          g.fillRect( 0, 0, _dimension.width, _dimension.height);
          g.setColor( Color.blue);
          g.fillRect( 100, 100, _dimension.width-200, _dimension.height-200);
     }
     
     public static void main( String args[])
     {
          Toolkit tk = Toolkit.getDefaultToolkit();
          LastPanel lp = new LastPanel( tk.getScreenSize());
          lp.setBounds( 0, 0, tk.getScreenSize().width, tk.getScreenSize().height);
         
          JLayeredPane layeredPane = lp.getLayeredPane();

          JInternalFrame jif = new JInternalFrame( "Test", true,     true,     true,      true);
                                                                  //resizable, closable, maximizable,iconifiable
        jif.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE);
          jif.getContentPane().add( new JLabel( "Label1"));
          jif.setBounds( 10, 15, 100, 100);
          jif.pack();
          jif.setVisible( true);
          jif.moveToFront();

          AnimationPanel ap = new AnimationPanel();
          ap.setBounds( 0, 0, tk.getScreenSize().width, tk.getScreenSize().height);
          layeredPane.add( ap, layeredPane.lowestLayer()+1);
     
          lp.getContentPane().add( jif);
         
          lp.setVisible( true);
     }
     
     public static class AnimationPanel extends JPanel
     {
          private java.util.Timer _timer = null;
          private int _blink = 0;
         
          public AnimationPanel()
          {
               AnimationThread at = new AnimationThread();
               _timer = new java.util.Timer();
               _timer.scheduleAtFixedRate( at, 0, 500);    
               System.out.println( " Thread created ... ");
          }
         
          public void paintComponent( Graphics g)
          {
               if ( _blink == 1)
               {
                    g.setColor( Color.white);
                    _blink = 0;
               }
               else
               {
                    g.setColor( Color.black);
                    _blink = 1;
               }
               Toolkit tk = Toolkit.getDefaultToolkit();    
               g.fillRect( tk.getScreenSize().width/2-100, tk.getScreenSize().height/2-100, 200, 200);
          }
         
          private class AnimationThread extends TimerTask
          {
         
               public void run()
               {
                    Toolkit tk = Toolkit.getDefaultToolkit();
                    paintImmediately( tk.getScreenSize().width/2-100, tk.getScreenSize().height/2-100, 200, 200);
               }
               
          }
     }
     
}
0
Comment
Question by:PremkumarAC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
ruifilipevale earned 1200 total points
ID: 6274039
Hello!

If you want I can email to you a nice example of two images overlapping each other (or something like that). It uses the JLayeredPane class. Instead of images you can place what object you want.

My email is rui.vale@ent.efacec.pt

Feel free to contact me!


Hope it helps!


   RFV
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9017734
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


[points to ruifilipevale]


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question