Repaint JInternalFrame transparent over a picture

Hi,
I have a problem using a non-opaque JInternalFrame, with a content pane which has a background with ALPHA.
When I move the frame over a picture, it does not repaint() automatically.
But, when I use a ComponentListener to repaint() it manually (in componentMoved() method), there are flikerings...
I noticed that, when resizing the frame, the "automatic" repaint is good (really good).
Does anybody know how to "use" the same way to repaint() the frame when I move it ?
Here is an example :
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class EssaiRepaint {
public static void main(String[] aArgs) {
JFrame oFrame = new JFrame("Repaint Test"); oFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Container oContent = oFrame.getContentPane();
oContent.setLayout(new BoxLayout(oContent, BoxLayout.Y_AXIS));
JDesktopPane oDesktop = new JDesktopPane();
oContent.add(oDesktop);
ImageIcon oIcon = new ImageIcon("aRatherBigPic.jpg");
JLabel oLabel = new JLabel(oIcon);
oLabel.setSize(350,250);
oDesktop.add(oLabel, JLayeredPane.DEFAULT_LAYER, 0);
final JInternalFrame oIFrame = new JInternalFrame("Test", true, true , true, true);
// Try both by uncommenting the following lines
/*oIFrame.addComponentListener(new ComponentAdapter() {
public void componentMoved(ComponentEvent aEvent) {
oIFrame.repaint();
oIFrame.setOpaque(false);
Color oBg = oIFrame.getContentPane().getBackground();
oIFrame.getContentPane().setBackground(new Color(oBg.getRed(), oBg.getGreen(), oBg.getBlue(), 128));
oIFrame.setSize(200,200);
oIFrame.setVisible(true);
oDesktop.add(oIFrame, JLayeredPane.DEFAULT_LAYER, 0);
oFrame.setSize(500,600);
oFrame.setVisible(true);
Thanks a lot,
Luc.

Not sure if this is what you are looking for, but I think the flickering is caused because multiple componentMoved events are generated and Swing can't repaint fast enough. I don't know how to speed up the painting so I deferred the repaint until the component is finished moving:
final Timer timer = new Timer(50, new ActionListener()
     public void actionPerformed(ActionEvent e)
          oIFrame.repaint();
timer.setRepeats( false );
oIFrame.addComponentListener(new ComponentAdapter()
     public void componentMoved(ComponentEvent aEvent)
          if (timer.isRunning())
               timer.restart();
          else
               timer.start();
});

Similar Messages

  • I have a transparent picture in my document. How do I get the text, that is typed over the picture, to not fade in color? I want all the text to be the same black color.

    I am creating a form and would like to put the conference logo in he background. I added it and made it transparent but I want the text to not change it's shade of black when I type over the picture. Is there a way to make that happen?

    Insert your text in a text box which you will put above the picture.
    Yvan KOENIG (VALLAURIS, France) dimanche 25 septembre 2011 22:21:18
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • Semi transparent drawing over the picture

    Hello every one
    I am drawing the arrow image over the picture , so after drawing the arrow over the picture how to make it semi transparent so that background picture also should appear . 
     Please see the attached vi
    Attachments:
    arrow1.zip ‏2436 KB

    Thank you Strokes
    See the below pic i need this kind of output, transparent  drawing over the 2picture 
    Attachments:
    arrow transparent.PNG ‏411 KB

  • Shapes over a picture

    I am making a java program in wich I would like to have a picture and some shapes (that I can draw with J2D) over the picture. Lines, circles, squares, etc...
    I want to save the picture and the shapes separatly. I mean to save the picture in one file and the shapes in another.
    How can I do that?
    A solution that I was thinking is:
    To work with two pictures, one for the picture and another for the shapes, and to create an overlay between them every time I make a change.
    But what I don�t know is how to create(the first time) an empty picture, I mean a transparent picture with the same size that the other picture has.
    I hope you could understand me, english is not my first languaje.
    Thanks

    How do you want to save the pictures? As a row image file (like jpeg, gif etc) of in a vectorial format ?
    If you want as raw image file you can use codec classes from JAI .
    Basicaly, you can do something like this:
    In the component that dislays the image and the shapes :
    public void paintComponent(Graphics g) {
        paintImage(g);
        paintShapes(g);
    }Then you can implement a save routine like this :
        public void save(String pictFileName,
                   String shapeFileName)
         throws Exception {
         Dimension d = getSize();
         BufferedImage img = new BufferedImage(d.width, d.height,
                                   BufferedImage.TYPE_3BYTE_BGR);
         Graphics2D g = img.createGraphics();
         paintImage(g); //here paint just the image
         saveImage(pictFileName, img);
         //clear the image
         g.setColor(Color.white);
         g.fillRect(0, 0, d.width, d.height);
         paintShapes(g); //here paint just the shapes
         saveImage(shapeFileName);
        public void saveImage(String fileName, BufferedImage img)
         throws Exception {
         int dotIndex = fileName.lastIndexOf('.');
         String ext = null;
         if ( dotIndex != -1 && dotIndex != name.length()-1 )
             ext = fileName.substring(dotIndex+1).toLowerCase();
         ImageEncodeParam encodeParam = null;
         String type = null;
         if(ext == null || ext.equals("jpg") || ext.equals("jpeg")) {
             type = "JPEG";
             encodeParam = new JPEGEncodeParam();
             ((JPEGEncodeParam)encodeParam).setQuality(1F);
         else if (ext.equals("tiff") || ext.equals("tif")) {
             type = "TIFF";
             encodeParam = new TIFFEncodeParam();
             ((TIFFEncodeParam)encodeParam)
              .setCompression(TIFFEncodeParam.COMPRESSION_NONE);
         else if(ext.equals("bmp")) {
             type = "BMP";
             encodeParam = new BMPEncodeParam();
         else if(ext.equals("png")) {
             type = "PNG";
             encodeParam = new PNGEncodeParam.Palette();
             ((PNGEncodeParam.Palette)encodeParam).setBitDepth(2);
         else if(ext.equals("gif")) {
             throw new Exception("Gif file format is not yet supported !");
         else {
             throw new Exception("Unknown extension: " + ext);
         ImageEncoder enc =
             ImageCodec.createImageEncoder(type,
                               new FileOutputStream(fileName),
                               encodeParam);
         enc.encode(img.getData(), img.getColorModel());
         enc.getOutputStream().close();
    If you want to save as a vectorial format, you should chose one. For this you can take a look at http://xml.apache.org/batik/index.html . There are of course many other formats :-))
    I hope you got an idea.
    Regards,
    Iulian

  • I am installing itunes to a laptop and have not sync device to this lap. It is saying that it must first restore device. The problem is I have over 2000 pictures and don't want to lose them. Now my phone is in restore mode and I don't know what to do. I

    I am installing itunes to a laptop and have not sync device to this lap. It is saying that it must first restore device. The problem is I have over 2000 pictures and don't want to lose them. Now my phone is in restore mode and I don't know what to do. I don't want to proceed and loose these very important photos of family. What do I do to get it out of restore mode? My phone will not allow me to do anything to it at this point. I have the itunes downloaded on the laptop now. When I push the button for the phone it just shows Itunes and plug. I can't even call or open phone up.

    Unfortunately... Once the Device is asking to be Restored with iTunes... it is too late to save anything...
    See Here  >  http://support.apple.com/kb/HT1808
    However... Once you have Recovered your Device...
    Re-Sync your Content or Restore from the most recent Backup...
    Restore from Backup  >  http://support.apple.com/kb/ht1766
    Jessica Sanchez wrote:
    I am installing itunes to a laptop and have not sync device to this lap. ...
    Using a computer, other than the one you have regularily been Syncing and Backing up to, was the begining of your issue.

  • Problem with PDF 1.3-Export: Photoshop-Files with transparency over InDesign colored objects

    Hello!
    I'm using InDesign CS6.
    I'v finished now a layout for a folder, and I put a photoshop-image with transparency over a InDesign-rectangle which I have filled with a cmyk-color in yellow.
    When I export a PDF with the Settings "PDF X-3:2002" (with PDF-Standard 1.3) the Photoshop-image shows uggley jagged edges at the border to the InDesign-colored background. However, the Photoshop-images which are over another bitmap-image (as background), this images don't show this annoying edges.
    When I export to PDF-Standard 1.4 the problem doesn't occor, however my printing-service requests PDF 1.3.
    I know, the workaround for this problem is, to replace the yellow background-color with an bitmap-file with the same color, but is there any other option to get a correct result without this more time-consuming image trick?
    I think it has to do with the transparency reduction which is necessary if using PDF 1.3. When I examine the PDF-File in Illustrator, this edges occurs mostly at the borders from the tiles in which the image is cut during the transparency reduction process. Although, if I open the rendered PDF in Photoshop this jagged edeges are visible, so it is definitly a render error.
    I would be glad if someone of you has a solution for this problem, in the attachment is an image which illustrate the problem.
    Best wishes

    Find another printer.
    End of problem. It really saddens me to think that these Luddites are
    still in business making no effort to move into the 21st century.
    Bob

  • How to write text over a picture in Pages 5.0?

    In a Pages 5.0 document I want to write a text over a picture. This text will allways stay 'behind' the picture.
    I can change the order of the picture (in front of at the back), but the text will not become visable.
    It did work in Pages '09...
    What am I doing wrong?
    For for helping me...

    Assuming your text is in your document, and you insert a picture. While the picture is selected, you will notice that on the right format panel, the Arrange tab has appeared. Select either Stay on Page, or Move with Text — depending on your image goal — and then look at the Text Wrap feature. By default, once you drop a picture into the document, it is set to Automatic. This means you can place your pointer in the image and just move it around, while text flows around it. The smaller the image the better the flow effect. This is a discussion about Pages v5.2.2, but it will work the same in v5.5.
    Let's say you want the image flush aligned to the left margin, but want text to flow above, to the right, and below the image. Change text wrap automatic to Around, select the right icon for Text Fit, and adjust your spacing up or down for the proximity of the text wrap to the image. It looks like this with Text Fit spacing set to 9 pt.

  • When I try backing up to icloud it says that I have gone over the free 5gb. It shows that I have 4.6 gb of pictures in my camera roll when I barely have over 200 pictures! Any similiar problems or possible solutions?

    When I try backing up to icloud it says that I have gone over the free 5gb. It shows that I have 4.6 gb of pictures in my camera roll when I barely have over 200 pictures! Any similiar problems or possible solutions?

    You're welcome.  Given the number of people who seem to have problems restoring photos from their backup I wouldn't trust the iCloud backup for my photos anyway.  I always import them to my computer at least weekly.  That way I know I have them.
    You might want to check out the app PhotoSync.  It makes this pretty easy as it transfers them to your computer wirelessly and keeps track of which ones have already been transferred.

  • My imovie '11 when i put a transparent video in picture in picture and it dosnt show or play

    My imovie '11 when i put a transparent video in picture in picture and it dosnt show or play. Help Please

    What do  you mean by "transparent video"?
    Matt

  • I deleted over 200 self taken videos and over 500 pictures in the Moments window in my photo tab.  They deleted but still show in my setting in the About window and I haven't gained any additional storage capacity.  What do I do now?

    I deleted over 200 self taken videos and over 500 pictures in the Moments window in my photo tab.  They deleted but still show in my setting in the Setting/About window and I haven't gained any additional storage capacity.  What do I do now? Please help!  Thanks in advance for any assistance!!!

    Check the Recently Deleted album. Deleted photos will reside there for up to 30 days. This allows all those people who accidently delete photos to recover them, something they couldn't do before. To actually free up the space you might have to delete the photos in the Recently Deleted album.

  • How do I superimpose a video over a picture?

    How do I superimpose a video over a picture?

    First, go to iMovie/Preferences and make sure that the Advanced Tools are enabled.
    Drag the Photo to your project.
    Now select the frames that you want from the clip in your event library. You can get the whole clip, or a selection. Your selection will have a yellow border around it. Click inside this yellow border and drag it to your photo. Drop it at the point where you want the video to be superimposed and drop it on the photo. A popup menu will appear. Choose CUTAWAY.

  • When you add a background over your picture/sound footage the background has 2 fade toggles that both move in mirror fashion. Is there a way to lock one of the fade toggles on a background colour? iMovie 10.0.6

    When you add a background over your picture/sound footage the background has 2 fade toggles that both move in mirror fashion. Is there a way to lock one of the fade toggles on a background colour? iMovie 10.0.6

    You used the data.  Verizon can not see what it was sued for.  However your phone can see whats apps used the data.  go to settings-data usage- there will be a place that says data usage cycle.  line the dates up with your cycle.  then there will be a bar graph below that   extend bother white bars one all the way to the left and one all the way to the right.  after those are extended below that will be a list of apps,  there should be one that used over 2 gb and that will show you what app used that data in her purse

  • I have taken over 9999 pictures with my phone and it is now creating duplicate names for the pictures starting back at 0001 making it difficult to manually upload my photos like i always have. How do i fix this?

    I have taken over 9999 pictures with my phone and it is now creating duplicate names for the pictures starting back at 0001 making it difficult to manually upload my photos like i always have. How do i fix this?
    (I tried to just write this as a reply to someone who had already asked the question whos problem was magically solved after posting the question and the site was not allowing me to post to it so here I am)

    Additionally, when I try to sort the photos by date to easily extract the newest photos which I have not yet uploaded, it is unable to put them in correct order regardless of the fact that the date is correct. Only the videos end up in chronological order for some reason while the photos stay in order by name.

  • I have over 2000 pictures in IPhoto how do I transfer to ICloud?

    I have over 2000 pictures in IPhoto how do I transfer to ICloud?

    You can't. iCloud is not a general purpose photo storage solution. The Photostream feature is only a conduit for transferring photos from iOS devices to other iOS devices and your computer. It only stores up to the latest 1000 photos for a maximum of 30 days.
    As Winston points out, you also cannot use iCloud on your current OS X 10.6.8 system, you'll need to upgrade to OS X 10.7.2 or later.

  • I have over 300 pictures on my phone...my question to someone iphone savvy is why, when I plug my phone into the computer is iPhoto showing no pictures?  I want to delete them for space issues.  Thanks

    I have over 300 pictures on my phone...my question to someone iphone savvy is why, when I plug my phone into the computer is iPhoto showing no pictures?  I want to delete them for space issues.  Thanks

    I've seen this happen when the phone was encrypted... Other than calling apple/deleting passcodes I don't know of any solution.
    If you're keen on waiting, upload your photos to dropbox, that's the way I do it.

Maybe you are looking for