JLayeredPane - keeping all contained components filling the layeredPane

I'm having some troubles keeping contained components inside a JLayeredPane so they're all filling the pane.
The desired effect I want is to have a region of the window that contains two panels -- one for standard view/editing, and an overlayed transparent panel above it, which, at times, will show icons overlayed over the base panel -- basically an OSD layer over a panel that will be showing video.
I've gone the approach of using a JLayeredPane and adding the base panel, but I'm having troubles getting it to make sure it fills the entirety of the JLayeredPane.
I thought of several approaches:
1.) Set up the JLayeredPane with a BorderLayout, and set the components all to CENTER, but then I realized that with BorderLayout, each position can only have one component assigned to it.
So, this approach is a no-go. :(
2.) Set up a ComponentListener on the JLayeredPane, listening for componentResized, and resizing the contained panels to event.getComponent().getSize(). This approach did result in a resize happening on the component I was testing, but alas, it resizes it to the original, pre-resized size! Reading the docs, and what others have said on the msg board, this seems to be going against what I'm reading and hearing about.
Does anyone have any ideas for me? I'm all ears.
Is there a radically different approach I could take?
What I'm going after is kinda like the glassPane feature on a Frame, but I'm not working with a frame, just one panel inside the frame of my main application window.. And I'd like it so I could encapsulate the OSD panel in it's own derived class -- that's what I'm doing right now -- so I can have custom methods for manipulating the OSD.

