Heavy Fog - Layout Managers and the word "preferred"

Hello again world.
While reading the API, the tutorials, and various other documentation dealing with layout managers, I keep coming across the word "preferred" - "preferred size", "preferred width", "preferred height", and so on.
However, I can't seem to visualize just what "preferred" means in this context.
Do they pre-suppose that one has used the setPreferredSize() method?
And if no set*Size() method is used, how does the parent container size its components? The literature just comes back to "preferred" this and that.
This whole "preferred" business is, to me, circular and confusing, and the more I read, the foggier things get.
Anyone out there with a fresh breeze?
Thank you one and all.
Ciao for now.

You should never use setSize(). The size of a component is set by the LayoutManager as the components in the container are layed out. For example say you are using a GridLayout and you have 3 buttons: following text:
small = new JButton("small");
medium = new JButton("medium sized");
large = new JButton("the largest button");
The preferred size of each button is calculated to be:
a) the size of the text +
b) the border +
c) the margin
When components are added to the GridLayout all components are made the same size. The preferredSize does not change, but the size of each button is set the the largest preferredSize of the three buttons before it is painted. The GridLayout ignores the preferredSize of individual components and only cares about the largest component.
On the other hand the FlowLayout repects the preferredSize of each component when they are layed out and painted. When using a FlowLayout you can set the preferredSize of each component to be the same by doing the following:
small.setPreferredSize( large.getPreferredSize() );
medium.setPreferredSize( large.getPreferredSize() );
Every LayoutManager has rules it follows with respect to preferredSize, minimumSize and maximumSize. Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]Using Layout Managers.

