Something like setVisible

I've got a JPanel which contains several components. I'm using GridLayout. If I change the visibility of one of them so that the component doesn't show, it works perfectly, but the room occupied by the component is still there so I get an empty area. I don't really want to remove the component from the JPanel. The only thing I want is to hide or show it, but if I hide it I want the layout manager to take all the room avalaible and adjust the rest of the components.
I don't know if I am explaining my problem very well. If you know something about CSS it is like the difference between using the visible and the display properties (It's the best example I can think now). In CSS if you set the visible property to the value of hidden the corresponding element hides but the room doesn't dissapear, you get an empty area. But if you set the display property to the value of none, the corresponding element hides and also the room is freed, so the rest of the elements in the page adjust their positions in order to take all the space avalaible.
How can I achieve this with Swing?

I want the layout manager to take all the room avalaible and adjust the rest of the components.So I believe you need to remove the component from the container:
container.remove(component);
container.validate();
You can always add it back later using:
container.add(component, index);

Similar Messages

  • How do yah make something like this?

    I'm trying to make simething like this. However I'm stuck on what sort of algorithm would be used. Any idea? Thanks a bunch in advance for any help!
    http://i91.photobucket.com/albums/k293/rawlehypermode/Untitled.jpg

    You meant something like this ?
    import java.awt.Dimension;
    import java.awt.Graphics;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class LineDemo extends JPanel {
        final static int SIZE = 640;
        final static int STEP = 20;
        protected void paintComponent(Graphics g) {
            for (int i = 0; i < SIZE; i += STEP) {
                g.drawLine(i,0,SIZE,i);
                g.drawLine(SIZE,i,SIZE-i,SIZE);
                g.drawLine(SIZE-i,SIZE, 0, SIZE - i);
                g.drawLine(0, SIZE - i,i,0);
        public static void main(String[] args) {
            JFrame frame = new JFrame("Line demo");
            frame.add(new LineDemo());
            frame.setPreferredSize(new Dimension(SIZE+STEP,SIZE+2*STEP));
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
    }

  • How difficult would it be to create something like this? 

    I'm looking to create a flash widget similar to what WoW has
    on their main page -
    http://www.worldofwarcraft.com/index.xml
    It needs to have images & text that could be called from
    a php or text file, so that it can be dynamically changed. Movies
    will also be integrated in the rotation as well for the Flash.
    How difficult would this be for someone who's new to flash?
    How long would it take and what all is needed to learn how to
    re-create something like this?

    The difficulty and time to do it depends on the learning
    capability of the new programmer. Patience and a drive to learn is
    what all is needed. Accomplishing one step at a time is probably
    the best approach, whether you're new or well-versed.

  • Malicious or not? Message popped up: Mozilla security found (something like too much, forget exact word) activity on your computer so it will do a fast scan of system file. With OK button.

    I was looking at youtube.com, which always tells me my browser is not supported and recommends I download Firefox, but that is what I was using, so I went to Firefox to check for updates. (I think I also had freecycle.org open.) Then this message popped up in a new page: Mozilla security found (something like "too much", forget exact word) activity on your computer so it will do a fast scan of system file. There was an OK button. The page address was: http://update17.stegner.ce.ms/index.php?Q7Lhl9ShbRxGJXpkM1VLSi4ZE8H4pTedoVPySgeppM3VpC+thEspcFG7qxHgn1pdsC2h5ygPGWI3t5hXqMzL9EQaZZ3J1e3CKXgCb0Qp. I did not click OK but copied the link and closed the window which closed the internet. I have never seen this before and would like to know if it is really Mozilla or possibly something malicious. Thank you.

    Good catch. That almost certainly is an invitation to download malware.
    There are a lot of infected web sites pushing "fake antivirus" software. If you have any doubts about whether your system might have become infected, you can supplement your regular security software with these two highly regarded scanners:
    Malwarebytes Anti-malware : http://www.malwarebytes.org/mbam.php
    SUPERAntiSpyware : http://www.superantispyware.com/

  • Exist a Jtree node.id or something like this ?

    I would want to retrieve a node using a unique 'id', for example the absolute index (into the total nodes count)
    Is there something like this ?
    Can I add a particular property to a node ? ( for example this 'id' if it does not exist )
    Another question :
    If I want to implement a search code, this 'id' can be useful, or must I transverse the whole Jtree
    Thanks

    Hello.
    Do the following:
    1. Go to the Apple Menu at the top left of the screen
    2. Select Software Update...
    3. Install any updates that are found.
    If the Amazon issue continues after these updates, then do this:
    1. Open Safari
    2. Erase any web address you have currently showing (for example www.apple.com or www.google.com)
    3. Type in www.amazon.com
    4. That should take you directly to amazon.com
    It should look like this in your Safari::

  • Hi Team, I wuold like to know if you have any app to make Firefox OS working with cisco Call Manager 10.5. Something like Cisco Jabber for Android or iOS.

    I'm interesting on buying a Firefox Smart Phone, but
    I would like to know if are any app to install on Firefox OS smart phone in order to work with cisco call manager 10.5.
    Something like Cisco Jabber for Android o iOS.
    Thanks,

    Hi Itech,
    If Cisco Jabber has a webapp, or mobile version of their website available, you should technically be able to access it through Firefox OS.
    You may also search Firefox Marketplace for an alternative solution:
    * [https://marketplace.firefox.com/]
    - Ralph

  • My iPhone 4 no longer connects to my car or alarm clock after a recent sync to my computer.  The message at I get when trying to. Connect is "this accessory is not optimized for the device" or something like that.  Anyone know how to fix this?

    My iPhone 4 no longer connects to my car or alarm clock after a recent sync to my computer.  The message at I get when trying to. Connect is "this accessory is not optimized for the device" or something like that.  Anyone know how to fix this?

    Hello there philp_69,
    If I understand correctly it sounds like your phone hasnt been recognized in iTunes on your PC since the last couple of updates. I would use the troubleshooting in the following article which will walk you through the steps one by one. 
    iPhone, iPad, or iPod touch not recognized in iTunes for Windows
    Thank you for using Apple Support Communities.
    All the very best,
    Sterling

  • I just updated my pages and now it won't load. This is on my iPad. The first version which has the latest version it can have 5.1 or something like that. I am trying to open a document and am worried that if I uninstall and reinstall I will lose all my do

    I just updated my pages and now it won't load. This is on my iPad. The first version which has the latest version it can have 5.1 or something like that. I am trying to open a document and am worried that if I uninstall and reinstall I will lose all my documents

    I just uninstalled it and am waiting for it to reinstall. I sincerely hope that I have not lost everything that I worked on so hard. Now that mobile me is gone, I have not been able to go between devices to transfer things. I was merely trying to take a document I had worked on and open it in pages, but it said my version was too old. When I updated, it wouldn't load. Now I cannot do anything. I hope that the reinstall fixes it without losing everything. Please advise!!! Yes, I am in panic mode.

  • I am doing a lot of presenting with the ipad and want an app that would bullseye or show where I am to my audience. Anyone know of something like this?

    I am doing a lot of presenting with the ipad and want an app that would bullseye or show where I am to my audience. Anyone know of something like this?

    It sounds like either your hard drive or the SATA cable that connects it to the motherboard are failing. This could be heat related in your case, which is why you see it after it runs awhile. You can take it to the Genius Bar for a free evaluation. If you decide to test it yourself, I usually suggest moving the hard drive to an external enclosure. If it works there for awhile, the cable is probably the issue.
    http://www.amazon.com/Sabrent-2-5-Inch-Aluminum-Enclosure-EC-TB4P/dp/B005EIGUD4/ ref=sr_1_3?ie=UTF8&qid=1397647657&sr=8-3&keywords=2.5+enclosure
    http://www.ifixit.com/Device/MacBook_Pro_13%22_Unibody_Mid_2009

  • I ran a virus/trojan fix and this is what it said it could not repair something in the main library core or something like that.  What do I do?  The problem seems to be with safari?

    I ran a virus/trojan fix and this is what it said it could not repair something in the main library core or something like that.  What do I do?  The problem seems to be with safari?

    I ran the utility disk and this is what it said.
    Warning permission differ Applications/Safari drwxr-xrx they are -rwxr-xr system/livrary Cores has been modified and will not be repaired.
    Permission apllication differ on System/livrary/Pr or could be -rw-r--r-- they are rwxr-xr-x Application/iTune be droxr-xr-x they are rwxr-xr-x
    Then I hit fix permissions and it said this
    Warning SUID file Systm/Library/Core has been modified will not be repaired
    I also downloaded Bitdefender Virus Scanner and it found nothing.

  • My ipod touch 1st gen has gone into recovery and wont restore because of a error 1 or something like that can someone help me quick this ipod is my little cousins and i dont want her mum to find out what happend

    my ipod touch 1st gen has gone into recovery and wont restore because of a error 1 or something like that can someone help me quick this ipod is my little cousins and i dont want her mum to find out what happend

    I have not seen a solution for error (1)
    make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar

  • Problem with iOS7 : I have a message on my screen "This phone is not registred as a developper phone..." or something like that, can you help me because I download the iOS7 Beta even if I was not a developper. Thank you very much if you help me.

    Problem with iOS7 : I have a message on my screen "This phone is not registred as a developper phone..." or something like that, can you help me because I download the iOS7 Beta even if I was not a developper. Thank you very much if you help me.

    JaillotJb wrote:
    I download the iOS7 Beta even if I was not a developper.
    if you downloaded it and are not a developer, then we are not allowed to help you here.  sorry.

  • Does Something Like This Exist Already (for Window Managers)

    I know that one can use idesk to produce launchers for desktop programs in window managers like Openbox, but what about an actual small file manager, that always sits on the desktop, confined to its own little space.  Kind of like conky, if this makes sense. 
    I don't have a great deal of programming knowledge, just basics, but I've toyed with the idea of making a script to constantly reedit the idesk config file to do this, and while it could work, it's messy at best, and doesn't provide the same desired effect that a small desktop folder sitting on the WM desktop would.
    If this does exist, I give my apologies, but I did try to search Google for it, but got junk results.  Also, would something like this be feasible? (I am looking for a way to improve my programming skills over the summer, and was thinking that this could possibly be a way to do it.)  Even further, would it be acceptable to use Python for it?

    whoops wrote:
    Hi!
    I don't really get what you mean... the Desktop usually is a file manager, isn't it? I'm not sure if Thunar draws the desktop, but Nautilus can even be pretty bitchy if something else (like conky) wants to have a piece. I didn't care enough about rox and its "everything's a folder"-philosophy to take a really close look at it, but there was an option to have it provide a desktop, too, if I remember right. And rox sounded/looks a lot, as it would provide the most "normal filemanager" behaviour when providing the Desktop (didn't try though - maybe I will).
    http://img25.imageshack.us/img25/5576/shot0004bvb.jpg
    Did my best to try to elaborate by using an example there on a screenshot of my desktop. (A sloppy edit done in the GIMP)
    EDIT: What I would be looking for is something contained to that spot, so that way, if I were to right click inside of the rectangle, such as on a file, I would get options with what to open the file, or something else, even copy, cut, paste, or delete.  However, if I were to right click outside of the rectangle, I would get my openbox menu.  Hope this helps make more sense.
    Last edited by ntowakbh (2009-06-13 21:04:43)

  • Hi everybody, my Macbook air mid 2012 MD 231 suddenly shut down then i can not turn it on. I heard a sound like a fuse is blown or something like that. Did any system break or burnt? I did not charge at that moment. Plz help

    my Macbook air mid 2012 suddenly turn off after a strange sound (like the sound òf a fuse has blown or something like that) and I also feel a burnt smell too while i am watching a film on the internet and did not charge the laptop at this moment. The sound was from the left of it, and now just a dark screen , even I tried charging it (still has green light at the charge tool). I bought it on 13st April 2013, not often use.
    I love apple and i am so sad that a new product which i seldom use could be break so easily and outstanding. It's so late in my country now but i am too disappoint about the trouble so i am writing with hope of supporting from Apple and the community.
    Please help , thank bro

    You will have to take it to an Apple Store for repair.

  • I buy adobe creative suite for teachers and students about one year ago but now i'm not longer a student. Can I still use this programs legally for commercial purposes or do I have to buy some upgrades or something like this? Please help

    I buy adobe creative suite for teachers and students about one year ago but now i'm not longer a student. Can I still use this programs legally for commercial purposes or do I have to buy some upgrades or something like this? Please help

    The license did not have use restrictions Licenses and terms of use | Adobe
    BUT... when your one year Education account ends, I do not think you will be able to renew at the Education rate

Maybe you are looking for

  • Creating stills in photoshop cs2 for 16:9 HDTV

    Hi, I've been reading posts regarding creating stills and still need some clarification. I'm from a print world, so dealing with square pixels vs. non square, hdv, vs dv widescreen is all a bit confusing.... I've been to this link: http://www.fcpbook

  • CS4 problems 'Login has Expired"

    Hello all,              I have just picked up my full version of Photoshop CS4 at Office Depot and I am having trouble downloading it to my laptop.  I originally downloaded the 30 day free trial from the Adobe website to see if I would like it and I

  • Need to detect when an item is clicked in a combo box in flex 3

    Hello I am having a check box and a combo box whenever any selection is made in combo box (current selection may be same as previous selection), I need to select the check box. By default the 1st item in combo box is selected and check box is unselec

  • Deploying war Tomcat sun one

    Our developers gave us war file they tested on tomcat and when we deloyed it on sun one it gave us this error. failure (12525): ContextConfig[test4] WEB3524: Parse error in application web.xml org.xml.sax.SAXParseException: Element type "web-app" is

  • Server name problem-jdbc connection string

    hi.. my server name is SERKANPROX\LOCALHOST .. i couldn't connect to this server with this server name . how can i write the server name in connection string?. this is the part my code: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").ne