JPanel with many children doesn't display them all in a narrow window

I'm writing an application that has a JPanel at the top containing many
JToolBars. However, the height of the JPanel stays constant when I narrow
the application window so that many of the JToolBars are not displayed.
I would like to have the JPanel increase in height as the window narrows
so that all the JToolBars remain visible. How can you do this? Thanks.
Try widening/narrowing the window in this example:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Sample extends JFrame {
    public Sample(String name) {
        super(name);
        JPanel tp = new JPanel(new FlowLayout());
        for (int i = 0; i < 10; i++) {
            JToolBar tb = new JToolBar("toolbar" + i);
            for (int j = 0; j < 10; j++) {
                tb.add(new AbstractAction(("Action" + i) + j) {
                    public void actionPerformed(ActionEvent event) {
            tp.add(tb);
        JPanel cp = new JPanel();
        cp.setSize(400, 400);
        cp.setBackground(Color.red);
        add(tp, BorderLayout.PAGE_START);
        add(cp, BorderLayout.CENTER);
    public static void main(String[] args) {
        Sample s = new Sample("Sample");
        s.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        s.setSize(500, 500);
        s.setVisible(true);
}

There are some neat tricks in this thread.
http://forum.java.sun.com/thread.jspa?threadID=716580&messageID=4190052

Similar Messages

  • Multiple parents with many children in same table -get all generations

    Hi
    I have parent and child columns in my table. The child can have multiple parent keys and the parent can have multiple child keys.
    So every child can be a parent of further more children. So every generation can be considered to be a level. I need to display them in hierarchical order. First greatest parent, next level all its childres, next level, their children and so on. Its like a recursve pattern. How may I achieve this? I do not know anything about how many levels there are - could be any number.
    Any help?

    Hi
    This link was of great help and I am getting the hierarchy.
    My next question related to the same thing is -
    I have the following query:
    select distinct level,
    sys_connect_by_path(child_id,'/') Path
    from table1
    connect by prior child_id= parent_id
    What I need is getting the name beloging to the id and display that instead of the id itself. But then would that mean I am changing the connect_by_path itself?
    Example:
    id
    2     /25/016
    2     /25/06
    2     /20/014
    In place of these numbers 25, 016 etc, I want their corresponding names that are stored ina nother table table2. How may I achieve that?
    Thx!

  • Album Art doesn't display in all cd in the Zen Visio

    Album art doesn't display in all cd in the Zen Vison M . I have 649 cd and most of them display correct on ZEN Vision M. But some doesn't , I try to delete de Cd and rip it again and add the album art it didn't work for some reason some of the albums does not dipslay. The album art shows in Zen Explorer but not on the Zen vision M. Do you know why. I also try to get the Cover enlarge 200x200 or larger 500x500 but still odesn't work please any help. I had read all the suggestion in the forum also and follow suggestion but it doesn't work.
    Take Care
    AussieDog

    If you select multiple songs and choose Get Info, the Album Art box will always be blank, even if the individual songs each have the same common Art. This is expected behavior.
    Copying the Art directly to the iPod will never work. If your iTunes displays the Art fine, and the nano doesn't, your problem is likely to be a firmware issue with the iPod. I would suggest performing a "restore" and then try again. Otherwise, if issues remain, reinstall iTunes if more than one XP user is affected.

  • I lost all my contacts i havent backed it up on computer or icloud i synced it with my macbook and accidently deleted them all off my macbook and now its gone of my phone!! help me

    i havent backed it up on computer or icloud i synced it with my macbook and accidently deleted them all off my macbook and now its gone of my phone!! help me

    You'll have to restore them from the most recent backup you made before you deleted them.
    When computers and iOS devices are "synced" together, whatever you do on one device is synced to the others. You deleting them off your Dads phone made the same occur on your phone. That's how it is supposed to work.

  • JPanel with Image just doesn't want to show

    Hello,
    i am trying to create a JPanel with a JLabel to which i assign an ImageIcon, but for some reason the JPanel seems not to appear in my JFrame.
    Here's the code: private void jbInit() throws Exception
        NumberListener numListener = new NumberListener();
        frame = new JFrame();
        frame.setTitle("Error Manager");
        frame.setLayout(new GridBagLayout());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        gbc.gridwidth = 1;
        gbc.gridheight = 1;
        gbc.weightx = 1;
        gbc.weighty = 1;
        gbc.gridx = 0;
        gbc.gridy = 0;
        numberList = new JList(numbers);
        numberList.addListSelectionListener(numListener);
        numberList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        JScrollPane listScroller = new JScrollPane(numberList);
        listScroller.setPreferredSize(new Dimension(250, 80));
        frame.getContentPane().add(listScroller, gbc);
        imgPanel = new JPanel();
        imgPanel.setSize(300, 250);
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image img = toolkit.createImage("Somepic.png");
        imgPanel.add(new JLabel(new ImageIcon(img)));
        gbc.gridx = 1;
        gbc.gridy = 0;
        frame.getContentPane().add(imgPanel, gbc);
        frame.pack();
        frame.setVisible(true);
      }

    Sorry forgot to close the code tags...
    private void jbInit() throws Exception
        NumberListener numListener = new NumberListener();
        frame = new JFrame();
        frame.setTitle("Error Manager");
        frame.setLayout(new GridBagLayout());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        gbc.gridwidth = 1;
        gbc.gridheight = 1;
        gbc.weightx = 1;
        gbc.weighty = 1;
        gbc.gridx = 0;
        gbc.gridy = 0;
        numberList = new JList(numbers);
        numberList.addListSelectionListener(numListener);
        numberList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        JScrollPane listScroller = new JScrollPane(numberList);
        listScroller.setPreferredSize(new Dimension(250, 80));
        frame.getContentPane().add(listScroller, gbc);
        imgPanel = new JPanel();
        imgPanel.setSize(300, 250);
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image img = toolkit.createImage("1_Alpinweiss_III.png");
        imgPanel.add(new JLabel(new ImageIcon(img)));
        gbc.gridx = 1;
        gbc.gridy = 0;
        frame.getContentPane().add(imgPanel, gbc);
        frame.pack();
        frame.setVisible(true);
      }

  • Problem with video skin doesn't display on html although the video played normally.

    I used "Adobe media encoder" to convert a video file to "FLV" format, so that I can import to "Adobe Flash CS5" . I have chosen all the component buttons and tried to "publish preview" on to html but the video skin doesn't display although the video does. Two swf file skin file + fla + swf movie + html are all in the same folder.
    Please help....I have tried to fix this problem for 10 hours already and still have no luck, tried to search online for solution but counldn't find anything.
    Message was edited by: adobe_user_2

    I already gave you the answer to your problem and now here is
    the proof:
    http://www.johnkalnin.com/test/dancin/dancin.swf
    Notice the skin?
    http://www.johnkalnin.com/test/dancin.html
    Notice the lack of a skin?
    This is because the skin is in the wrong directroy. If I put
    the skin in the same folder as the HTML file, not the swf, it
    works. So if you would do what I said a few posts ago and make this
    work:
    http://www.mikelrouse.com/SteelExternalAll.swf
    Then your problem would be solved. The problem is that the
    skin path must be defined by the html file calling the swf file,
    not the location of the swf file.
    PS - My daughter is too cute!

  • How to arrange contacts in my Addess Book starting with the last name, re-doing them all at once, not individually. (I have 910 names in my Address Book).

    This is a new computer. I see that my addresses have been arranged so that they read from the first name -- i.e. Jimmy Brown comes under 'J', not 'B'. I should like to put them all so that they read from the last name, first. I can do this individually but very much hope that there is a way that I can do ALL of them in ONE go? There are 910 addresses! Thank you very much, Frederica

    First step is to set the address book to show last name and then the first.
    Open the Address Book
    Select View-Show Name As-Last, First
    Then click on the column header labeled NAME to sort on that column.

  • On a long web page with many small pics Firefox (4.0.1 on Linux Mint 11) doesn't load them all at once, and MAFF replaces original pics with blank lazy.png

    Similar problem trying to save web page with ScreenGrab! (many small pics on the web page are blank). Maybe there is a way to fine tune Firefox?

    Does the ext directory have the php_oci8.dll? In the original steps the PHP dir is renamed. In the given php.in the extension_dir looks like it has been updated correctly. Since PHP distributes php_oci8.dll by default I reckon there would be a very good chance that the problem was somewhere else. Since this is an old thread I don't think we'll get much value from speculation.
    -- cj

  • My local library uses a program called Overdrive Media Console to check out audiobooks.  MP3 type books go to music on my iPod Nano, but I am unable to delete them because I tunes doesn't display them as content. What should I do? I need the space.

    According to my library, I can download MP3 audio books to my Ipod Nano.  The material is "checked out" to a program called Over Drive Media Console. and from there, it is transferred to my IPod.  the audio doesnt go to Audi Books, it goes to Music.  I want to delete some of the books I have listened to, but when I plug in the Ipod and open ITunes, the titles are not there.  The manual says to connect to itunes, and delete a "song or other material" but since I  did not use ITunes to get the
    "song" to begin with, it isnt recognized.  How can I get these audioboks off my IPOD?  I am running out of space.  I tried connecting to Overdrive, but the software doesnt recognize the internal content.  It only sets it up for transfer.

    The audio books do not display under the music sub-menu
    And they shouldn't.  They should be under the Books submenu that is further down the list from the Music submenu you are referring to.
    B-rock

  • Centralizing text in JButtons in a JPanel with a boxLayout doesn't work!!!

    Hello, I tried to use the JLabel constructor:
    JLabel saveButtonLabel = new JLabel("Save", JLabel.CENTER);
    and then put it in the JPanel:
    controlPanel.add(saveButton);
    but the text is still aligned to the left. What have I done wrong please!!!
    I am using the folling to seperate the JButtons, if this is at all affecting it:
    controlPanel.add(Box.createHorizontalGlue());
    controlPanel.add(Box.createRigidArea(new Dimension(13, 0)));
    regards

    Is your control panel being added to a border layout, and if so, what section (SOUTH?)

  • Too many keywords, can't see them all in search?

    Hi all,
    I am a recent "convert" from the Beastmaster, and am trying to digest iPhoto coming from Adobe Photoshop Elements for PC.
    My keywords imported fine from PE to iPhoto, but I seem to be having a problem. When I click on the keyword search at the bottom of the window, the pane with keywords comes up, but only a portion of them (from what looks like alphabetically letter "D" to "Z". It is as if 0-9 and A-C are "above" the top of my screen, yet I can't widen the window or scroll up in the keywords. Any ideas? I am trying to search by a "b" keyword and I can't seem to get to it to search!
    Thanks.

    oliburner:
    Welcome to the Apple Discussions. That's a common complaint. One workaround is to use one of the 3rd party keyword apps like Keyword Manager which will let you arrange keywords hierarchically.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier) database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 6 and 7 libraries and Tiger and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Perssonas not being displays - Themes are but top of window not colour and firefox button not shown correctly

    I have installed the personnas plus add on and have tried to select several different personnas (e.g. Earth from space etc.) but none of them appear to be displayed. The window remains its default light blue.
    I am not aware that i have installed anything else which could have affected this situation.
    When attempting to apply a full theme the very top bar of the window (with minimize, exit etc.) is also not coloured as it should be - see the theme FT Deep Dark 5.6 for example. And the firefox button has an orange 'fuzzy' ' glitchy' border around it still.
    Cheers if anyone knows anyway around this problem :>

    hello Kirie_kore, it is a known issue that light-weight themes are currently not shown when firefox is set to ''never remember history'' (a.k.a. always run in private browsing mode) in firefox/tools > options > privacy. this will be corrected in the upcoming firefox release.

  • GREP search for \$ Dollar sign doesn't find them all?

    Hello,
    OK-I was practicing my GREP yesterday and was working with escaping out characters. Since the $ could not be found, I assumed it needed to be escaped out \$. The odd thing is, when I say find next, it skips many of them in the document?
    Anyone know why?
    thanks!
    babs

    This has been reported before; it's an oddity of ID's implementation of GREP. Nobody knows why! (*)
    It only works reliably when you do not use the escape code \$ (you were, in fact, correct to try that first!), but instead use the Unicode notation for a dollar sign: \x{0024}.
    I've noticed some strange GREP-related behavior myself: at times, it seems "Find Next" can skip a *huge* quantity of text and finds something near the end of the file; but a next "Find Next" mysteriously jumps back to the previous find position, and continues from there as if nothing happened.
    (*) I'm pretty sure it's the Adobe engineers that are responsible for this. According to Peter Kahrel, Adobe didn't write the GREP module by themselves but chose to use a free programming library called "boost". Now boost is an extremely thorough piece of work that has gone through literally years of development and dozens, if not hundreds of programmers (probably unpaid as well, since boost is open source), and I cannot imagine something like this to slip through unnoticed.
    But ... for InDesign, the Adobe programmers had to add code to cater for InDesign's own special characters and codes -- stuff like the special characters and spaces, and text variables. It's not hard to imagine a programmer accidentally changing a line of code that did the, erm, "now search for \$" stuff.

  • New system with Neo4 Platinum doesn't work at all!!!

    Hi guys,
    I bought my new system:
    1 - AMD Athlon 64 3200+ Core Venice
    2 - MSI K8N Neo4 Platinum /BIOS 1.1
    3 - RAM S3+ 1GB (2x512 MB)
    4 - Western Digital Caviar SE 120 GB SATA WD1200JD
    5 - Hitachi Deskstar 80 GB SATA II HDS728080PLA380
    6 - NEC 3500AG DVD-RW
    7 - Albatron 6600GT 128 MB PCI-E
    8 - Enermax Noisetaker 485W
    Where is the problem?
    It's IMPOSSIBLE to install the OS.
    I can't install Windows XP, I can't install Windows 2000, I can't install Windows 98.......
    When I try to install Windows (no matter what version) the system tell me that it CAN'T read or write some file from the CD to the HD.
    No matter what files it is, once it's the shell32.dll...... another installation it's the file ntdll.dll....... another time the file riched20.dll....... another time it's the file "whatTHEhell!" and so....
    I tried to connect one only HD, I tried to connect the WD and the same. I tried to connect the HITACHI, and the same.
    I tried to connect my HD to SATA 1, 2, 3, 4 on nVidia controller, and the same.
    I tried with the Silicon Image controller and nothing changed.
    I tried to change the optical drive, I connected my old ASUS CD 50x and disconnected the DVD Writer, but the same.
    I've started to think that this could be a cable issue, then I changed the IDE Cable and the SATA cable... but nothing.
    I flashed the bios from version 1.1 to 1.4 with the support to Venice core, the same.
    I also disconnected my SATA HD and I've plugged in my old PATA HD, an old Samsung 6,4 GB HD............... BUT NOTHING!
    I can't imagine nothing more to do to solve the problem, but I'm listening for your advices.
    Thank's.
    elem

    Quote from: Supershanks on 05-June-05, 19:23:35
    hi elem,
    Type of floppy i meant was 1 with a usb componenent like:-
    Mitsumi FA404M 1.44 Silver FDD+Int USB2 7 in 1 Card Reader so if it's just a n ordinary floppy i'd plug it back in.
    I'd try 3) Memtest86+ run it as decribed in the link to verify your memory isn't the issue.
    luck
    Yes Supershanks and blazing storm,
    I misanderstood, but now I reattached my floppy and performed a full scan of my HDDs
    with their own diagnostic tools, downloaded from the Western Digital and Hitachi websites.
    I choosed the DOS version that make a bootable floppy disk and verified the drives.
    The HDDs are working fine and there's no errors on the surface, the HDDs are ok.
    Quote from: SAB on 05-June-05, 19:35:43
    Try swapping the optical drive that you are loading the O.S. from. Make sure SATA controller AND SATA ports are enabled. Make sure IDE controller for floppy is also enabled. Perhaps your optical drive has one piece of dust on just the wrong place. That's all it takes to throw one of those things off!!!
    SAB, I've tried to swapping my optical drives yet. I've tried a DVD-RW NEC 3500 AG, then a CD Player from ASUS, then a CD-RW from LITEON.
    The same problem with the new system, but these are performing very well on my old pc, then these aren't the problem.
    I think the problem could be only on CPU, or MOTHERBOARD or MEMORY.
    Thank's Supershanks, I'm downloading MemTest86+ for a memory scan.
    I'll let you guys to know as fast as possibile the results!

  • ITunes says my iPad 2 is over capacity with videos but I've removed them all when syncing. Please help. Have restored it too-didn't work

    It's been this way for days. Restoring doesn't seem to work.

    If you are sure that the videos have been removed from the iPad - Have you tried restarting the iPad or resetting it?
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

Maybe you are looking for

  • Need info on automating SAP email to PO requestors for AP events

    Hi Friends,           Is there any BADI for triggering the PO(Invoice changes). For example when an invoice posts against a PO the system could automatically send an email to the PO requestor in SAP that this invoice was posted against this PO.It is

  • Use of variables in cross tab

    Hi experts, Can anyone tell me how to use a variable in cross-tab? I am populating the crosstab from the columns of a table. I want to use a variable (say percentage of averages) which calculates for each month for any number of months the data has b

  • WS-File Scenario Error

    hi all, i have a scenario that send data from WS to file. when testin my scenario im getting this error in MONI.   <SAP:Category>XIServer</SAP:Category>   <SAP:Code area="MAPPING">NO_MAPPINGPROGRAM_FOUND</SAP:Code>   <SAP:P1>Object ID 7511E1BD8936326

  • ME9F PO display message as PDF

    Hi,   I have a requirement in ME9F  there is option as display message  then we can see the PO as displ;ay we want that that display should open as PDF vievwer is it possible  what setting are required for this.   In ME22N there is button as print pr

  • HT201205 How can I keep my phone paired with my car after I leave car?  My 4 had no problem

    I just replaced my iPhone 4 with a 5s.  It pairs with my car and when I leave my car, it uu-pairs.  My 4 did not have this problem. I don't want to have to pair my phone everytime I get in the car.