bsampieri wrote:
For this type of situation, I usually subclass JLayeredPane and override the doLayout() method. In there, assuming you want to have everything on it's layer fill the layer it's on, just set it's bounds to (0, 0, w, h) with the width/height of the layered pane itself. Aha! That worked like a charm! Just what I was after. I need to get more comfortable altering the inner-workings of swing components through subclassing.
If you need something more advanced, you'd have to have a way to determine which components should go where/what size.Nope -- I didn't need to subclass in this case -- I want each and every item in the JLayeredPane to fill the entirety of the container. I sorta figured that there should be a relatively easy solution to it, but I hadn't been able to figure out how, and googling it up didn't seem to result in any useful information on the subject.
Thank you very much bsamieri!
Here's exactly what I ended up doing:
package com.tripleplayint.newvideopreviewermockup;
import java.awt.Component;
import javax.swing.JLayeredPane;
* A panel widget that allows components to be layered on top of one another,
* where each component fills the entirety of this container.
* This is only useful when all but the lowest layer is set transparent, as
* the highest opaque layer will obscure any layers below it.
* @NOTE If one wants to move the layers to choose which one is visible, your
* better option is to use a JPanel with the CardLayout.
* @author kkyzivat
public class FilledLayeredPane extends JLayeredPane {
     * Layout each of the components in this JLayeredPane so that they all fill
     * the entire extents of the layered pane -- from (0,0) to (getWidth(), getHeight())
    @Override
    public void doLayout() {
        // Synchronizing on getTreeLock, because I see other layouts doing that.
        // see BorderLayout::layoutContainer(Container)
        synchronized(getTreeLock()) {
            int w = getWidth();
            int h = getHeight();
            for(Component c : getComponents()) {
                c.setBounds(0, 0, w, h);
}

Similar Messages

  • I have an iPhone5 16 gb and a 120 gb iPod. All my songs won't fit on the iPhone of course. How can I just get some of them on the iPhone? I want to keep all my music on the iPod. I am VERY new to all this so be gentle and thanks.

    I have an iPhone5, 16 gb and a 120 gb iPod. All my songs won't fit on the iPhone of course. How can I just get some of them on the iPhone? I want to keep all my music on the iPod, but just want SOME of my music on the iphone. I am VERY new to all this so be gentle and thanks.

    You Sync the Music you want on the Phone via iTunes on your computer.
    See here  >  http://support.apple.com/kb/HT1386
    From Here  >  http://www.apple.com/support/iphone/syncing/

  • How can I quit (close) Photoshop and keep all windows so that the next time I open Photoshop the fil

    How can I quit (close) Photoshop and keep all windows so that the next time I open Photoshop all the files that I had open are there already in the same position as when I closed Photoshop?
    I've been a Fireworks user for over 10 years and just switched to Photoshop. I cannot find a setting that will enable all my file windows to reopen when I quit Photoshop. This is really a problem since I often work on several files at the same time.
    Please let me know if the feature exists or point me to where I can post a message for a new feature to be implemented. The feature is a must for any designer working on large projects.
    Thanks!

    There is no such functionality. You could perhaps create a script that stores that info in a custom text file and arranges them accordingly in the workspace, but that's as good as it gets...
    Mylenium

  • After i upgrade to mavericks, every time i create folder or delete files, they keep asking me ti fill the password, but only on my finder? help me please :) Thank You

    after i upgrade to mavericks, every time i create folder or delete files, they keep asking me ti fill the password, but only on my finder? help me please Thank You

    As a first step, open Disk Utility > select your hard drive > repair disk permissions.

  • Best way to replicate a directory share to a new Windows 2012 serv, keeping all permissions and timestamps the same?

    We have a legacy Windows 2008 R2 server, with a single network share on it, that was acting as a primary file share.   Inside the network share are about a dozen different folders (with subfolders) all with different permissions applied to them at the
    folder and file level.   
    I want to migrate/copy this entire directory structure to a new Windows 2012 Standard server, keeping all the timestamps, permissions, etc. exactly as they are on the old directory structure.  Both servers are part of the same single Windows 2008 R2
    domain.
    What would the best practice method for achieving this?  Using XCopy?   If so, what syntax would I want to use with the command to make sure I don't lose any permissions or change any data and timestamps during the migration?

    Hi 
    I recommend you use robocopy to accomplish it.
    Technet Guide for robocopy command:http://technet.microsoft.com/en-us/library/cc733145(v=ws.10).aspx
    Microsoft RoboCopy GUI tool. Tool
    link: http://www.myitforum.com/articles/15/view.asp?id=9433
    Note: Its always good test in test environment, before applying it to production servers
    Regards, Ravikumar P

  • Lost Ipad today and erased on find my Iphone then later i found it before it was able to erase via wifi how can I reverse the request for erasing to keep all my current content the same

         Today I lost my IPad and was FREAKING OUT !!!!!   When a couple of store attendants told me to use the ICLOUD find my Iphone option in order to erase all the content just in case it fell into wrong hands.    Within an hour via survelance video we located the ipad prior to being able to connect to internet and erase everything.
        Now I am keeping the power off keeping it untouched or unerased,   QUESTION TO COMMUNITY????    Is there a way for me to successfully avoid the erase process  that is due to occurr once I power up and hit the WIFI????   Appreciate any input up front,    BRfromGR

    You cannot prevent it from being erased now. But surely you backup with iCloud or iTunes and/or sync with iTunes so when you get the iPad up and running again, just restore from your iCloud backup, or your iTunes backup and then sync with iTunes again and you will be OK.
    If you don't backup or sync .... Well then you should probably think about doing so in the future. Out of the mouth of a Apple ......
    If you erase then find your iOS device, you can restore the information on the device using iCloud Backup (if backup was turned on before you erased it) or iTunes. For more information, see iCloud storage and backup overview, or your device’s user guide in Safari bookmarks or on the Apple Support website.

  • How to keep all text and formats the same on multiple computers?

    I'm creating a file in InDesign CS6 on my Windows computer. I keep everything on my flash drive. When I go to school, I bring my flash drive with me and open it up on the Mac computer, but then there are are compatibility issues. There seems to be missing fonts and formats but the school uses the same version of InDesign I do. Now I was told a lot of things of how to keep the fonts and formats the same (embed the links, package the files, outline the text, save as IDML). However, it is not clear to me what each of those options do, so I don't know when or why to use them. So I just want to make sure that when I bring in my file in next Monday, I won't have any missing fonts or formats. What would you suggest is the proper things to do to keep everything the same on multiple computers? And could you please explain why?

    If you want cross-paltform comaptibility limit the fonts to OpenType or Windows TrueType formats, both of which work on both Mac and PC. To avoid missing font warnings the fonts must either be installed on each computer, or they must be in a folder named Document Fonts in the same location as the .indd file they are to work with. Packaging the file will build taht folder for you.
    the rest of the stuff in your list won't help you. .idml would allow you to open on an older version, but does nothing for your situation. Embedding the links will keep you from having missing links, but so will packaging, and embedded links will make the file much larger and harder to work with.
    For goodness sake, don't even think about outlining the text. It stops being text when you do that and you can no longer edit it.
    And finally. do yourself a big favor and don't attempt to actually work on your file directly from the flash drive. Copy the whole package folder to the hard drive, work on it, then copy back. You don't want to know how many files are fatally damaged by write errors on flash drives.

  • How can I keep all the previous datas in the same array?

    I have a problem with keeping the previous datas in my array. The problem is when the iteration loop is executed, I have one or two value(s) stored in the array. The second iteration I have either one or two values (depending on the condition) coming out, but it overwrites my previous value. I want to keep all my data in the same array as the loop is executed.PS. I have attached a simple vi along this message. If anyone can help me out with this, I really appreciate for the help.
    Regards,
    Sonny

    If you iterate several times (N > 100) then I would suggest using the Initialize Array outside of the For Loop and then use the Replace Array Subset inside the Loop to populate the array. The reason for this is because the Build Array utility has to locate a new space in memory for the newly concatenated array -- the Replace Array Element utility uses the same memory space.
    If you iterate just a few times with a small array then using the Build Array should be okay.
    Chris_Mitchell
    Product Development Engineer
    Certified LabVIEW Architect

  • Apple tv my tv programmes are not playing in widescreen even though rented movies are. Aditionally my photos on my iPhone 4 are also shown only in the middle of the screen? Why are not all films/programmes / photos filling the whole screen?

    Just purchased Apple TV 2 & music videos purchased and films rented from iTunes play in 16:9 ratio and fill my 6 year old Samsung TV screen completely. However my photos and videos played by AirPlay play in the centre of the screen along with TV series purchased and played from iTunes. Why are not all played media filling the TV screen even though they are playing in 16:9 on the TV?

    if the original material is not in widescreen appletv will not play it in widescreen
    if it did it would mean that it had to cut off some of the image

  • Adding a panel over other components in the main mxml application

    Hi,
    I've created a main mxml file that contains,among other things, a button, and another mxml that contains a panel with some options. I want to be able to add that panel to the main mxml OVER all other components in the main mxml file with a mouse click on the button in that main mxml. How can this be done, please help ?

    Hi mesanarapscallion,
    Can you please post the sample code you are working...
    Do you want to show the panel component on all the thing above in the main.mxml file...Do you have all the other things positioned at the same position..?
    Thanks,
    Bhasker Chari

  • Keep all unplayed episodes - bug?

    Hi everybody!
    My iPod/iTunes7 is killing me. I have selected "Keep: All unplayed episodes" in the iTunes podcast options because I want iTunes to automatically delete all podcasts that I have listened to on my iPod.
    If I manually mark a podcast as "played" in iTunes7 it does what I want; deletes that podcast from my iPod.
    But it doesn't work the other way. If I listen to a podcast on my iPod (and the podcast is marked as played on the iPod), the podcast is reset to unplayed on both the ipod and in iTunes on first sync.
    This is annoying!
    Please advice!
    I've tried restoring my iPod, and I've also installed the latest iPod-update.
    markus

    * Four weeks ago my Apple headphones stopped working
    * Three weeks ago my I bought the new Apple headphones which were designed to not stay in my ears
    * Two weeks ago because my new (old headphones) that hang around the neck had not arrived I fumbled my I-Pod, dropped it and it stopped working.
    * Last week I got my new replacement I-pod which I bought (two sets of headphones -- only ordered one).
    * This morning my I-pod locks up, had to go to Google to finally solve the problem.
    * For the past couple days I have been relistening to podcasts because of this silly ignoring my request to only keep unplayed episodes problem.
    * Today when I looked for E-mail tech support it was hidden or unavailble.
    ==> My first Nano was great while it lasted, but needless to say this is the last Apple product I will ever buy.

  • When you change iPHONE'S is it possible to keep all your games without losing your progress?

    I just upgraded to the iPhone 4S from the iPhone 3. I have several games that I want to keep my progress from but I can't figure out how to put them on my new phone without losing all that progress. Is there anyway to transfer these games and keep all my progress?

    The iPhone 3G does not support iCloud backup, but you can back up (or sync) all your data to a computer with iTunes. Once connected, you right click on your iPhone in the left column, select back up. This will copy all your data (incl. game progress) to your computer. Then when you are setting up your 4S, connect it to the same computer with the 3G's backup and instead of selecting "set up as a new iPhone," select restore from backup of the 3G.

  • HT1473 When downloading a CD album, if it contains different artists, the album is split up into separate albums/icons. How do I get all songs into one album (just like the original CD)?

    When downloading a CD album, if it contains different artists, the album is split up into separate albums/icons. How do I get all songs into one album (just like the original CD)?

    Generally, in iTunes, all you need to do is fill in an appropriate Album Artist to keep things together. For older iPods each track from the same album should have the same artist, or be marked as a compilation where appropriate. For iOS devices you may need to go to Settings > Music > Group By Album Artist > On.
    For more details see my article on Grouping Tracks Into Albums, in particular the topic One album, too many covers.
    tt2

  • HT1711 When I load one of my own CD's onto itunes, it creates separate albums for each unique pairing (ie: singer/composer or singer/orchestra). How can I keep all the cuts together on one album?

    When I load one of my own cd's onto itunes, it creates separate albums for each unique pairing (ie: singer/composer or singer/orchestra). I end up with
    the cuts scattered over several albums.  How do I keep all the cuts on an album together rather than divided between several albums? I'm brand new with this technology, so I need your information in simple terms.  Thank-you.

    Generally all you need to do is fill in an appropriate Album Artist. For more details see my article on Grouping Tracks Into Albums, in particular the topic One album, too many covers.
    The site could do with updating as some options have changed with iTunes 11, but the principles are the same.
    tt2

  • How do i keep only the name of a month in a cell in Numbers and not have it auto fill the date and time?

    how do i keep only the name of a month in a cell in Numbers and not have it auto fill the date and time?

    Hi JN and Barry,
    Barry wrote:
    The second case may not be included in the available D&T formats in Numbers 3
    For my region, the Date & Time data formats include month.
    The Date Pop-Up
    This may not be the case for all regions.
    Remember that the month is only the display, and the Full Date & Time is still there. If I change the format to reveal what is behind the curtain:
    Regards,
    Ian.

Maybe you are looking for

  • Media Encoder CC Has Disappeared and Can't Be found!

    My Media Encoder CC is gone and won't return.  I tried uninstalling After Effects and Premiere Pro, then reinstalling on the assumption it was part of one of thsoe two packages, but alas ... still no Media Encoder.  What do I do?

  • File is not compatible with this version of Photoshop error

    Computer crashed yesterday and now I am getting "File is not compatible with this version of Photoshop" error and unable to opening in PS CS5 or Fireworks CS5. Any ideas? Also tried the PS repair download and would rather not pay $30 to find out it c

  • VARIABLE option for currencies during query runtime.

    Hi Experts, Please provide me the solution for the below. In Bex query, during the runtime, selection time of currency, We have to give variable option for Millions in rupees, thousands in rupees and rupees. How we can give? Is it any SAP exit variab

  • A JDataStore problem...

    Good morning, in my application, i make connection to a JDataStore db. I fill a vector with Objects containing some data of classes. my problem is although there are 12 objects that meet the query I make on the DB, only 10 of them are delivered to th

  • How to rename files already in catalog?

    I accidentally imported a large batch of images into LR 2.5 (on a new Windows 7 machine) using the "Filename" template rather than my customary "Date - Filename" template, and did a LOT of work on the files before I noticed the error.  Is there a way