Why FlowLayout - JPane will NOT auto adjust in size?

Hello java friends,
I don't understand why my little demo program's JPane(use FlowLayout manager) will not adjust the size correctly. When run, I see one row of buttons, which only show 11 of them; the rest are shown on secon row which only visible if I go resize the window. Why is that? Wouldn't FlowLayout manager will auto size the pane? My main frame used the pack() method, so it's up to the pane's preferredsize. Please give me some ideas. Thanks.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Template {
    public static void main(String[] args) {
         JFrame mainFrame =new JFrame("Template");
        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        mainFrame.setContentPane(new TemplatePane());
        //Display the window.
        mainFrame.pack();
        mainFrame.setVisible(true);
class TemplatePane extends JPanel
          implements ActionListener {
     JButton componentAry[] =new JButton[100];
     TemplatePane() {
          this.setLayout(new FlowLayout());
          for(int i=0; i<componentAry.length; i++) {
               componentAry[i] =new JButton("Test#"+i);
               componentAry.addActionListener(this);
               this.add(componentAry[i]);
     public void actionPerformed(ActionEvent ae) {
          System.out.println(ae.getActionCommand());

I did read the API doc:
>>>>
A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. Flow layouts are typically used to arrange buttons in a panel. It will arrange buttons left to right until no more buttons fit on the same line. Each line is centered.
>>>>
My question is why won't it adjust the pane size if the there is more than one line? It did draw the second line for things that won't fit in the first line... just not visible unless the whole window is resized to a bigger view. Can you please provide an explanation?

Similar Messages

  • Lumia 920 clock will not auto adjust to operator t...

    I have a 920 Lumia and the date / time function is set to ON for 'set automatically'.
    I just travelled from the UK to Belguin and the clock updated to the Belgian time zone and time.
    I have been back two days in the UK and it's still stuck on Belgian time, I have turned it on and back off a few times but it's still the same.
    I travel to Europe a lot and would like this function to work, it did this no problem on my previuos N8 (just about the only thing that did work on it..... )
    Thanks for any responses.

    Thought so. On orange the automatic time feature used to work but since they became EE it either doesn't work or only works intermittently. I believe they may have dropped support for the feature, or it only works when connected to orange transmitters, not the t-mobile ones. Forcing it to pick up an orange 2G signal may help but not totally sure.
    Sadly it's a network issue, not a hardware issue.

  • Why Safari 6.0 will not auto complete the password ?

    Why Safari 6.0 will not auto complete the password ? even when the option is selected in autofill tab, and the user-password are listed in the password tab ?
    It used to work fine before I upgraded to mountain lion.
      Tks

    Same problem for me since upgrading to ML.  Safari remembers autofills for some passwords but not others.  For example my web mail password was no longer auto filled.  Checked in the keychain list and all the info was there. Therefore I deleted this and tried again - but Safari did not offer to remember the password.  Than ran an old script I had that is designed to "Removed autocomplete=off from 0 forms and from 2 form elements, and removed onsubmit from 0 forms. After you type your password and submit the form, the browser will offer to remember your password." Safari then offered to remember the password.  I accepted this and checked that the password was then saved in keychain - it was. However, next time I tried to access the email Safari once more did not auto complete.  Very frustrating, especially as some auto completes do work.  I hope apple sort this out soon.

  • Captivate 7: slide with mouse will not auto advance after publishing

    After I export my Captivate video, any slide that has a mouse object on it does not auto advance. I suspected that maybe the clicking sound file default attached to the action may have become corrupted, so I opened the sound file attached to "single-click" from Captivate. In the VisualClicks folder, there were no sound files. So, I opened the ClickSounds folder and attached the Mouse.mp3 file to this action. After publishing the training, the slide still will not auto advance. The slides that do not have the mouse action advance automatically as they should. The sound file may not be the issue (going to try to uncheck all of the Mouse Click Sound check boxes and republish to see if that helps).
    Was hoping to find a solution for future videos.
    Each slide is basically a layer of audio > slide > png file > the occasional smart object and/or text > mouse. I have no quizzes or video.
    When publishing I use the following setup swf/html5 with swf + html5 checked and scalable HTML content checked. We use Google Chrome and I've had numerous people try my HTML link after I've uploaded all files and everyone has the same issue. 
    1- Do you happen to know why the mouse action would cause the slide to not auto advance, and if so please let me know a solution so the user doesn't have to click next. If the mouse itself isn't the culprit, any other suggestions on what could cause this?
    2- Is there a way to make changes to the audio or override the mouse properties on all slides? I tried right clicking and "use the current mouse pointer for all slides" but it didn't change any of the properties. Thankfully my video is only 110 slides or it would have been even more painful.
    Captivate 7
    Windows 8.1

    Of course! Here ya go
    For the record, I did create a new project with only two slides to try and duplicate the issue. I had the same problem. I unchecked the Mouse Click Sound check box, republished and the slide auto advanced. I'm wondering if a default sound file was somehow moved or deleted? I discussed uninstalling and reinstalling C7 onto my laptop, but that's a frustrating solution haha

  • Driver disk will not auto run on Mac Pro 08

    Hi
    I have a Mac Pro early 08 and i'm finding the Leopard driver disk will not auto run "to install" drivers but it only gives me 2 other options for disk share and something else which I forget now as I un=installed.

    Hi
    Oh god no I popped the disk in when WVU finished installing and arrived on the desktop and it only gives me 2 install options.1.for the MB air and another for disk sharing but why does it not install drivers aotomatically?
    The driver disk does not aoto run under vista and which drivers do I use ..also the ATI just does not want to work "advising errors of hardware or software" not installed.
    I have done this numerous times on the iMac and XPP worked fine with the driver disk but WVU is giving me headaches.
    Message was edited by: macbookair

  • TS1398 Since I upgraded to iOS 7.0.2 my phone will not auto-connect to the home WiFi network.

    I upgraded my iPhone 4S to iOS 7.0.2 and now my phone will not auto-connect to the home wifi network.  Each time I leave and return to within range of the network I have to remember to manually connect, otherwise it continues to use 4G for data.  The credentials are saved (all I have to do is tap it to connect) but just won't happen automatically any more.
    Is anyone else seeing this problem?

    Tried the reset multiple times. No go. Before the IOS 7.0,2 update my devices were connecting to home WIFI eventually.

  • Why my Ipad2 will not play rented video to a projector via vga adapter connection

    Hi, i want to know why my ipad will not play rented video to a projector using the apple vga adapter connector.  This is just basic mirroring and there should be no problem isn't it?  Please help.
    Thank you

    Technically, yes, it should be easy. However with rented videos you may be running into DRM (DIgital rights management) where you may not be allowed to play that video anywhere but on the iPad. The video could have a bit of programming in it that literally tells the HDMI or VGA output not to work.
    One way to test the connection, with your ipad's camera, shoot a short video and try to mirror that. If it mirrors and the movie doesn't then it's likely that you're simply not allowed to mirror it. If it doesn't play then there may be something wrong hardware or setting wise.

  • My ZAGG keyboard will not auto-cap, How do I fix that

    My ZAGG keyboard will not auto-cap, How do I fix that?

    What MacBook? How did you try to 'play' CDs? What happens? Does it happen with a specific CD, some CDs, or all CDs? Does it happen with data CDs, or audio CDs, or both? Does it happen with commercially-pressed CD, or CD-R, or both?

  • Why IPHOTO album will not keep the template format when share to IDVD.

    Why IPHOTO album will not keep the template format when share to IDVD. Also, could be better if IPHOTO Album could access "inspector tool" with ability to change the slide duration time and apply a random "Transitions" to specific slide.

    Are you sharing an album of photos or a slideshow to iDVD?  If it's an album then what you get in iDVD is just a slideshow with the photos in it where you have to set the transition and slide timing unless you add music and select fit to audio.
    Don't know what you mean by the template format unless you're referring to the themes in a slideshow? If you share a slideshow the ss is converted to a Quicktime movie file and that is added to the iDVD menu window.  No changes are possible.
    OT

  • My images will not auto resize for viewing

    This is somewhat embarrassing. When viewing images from the web, if they're too large to fit the current window, they get re-sized to fit. Okay. I have a file/page of thumbnails generated by XnView and when I click, the image is loaded, everything is good except the image is always larger than the window. The problem is Firefox WILL NOT auto-resize the image to fit. If I right mouse, I can select "View Image" to view whole image, but I don't want to have to do that for 1000's of images.
    Any help/insight would be appreciated.
    Regards,
    Dave

    Lilly.Love wrote:
    Hi, I'm new to this and for some reason my images are not appearing to full scale on adobe premiere cs6. This is really annoying as I am trying to make a stop motion video but I can't see what I'm doing. Please reply soon, this is an important project. Thanks
    Your sequence settings and clip settings are not matching. To make them match, right click on a clip and choose New Sequence from Clip and a new sequence will be created based on your clip settings.

  • After updating with Security Update 2010-001, Quicken will not auto update.  Auto update function in Preferences are also inop.  Numerous posts in Macbook discussions about similar problems with other apps.

    Installed Security Update 2012-001.  Now Quicken will not auto save and the auto save function in Preferences cannot be changed. There are numerous similar comments in the Macbook discussions about other apps.   Come on, Apple, we need some help out here!

    Howdy,
    Apparently some are reporting that this causes the older PowerPC (PPC) applications that are supported in 10.6 via 'Rosetta' to crash upon attempting to open/save/print using any dialog box, or fail in other similar ways such as simply not printing or quitting, or freezing/hanging/crashing of the application.
    I have read of some companies that have indeed submitted proper bug reports to Apple, but that is not a guarantee of a bug-fix being issued.
    You might wish to read:
    http://www.macintouch.com/readerreports/snowleopard/index.html#d02feb2012
    If you are unsure if you are still using PowerPC apps, if the application is currently running, look under the 'Activity Monitior' (in Applications -> Utilities), or alternatively you could check in the System Profiler, Applications. Check the column "Type".
    Here is a fairly simple way you can restore you system and restore you applications functionality again, if you don't have a recent clone or good Time Machine backup that you can restore from. If you do, restore from your backup prior to having installed the Security Update 2012-001.
    Time Machine restore: http://support.apple.com/kb/ht1427
    If you are restoring a backup made by a Mac to the same Mac
    With your backup drive connected, start up your Mac from the Lion recovery partition (Command-R at startup) or Mac OS X v10.6 installation disc. Then use the "Restore From Time Machine Backup" utility. Select the backup prior to your issues, and it will be restored back to the state it was in at that time.
    If you can't easily restore from a backup, you can instead do the following:
    - You first start by reinstalling your OS X 10.6.x, this will preserve all your user data, your applications, no worries there.
    - Then install the Mac OS X 10.6.8 Update Combo v1.1 (links provided below)
    - Make sure you're printers are showing up correctly in your system preferences, if not, re-add the printers
    - Then finally, run the Apple Software Update (by pulling down the Apple Menu), and install any and all remaining updates, except do not then re-install the Security Update 2012-001. It is possible that you may have to reboot after installing some of the updates, and you may even need to run it a 2nd time to make sure that you've got all updates, except NOT the Security Update 2012-001.
    Links for 10.6.8 Update Combo v1.1:
    http://support.apple.com/kb/DL1399
    or the link to directly download this 1.09GB combo updater:
    http://support.apple.com/downloads/DL1399/en_US/MacOSXUpdCombo10.6.8.dmg
    Cheers,
    Daniel Feldman
    =======================
      MacMind
      Certified Member of the
      Apple Consultants Network
      Apple Certified (ACHDS)
      E-mail:  [email protected] 
      Phone:   1-408-454-6649
      URL : www.MacMind.com
    =======================

  • I,ve got a retail box CS6 design, it will not auto run or start set-upexe, help.

    I,ve got a retail box CS6 design, it will not auto run or start set-upexe, help.

    are you using a window's system?  if yes, which version?
    and, attach a screenshot of your disc's contents.

  • Help! My iPad 3 will not auto-rotate!

    Help! My iPad 3 will not auto-rotate to landscape when watching something from YouTube. Please help me fix this.Thanks(:

    Hello:
    I do not watch YouTube on my iPad, but check the setting in settings>general>use side switch to:
    If it is set to "lock rotation," the switch on the side of your iPad is probably set to prevent it.
    Barry

  • Droid Turbo will not auto-rotate

    My Turbo will not auto rotate in any app. I have toggled the auto rotate option, and reset my phone to factory. An ap I downloaded indicated the gyroscope was working fine, but it still will not work.

        Hello themattgorr,
    I want to make sure we get your Turbo back to its normal functionality. I know many of my applications require my screen to rotate as well.  I appreciate all the troubleshooting you have completed to try to resolve this issue.  Are you only encountering this issue on applications? Does the phone have any screen damage?
    YareliM_VZW
    Follow us on Twitter at @VZWSupport

  • I asked this question in iMovie and told it belonged here. When i try to copy homemade movie _TS format it will not auto load in DVD player original does. How do I make a copy that will auto load?

    I asked this question in iMovie and told it belonged here. When i try to copy homemade movie _TS format it will not auto load in DVD player original does. How do I make a copy that will auto load?

    garysm99 wrote:
    Not familiar with structure view. How do I go there?
    click in IDVD on this button

Maybe you are looking for

  • Profit center report with old currency exchange rate

    Dear All, I have a requirement in PCA reporting. We have maintained exchange rate as 1.86 Egyptian pound to 1 Saudi Rriyal from 01.01.2001 to 31.03.2014. Also, from 01.04.2014 onwards the exchange rate is 1.90 EGP to 1 SAR. When we run PCC report on

  • BI content for invoices from vendors

    Hi guys, Can you please help me in finding the appropriate BI content (DataSource, ETL, Cube, etc) for vendor invoices. I must find a way to put together the invoices that have been received from all the vendors, both on header and item level. Thanks

  • Pdf view : jumping back problem ?

    Hello. I've been having an issue lately where i view pdfs on Acrobat.com, and when i drag the sliders up, the page first jumps to its top, then slides normally from where it should be. Correct behaviour while dragging sliders to the bottom : pages fl

  • BOE上一个很奇怪的问题(Database Connector Error)

    BOE版本: XI3.1 OS:  SUSE10 DB:  SAP BW 情况是这样的: 安装BOE时, 用的是客户从Service Center上下载的临时的License, 在2010-1-12日到期. 安装完后在2009年12月底替换过一个临时的License, 是到2010-3-8日的. 客户这边由于公司采购流程的原因, 正式的license流程还没有走完,只好先用临时的license了. 现在问题出来了, 2010-1-12的早上, 包括测试的BOE系统和正式的BOE系统上的报表都同时

  • Implementing UIApplicationDelegate protocol methods in NSObject class not working.

    Hi Everyone, I am new bee in iphone developement. I want to implement UIApplicationDelegate protocol methods in one of my NSObject class, how can i implement that help me please. I have mentioned the sample code what acutal i want to impelment. .h fi