Similar Messages

  • When I take my phone off charge in the morning I get an info box on the front which has the sound trumpet icon with a line through it and the word Mute.  The only way to get rid of it is to reboot the phone any ideas as to how I can stop this happening?

    When I take my phone off charge in the morning I get an info box on the front which has the sound trumpet icon with a line through it and the word Mute.  The only way to get rid of it is to reboot the phone any ideas as to how I can stop this happening?

    Hello cor-el, thanks for your reply. I changed my settings for downloads to desktop and it has appeared on there. When I double click I am asked which program I want to open file. I click firefox and another box "opening install" says I have chosen to open the file which is an application and do I want to save it. This is the only real option so I press save file. I get a box saying this is an executable file which may contain viruses - do you want to run. I press ok and the final box showing C drive file name and desktop appears stating application not found.
    This happens the same whenever I try to install.
    To my untrained eye the application is not being recognised as an application and I cannot work out how to get it to do that.
    My plugin is still showing as out of date.
    Is there anything you could suggest. Thanks for your time.

  • Change the icon and the word "open" at the left upper corner of file dialog

    i wanna to change the icon and the word "open" at the left upper corner of a Jfilechooser...
    can any expert tell me how to do so?
    thx and thx...

    yeah u can change the JFileChooser's title by calling the setDialogTitle(String) method. i'm not sure of the icon change, i think it can't be done.

  • How to fix itunes playback from being choppy and the words out of sync? i have windows 8

    I am trying to playback a movie in itunes on my windows 8 computer but it is choppy and the words aren't in sync.

    Hi nick9192,
    Welcome to the Support Communities!
    The article below may be able to help you with this. It applies to Windows 8 as well.
    Click on the link to see more details and screenshots. 
    Troubleshooting iTunes for Windows Vista or Windows 7 video playback performance issues
    http://support.apple.com/kb/ts1718
    Cheers,
    - Judy

  • HT2242 I followed directions, USA Flag selected. Content of App Store (and the words "Install" etc and error messages, still in Russian

    I followed directions, USA Flag selected in bottom corner. and the content of App Store and the words "Install" etc and error messages, still in Russian. How do I reset to English?

    Look here.
    http://support.apple.com/kb/index?page=answerlink&url=http%3A%2F%2Fsupport.apple .com%2Fkb%2FHT1495&answerid=16777216&src=support_site.home.search

  • Icon on my desktop that-a sheet of paper with @ sign on it and the word NUMBER below it. Looked in Finder using QuickLook "Desktop" it said, javascript:void%20SortColumns('NUMBER)' Is it Malware?

    Icon on my desktop that-a sheet of paper with @ sign on it and the word NUMBER below it. Looked in Finder using QuickLook "Desktop" it said, javascript:void%20SortColumns('NUMBER)' Is it Malware?

    Bstarling wrote:
    I am unable to write down because the log is moving too quickly.
    Well, you don't have to write down anything. Just click on the message and copy it. Then paste it here, or in a text editor (eg, TextEdit). And you can enter a string like "Audio CD" (w/o the quote marks) in the filter and see only messages containing it.
    mds[71]: (Error) Server: Failed to register path "/Volumes/Audio CD"
    That's the metadata server, used by Spotlight. AFAIK, Spotlight does not index audio CDs, so what is this about? I don't know. Maybe it's the cause of what you observe; or maybe it's another symptom. Thinking again of the network issue… have you maybe installed some third-party software related to both Spotlight and the network (Searchlight perhaps)?

  • The font for my yahoo log in is very very small anbd my email fonts are far too big and the words overlap, please help to correct this problem

    The font for sign into my yahoo mail is so small that I am unable to make out my ID and password and when I do get into my mailbox, the fonts are far too big and the words overlap. Tried going into tools /options to make changes but not successful, please help.thanks

    Reset the page zoom on pages that cause problems, make sure that the window is not maximized:
    *<b>View > Zoom > Reset</b> (Ctrl+0 (zero); Cmd+0 on Mac)
    *http://kb.mozillazine.org/Zoom_text_of_web_pages
    If you have increased the minimum font size then try the default setting "none" as a high value can cause such issues.
    *Tools > Options > Content : Fonts & Colors > Advanced > Minimum Font Size (none)
    Make sure that you allow websites to choose their fonts.
    *Tools > Options > Content : Fonts & Colors > Advanced > [X] "Allow pages to choose their own fonts, instead of my selections above"
    You can use an extension to set a default font size and page zoom on web pages.
    *Default FullZoom Level: https://addons.mozilla.org/firefox/addon/default-fullzoom-level/
    *NoSquint: https://addons.mozilla.org/firefox/addon/nosquint/

  • Layout managers and JTabbedPane

    I have a JTabbed pane on my 'form' on which i want to insert two tables. the problem is that the tables are overstepping the 'boundaries' i have desgned for them ,whivh i suspect is a problem with the layout managers. I just cant seem to be able to restrict the tables within the fames and have scrollpanes, both horizontal and vertical for scrolling tables. I have included the code here:
    import java.awt.*;
    import javax.swing.*;
    public class FrmProducts extends JFrame{
         private          JTabbedPane tabbedPane;
         private          JPanel          factorsTab;
         private          JPanel          productListTab;
         private          JPanel          rateHistoryTab;
         private          JTable          forexFactorsTable;
         private          JTable      otherFactorsTable;
         private      JTable          productListTable;
         public FrmProducts(){
              initializeComponents();
         public  void DisplayForm(){
              java.awt.EventQueue.invokeLater(new Runnable(){
                   public void run(){
         private void initializeComponents(){
              setTitle( "Products administration" );
              setSize( 900, 550 );
              setBackground( Color.gray );
              JPanel topPanel = new JPanel();
              topPanel.setLayout( new BorderLayout() );
              getContentPane().add( topPanel );
              Toolkit kit = getToolkit();
              Dimension screenSize = kit.getScreenSize();
              int screenWidth = screenSize.width;                         //all this is to get
              int screenHeight = screenSize.height;                    //the form size and
              Dimension windowSize = getSize();                       //centre the form on
              int windowWidth = windowSize.width;                         //the screen
              int windowHeight = windowSize.height;
              int upperLeftX = (screenWidth - windowWidth)/2;
              int upperLeftY = (screenHeight - windowHeight)/2;
              setLocation(upperLeftX, upperLeftY);
              setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              // Create the tab pages
              createPage1();
              createPage2();
              createPage3();
              // Create a tabbed pane
              tabbedPane = new JTabbedPane();
              tabbedPane.addTab( "Facors", factorsTab );
              tabbedPane.addTab( "Products List", productListTab );
              tabbedPane.addTab( "Rate History", rateHistoryTab );
              topPanel.add( tabbedPane, BorderLayout.CENTER );
              setVisible(true);
         public void createPage1()
              factorsTab = new JPanel();
              factorsTab.setLayout( new GridLayout(2,1) );
              JPanel forexFactorsPanel;          //set up a frame with the forex factors details
              forexFactorsPanel = new JPanel();
              forexFactorsPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Forex factors"),
                BorderFactory.createEmptyBorder(5,5,5,5)));
              String forexFactorsColumns[]={"Factor","ZAR","US$"};
              String dummyValues1[][]={ {"Costing exchange rate","485.00",   "3400.00"},
                                          {"Local product exchange rate","430.00","3000.00"},
                                          {"Duty exchange rate1","35.30",          "250.00"},
                                          {"Duty exchange rate2","35.30",          "250.00"}};
              forexFactorsTable=new JTable(dummyValues1,forexFactorsColumns);
              JScrollPane scrollPane1=new JScrollPane(forexFactorsTable);
              forexFactorsPanel.add( scrollPane1, BorderLayout.CENTER );
              factorsTab.add(forexFactorsPanel);
              JPanel otherFactorsPanel;
              otherFactorsPanel=new JPanel();
              otherFactorsPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Other factors"),
                     BorderFactory.createEmptyBorder(5,5,5,5)));
              String otherFactorsColumns[]={"Description","Value"};
              String dummyValues2[][]={{"Landing Factor",                         "1.16"},
                                            {"Duty factor",                        "1.065"},
                                            {"Loading for overseas sourcing",  "1.15"},
                                            {"Extra mark up local",             "0.0"},
                                            {"Extra mark up imports",          "0.0"}};
              otherFactorsTable=new JTable(dummyValues2,otherFactorsColumns);
              JScrollPane scrollPane2=new JScrollPane(otherFactorsTable);
              otherFactorsPanel.add(scrollPane2, BorderLayout.CENTER);
              factorsTab.add(otherFactorsPanel);
         public void createPage2()
              productListTab = new JPanel();
              productListTab.setLayout( new BorderLayout() );
              String productListColumns[]={"Code1","Code2","Code3","Sales Category","Product code","Short Description",
                                             "Long Description","Supplier/Manufacturer","Supplier Product code",
                                             "Units","Master stockist","Lead time","re-Order level","economic order qty",
                                             "APR","min shipping qty"};
              String sampleValues[][]={
                     {"AI","AC","CE","Switchgear inc Starters","AIACCE 270","Timer int pulse start 230v 2C/O 30mins",
                       "Timer interval pulse start 230v 2 closed open 30 minutes","AC/DC South Africa","IAP2 30M","each",
                       "Central Stores","2","500","5000","APR","5000"},
                       {"GI","IN","ZZ","Alternative power and accessories","GIINZZ 174","INV HT SERIES 2500W 12v/230v MOD SWV",
                            "INVERTER HT SERIES 2500W 12v/230v MODIFIED SINEWAVE","SINETECH","HT-P-2500-12","each",
                            "Central Stores","6","1000","5000","APR","10000"}
              productListTable=new JTable(sampleValues,productListColumns);
              JScrollPane scrollPane3=new JScrollPane(productListTable);
              productListTab.add(scrollPane3, BorderLayout.CENTER);
         public void createPage3()
              rateHistoryTab = new JPanel();
              rateHistoryTab.setLayout( new GridLayout( 3, 2 ) );
    }This class is called by invoking the DispalyForm() function from a main form. May you please run it and see how the 'factors' panel needs correcting and help me do that

    wondering if there's a method that can be used to show a window(i.e. dialog) within a frame (much like an MDI form). That is, all windows are shown w/in the frame's border or title bar.
    Here's what I have attempted but to no avail:
    java.awt.Dimension screen = getDefaultToolkit.getScreenSize();
    java.awt.Insets frameInsets = this.getInsets();  // frame's insets
    // set bounds of child (window)
    window1.setbounds(frameInsets.top, frameInsets.top,
       screen.width - frameInsets.top -2, screen.height - frameInsets.top -2);any help is appreciated

  • HT1766 help i was following the steps for backing up my iphone and all of a sudden my iphone is dead and showing only a cord to connect to computer and the word itunes...what happened and how can I restore it?

    help i was following steps for backing  up my iphone and all of a sudden it went blck and then and now just shows a computer plug in with the words istunes....what happened and how do i restore my phone?

    As explained here
    http://support.apple.com/kb/HT1808?viewlocale=en_US

  • Is there a fix for downloading LDS scriptures, I downloaded it and the words are jumbled and illegible, thanks

    I attempted to download the LDS Scriptures to a IPOD touch 3rd generation and when the download was complete
    the words were jumbled and not legible,

    Have you tried here:
    iOS: Troubleshooting applications purchased from the App Store

  • TS1702 chat heads not working on the facebook app and whenever I log out of it the layout changes and the bar goes to the bottom

    I updated the facebook app today and the chat heads are not working and also whenever the app crashes or I log out the layout completely changes and a bar appears at the bottom of the screen instead of the sidebar. This is really annoying.

    Voice Over Fix
    Settings > General > Accessibility > Voice Over > Off
    Or,
    Press the Home Button 3 Times
    Now...
    Reset your phone:
    Press the sleep/wake button & home button at the same time, keep pressing until you see the Apple logo, then release the buttons...
    The Basic Troubleshooting Steps are:
    Restart..  Reset..  Restore from Backup...  Restore as New...
    Restart / Reset
    http://support.apple.com/kb/ht1430
    Backing up, Updating and Restoring
    http://support.apple.com/kb/HT1414

  • Constantly changing image on iChat - and the word 'stamina' appears?

    I just moved my G4 to another room. Now when I iChat with a friend, he/she sees the word 'stamina' on my screen and then the image constantly changes - to a blue border, to the purple theater curtains etc etc.
    I am completely baffled. Can anyone tell me how to get iChat to work normally please?

    Hi Bronxal,
    1) I have a Graphics Pad which makes Writing in some apps easier.
    2) The Sig was written and then coloured and shadowed in Photoshop Elements 2
    3) further tweaks to remove any background artifacts and get it as shown.
    4) Uploaded to a site such as Flickr or PhotoBucket.
    5) HTML Code to post it here.
    The code is the Image tag <img src="URL of pic">
    7:47 PM Wednesday; January 17, 2007

  • I have been working and the word program does not respond how do i save changes before forcing

    I have been working a word document and now the program does not respond, can I save the changes before forcing to close the application?

    no

  • I have lost scroll bar on 1 website only since upgrade to version 19 and the words run off the page

    Only 1 website affected. Scrollbar is missing and words run off page. If I minimize the screen, then maximize, the site returns to normal. If I leave the page, refresh the page or click on a topic to read (it's a sports message board) I lose the scrollbar again until I minimize-maximize. I have disabled all add-ons 1 at a time and all together. That doesn't help. Any suggestions? Other Firefox users are apparently not having this problem on the same website.

    Are you running any add-ons that might change the appearance of the page, e.g., add-ons that block ads, Flash, scripts, etc.?
    Sometimes you notice glitches in Firefox related to graphics card driver incompatibilities. To rule that out, you could disable hardware graphics acceleration. You usually need to restart Firefox in order for this to take effect, so save all work first (e.g., mail you are composing, online documents you're editing, etc.).
    orange Firefox button ''or'' classic Tools menu > Options > Advanced
    On the "General" mini-tab, uncheck the box for "Use hardware acceleration when available"
    After restarting Firefox, do you notice any difference?

  • During diction, is there any way to differentiate between the number "2" and the word "to ?

    :

    Well, what you have just been witness to is the lack of A.I.  Without AI, a computer cannot properly comprehend certain convesational criteria.
    Humans and other animals do not take actions or words at basic face value.  They apply learned data from past experiences to better match the context of the actions or words presented to them.  Once their brain settles on a % of correctness, it spits out a response value for it.  Computers don't currently do that... at least not yet and those that have wannabe AI logic on them still have a hard time making the right decision.  For the most part, they go with face value based on programmed parameters that are always applied the same way.
    It's like the thermostat in your house.  It's been told that if it's below a certain temp it needs to kick the heater in, if it's above a certain temp, it needs to kick in the AC.  But, if the temp is below a certain value and you just happen to have a sweater on which is keeping you warm, the termostat won't know that it's OK for it not to turn the heat on to warm you up.  It's a crude example, but you get the idea.

Maybe you are looking for

  • Problem writing a sql query for a select list based on a static LOV

    Hi, I have the following table... VALIDATIONS ID          Number     (PK) APP_ID          Number      REQUESTED     Date           APPROVED     Date           VALID_TIL     Date DEPT_ID          Number     (FK) I have a search form with the following

  • ATT online account is not showing data details

    Hello Everyone, I just bought the iPhone and signed up with ATT a week ago. On the online account summary, they show all my voice plan details but when I click on "Data Usage", they don't show anything and display a message that data-usage informatio

  • Where are my missing artists?

    I was going to ask which files I need to back up to avoid having to rip my CD collection for a second time (it took me three months). Had a quick browse in the Finder and Found (ha!) that there's a very limited number of artists in Music>iTunes>iTune

  • How to open Oracle 11.2.0.4 datafile in 11.2.0.3 binary?

    Hi: we are doing Oracle upgrade for our client from 11.2.0.3 to 11.2.0.4.  The client has a request, that after upgrade (database open to user access and new data will be entered by users during that time), they want to switch back to old version of

  • Standard Purchase organization

    I am unable to assign std purchase organization to plant.(Testing server SAP 4.7) Fields are grey out even after clicking the pencil. Lots of threads remain unclosed regarding this. Awaiting for your replies...