New starter layouts flow and border

Hi
I am teaching my self Java so I expect this is a simple mistake
set-up a class extending a JFrame
set-up a JPanel with a flow layout
added 5 checks boxes
this worked as I expected with the check box's moving down to the next line
I then changed the code so as to implement my first jpanel as the east panel in a Border layout. This runs ok only the check box's do not move down to the next line.
First question
have I comply misunderstood the section of the book and is it not allowed to put a panel with one layout type in side a panel?
Or
have I made a coding mistake and if so where?
This is my code.
import javax.swing.*;
import java.awt.*;
//THIS IS THE CLASS FOR THE HOLE PROGRAM
public class flowTest extends JFrame implements KeyListener {
public flowTest() {
super("Jeremys Demo");                     // THIS IS THE TITLE OF THE WINDOW
setSize(200, 200);                     //THIS IS THE SIZE OF THE WINDOW
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     // ACTION FOR THE EXIT x
setVisible(true);                         // MAKE THE WINDOW VISIBLE
JPanel master = new JPanel();
BorderLayout m1 = new BorderLayout();
master.setLayout(m1);
JPanel east = new JPanel();
FlowLayout flo4 = new FlowLayout();
east.setLayout(flo4);
//PANNEL EAST
JCheckBox oneStar = new JCheckBox("One Star", true);
JCheckBox twoStar = new JCheckBox("Two Star");
JCheckBox threeStar = new JCheckBox("Three Star");
JCheckBox fourStar = new JCheckBox("Four Star");
JCheckBox fiveStar = new JCheckBox("Five Star");
ButtonGroup rating = new ButtonGroup();
rating.add(oneStar);
rating.add(twoStar);
rating.add(threeStar);
rating.add(fourStar);
rating.add(fiveStar);
east.add(oneStar);
east.add(twoStar);
east.add(threeStar);
east.add(fourStar);
east.add(fiveStar);
master.add(east, BorderLayout.EAST);
// puts it all in to the main window
setContentPane(master);
// THIS IS THE START POINT
public static void main(String[] arguments) {
flowTest W1 = new flowTest();
}

Stern wrote:
FlowLayout is not designed for this, use GridLayout instead.Agree strongly. Also, you could simplify your code by using arrays. For example:
compare this:
        // PANNEL EAST
        String[] cbLabels =
            "One Star", "Two Star", "Three Star",
            "Four Star", "Five Star"
        ButtonGroup rating = new ButtonGroup();
        for (int i = 0; i < cbLabels.length; i++)
            JCheckBox cb = new JCheckBox(cbLabels);
rating.add(cb);
east.add(cb);
if (i == 0)
cb.setSelected(true);
with your code. Now see which is easier to add a "Six Star" rating?

Similar Messages

  • Need best procedure for adding new start-up disc and keeping all original data.

    We are adding a new (bigger)SATA drive to our 8-core Xeon Mac Pro and would like to clone the original startup disk to the new drive and use it to boot from.
    If you know of the best and surefire way to do this and not have any permission issues or any issues please advise.
    Thank you in advance.

    A. Carbon Copy Cloner
    B. use the big drives for media folders, libraries, data
    C. use smaller fast drive for system - $110 will buy a 1TB WD Black or Samsung 830 SSD, $150 will buy a 10K 250GB VR
    How to clone your system:
    http://macperformanceguide.com/Mac-HowToClone-backup.html
    http://macperformanceguide.com/Mac-HowToClone.html
    http://www.macupdate.com/app/mac/7032/carbon-copy-cloner
    Maybe you want to move all your sub-folders in your account to another drive - the new 2-4TB model (enterprise, not green)

  • Installing Photoshop on a new start up disk.

    I recently purchased a new SSD drive that I want to use as my new start up disk and install Photoshop CS6.
    Do I just deactivate Photoshop and uninstall it from my old drive and reinstall it on my new SSD or is there something else I need to do?

    deactivate (help>deactivate), then uninstall.  then reinstall on your new c drive.

  • LR Print Layout Request -- A New Start

    After some discussion on another thread, here is a new start, trying to detail my request to improve the layout functions in the Lightroom Print Module. These requests are for common layout requirements for those of us who do other printing than single page Fine Arts prints. The current layout functions in LR are essentially limited to Fine Arts and Contact Print functions. The requests below are for the rest of us.
    Please note that these requests are only about LR Print Module LAYOUT functions. Requests about soft proofing, output sharpening, etc. should be handled in another thread.
    Request that print layout functions include the ability to:
    1. Precisely place multiple cells of different size and orientation on a page.
    2. Automatically place as many images as possible of a given size on a page, making the image orientation as necessary. For example, three 4 x 6 prints on a single 8.5" x 11" page. Wedding shots, for example.
    3. Allow creation and saving a job of multiple pages with the ability to have different page layouts on each page. For example, a twelve page monthly calendar where some pages may have a single landscape image with no caption. Some may have a single landscape image with caption. Some pages may have two portrait images with or without captions, and some pages may have all of the above.
    Consider that on a landscape page, there could be two portrait prints with a single landscape caption below and spanning both portrait images.
    Another example to show the need for this is when making a Photo Book. Most often, each page will have different layout requirements.
    It should be possible to save and recall both the entire job with images and just the layout alone. Maybe a Print Job Collection and a "Print Layout Collection."
    With the implementation of 1. above, a separate caption option isnt necessary since it can be created as desired as a separate cell with text created in Photoshop or some other application.
    4. Be able to create a template for a page(s) and place selected images in selected cells. For example create a template for a greeting or note card that will be folded after printing. The portrait page template could have two cells. The outside page could have an image in the bottom cell only, and the inside page could have images in both cells, or any combination of the above. The point being that an empty cell should be possible.
    5. Be able to replace or remove any image from any cell on any page when desired. That is, be able to add, remove, or replace an image in a particular cell without changing the remaining layout.
    6. Be able to insert or remove an image from a page and have the entire layout change accordingly. For example, I just found the perfect sunset to insert after the thunder storm. This is the inverse of 5.
    7. Provide trim marks for page cuts when a final page is smaller than physical page. This situation has just come up in Christmas cards that will be 7-7/8" x 10-1/2", printed on 8.5" x 11" paper. By the way, I dont know of any other application that can do this.
    These are all some detailed request to implement the general request to be able to place any image in any orientation anywhere on a page.
    Wil

    And I would add that the form of this regquest is just about perfect...about the only thing missing is the "why would you want to do that" part with potential examples of how you would use certain aspects of the request to do certain commonly needed tasks.
    For example on #2, are you asking for the ability to maizimize the number of images up on a sheet to make prints more efficiently? Would you also want margins and trim lines? (personally, I would as an option).
    #3 has a good example for the suggestion/request. But another example of use would be to be able to print off custom brochures either for the photographer (self promotion) or as a service to the client.
    You say you want the ability to swap images in an array (I do too). Would you want to do this by drag & drop (say yes please)?
    This is much better...
    :~)

  • Hi, I don't know who to turn to: the person who handles all the compter stuff is out of town, This A.M.I started up Firefox and there was a message re an update, I thoght I new just to click on install and wait to re start Firefox. But what I can remember

    Hi, I don't know who to turn to: the person who handles all the compter stuff is out of town, This A.M.I started up Firefox and there was a message re an update, I thoght I new just to click on install and wait to re start Firefox. But what I can remember is that another window opened and asked me to choose 'something' (an icon or banner or?), I thought I must click something (I guess I should read all clearly). Firefox did update to 3.6.4, but it also inserted some sort of what might be called a banner? But it only partly covers the right one- half of my 3 toolbars at the top of the Firefox window. It can't be used for anything as it is just a mess of colors and unknowns, except what looks like a 'top' and what I recognize as a Firefox icon (but only partly visible)!! Now, what it does do is partly hide that whole portion of the toolbars and they are hard to read and in turn make this 'thing' impossible to figure out, if I would care to? I can't find anyway to remove it or use it?? But since the Firefox icon is on it, I guess you should know what it is and how to trash it. I am sorry for this occurrence caused my my carelessness, but I'm not much of a computer person ----HELP! Thank you for any help. Judi
    == This happened ==
    Every time Firefox opened
    == Today, Thrsday June 24, 2010

    The only thing I can imagine: it's a [https://addons.mozilla.org/en-US/firefox/personas/ Persona].
    Tools->Add-ons->Themes
    Here should be the persona (lightweight theme)
    and a button "Remove"
    Click it (button Remove), and it (Persona, this mix of colors) should go away instantly.
    Does it help you?

  • I Try to open an Indesign document. The message: it is made in a newer version. Go tot CC: Help/Give your Adobe id/Start Indesign again and try to open the document. This doesn't work. How to solve this problem?

    I Try to open an Indesign document. The message: it is made in a newer version. Go tot CC: Help/Give your Adobe id/Start Indesign again and try to open the document. This doesn’t work. How to solve this problem?

    What version are you running?
    What version was it made with?

  • Premiere elements 12, new installation, serial no. accepted, installation completed and new started, but does not run. I get following msg-box: "LoadLibrary failed with error 126: Das angegebene Modul wurde nicht gefunden."

    premiere elements 12, new installation, serial no. accepted, installation completed and new started, but does not run. I get following msg-box: "LoadLibrary failed with error 126: Das angegebene Modul wurde nicht gefunden."   Installation in German Language on WIN7 professional 64bit, Samsung SSD. What can I do to run that program?

    Jurgen Freund
    Premiere Elements 12 on Window 7 64 bit. What video card/graphics card does your computer use - AMD Radeon?
    I have found this YouTube video on the subject of Error 126 with details for resolving the problem.
    How to fix the ERROR 126 when you open OpenGL programs - YouTube
    The link was contributed in an old 2013 thread here by the ID danneomarre (see post 6 of the following thread)
    LoadLibrary failed with error 126: cant find the required
    Please let us know if that worked for you.
    Thank you.
    ATR
    Add On...When all is OK and working, please update 12 to 12.1 Update using an opened project's Help Menu/Update.

  • I am having sporadic issues after new hard drive install and recovery using Time Machine. The same sluggish response, start up screen pixelating...If I reinstall Lion will it wipe out other applications? My HD was formatted and partitioned correctly, I ha

    I am having sporadic issues after new hard drive install and recovery using Time Machine. The same sluggish response, start up screen pixelating...If I reinstall Lion will it wipe out other applications? My HD was formatted and partitioned correctly, I have a late 2009 iMac.

    Use the trackpad to scroll, thats what it was designed for. The scroll bars automatically disappear when not being used and will appear if you scroll up or down using the trackpad.
    This is a user-to-user forum and most people will post on here if they have problems. You very rarely get people posting to say there update went smooth. The fact is the vast majority of Mountain Lion users will not be experiencing any major problems with the OS, or maybe with apps which are not compatible, but thats hardly Apple's fault if developers don't update their apps.

  • I got a new iPad last month and set up through iCloud. Still have a message on my screen that it is still restoring from iCloud. How do I get it to complete other than having to rest me start again?

    I Got a new iPad last month and sent up in the usually way and syncd to iCloud. However it has ever since shown a comment saying:
    Restoring from from I cloud backup
    i I have no idea how to get it to complete. Or do I need to re-set and start again?
    Help!

    Where do you see this message? I know it can take a few hours to restore from an iCloud backup if you had lots of apps, data, movies, camera roll photos etc on it, but it should not take days and daus to finish.
    Have you restarted or reset your iPad since you got it? Not the reset that you are talking about - I mean the system reset. Try either or both and see if the message goes away.
    Restart or reset your iPhone, iPad, or iPod touch - Apple Support

  • How can I move (copy) my Time Capsule date to a new 2T hard drive and then wipe the TC and start as a new (clean) Time MACHINE backup?

    How can I move (copy) my Time Capsule date to a new 2T hard drive and then wipe the TC and start as a new (clean) Time MACHINE backup?

    Just use the archive utility on the disk page of the airport utility manual setup..
    If you have lion and v6 airport utility.. it missed out. On lots of things.
    Download and install the real.. UTILITY
    5.6 http://support.apple.com/kb/DL1482

  • My older mac book pro and iMac are both running 10.6.8 and both have started running safari and email VERY slowly.  My new mac book pro running 10.9 is having no issues.  Is anyone else experiencing these issues?

    My older mac book pro and iMac are both running 10.6.8 and both have started running safari and email VERY slowly.  My new mac book pro running 10.9 is having no issues.  Is anyone else experiencing these issues?

    No noticeable speed differences running the four latest OSs on my machine.

  • I'm new to Photoshop Elements and just getting started.  While in the organizer I have one group of photos up to learn with and now it says Edit in Progress with a padlock icon.  How can I remove this so that the photos will be restored to normal?

    I'm new to Photoshop Elements and just getting started.  While in the organizer I have one group of photos up to learn with and now it says Edit in Progress with a padlock icon.  How can I remove this so that the photos will be restored to normal?

    Go back to the editor and close the photo there.

  • I just started using a new version of Illustrator and the text I am creating has a pink box behind, looks to be about the depth of the normal linespace, it is not visible in outline view, only in preview. What is it and how do I get rid of it?

    I just started using a new version of Illustrator and the text I am creating has a pink box behind, looks to be about the depth of the normal linespace, it is not visible in outline view, only in preview. What is it and how do I get rid of it?

    Hi Larry. I see. It is a file I have worked on previously, and the font is Myriad which I though came with the system. I just changed to Myriad Pro and the pink box disappeared. Thanks for the assistance, I know a new thing!

  • I have the new version of iMovie, and when i try to start the program, i can't because it says that it is looking for some movie files from the Iphoto, so all the program is locked up... how can i do to restart the program??

    i have the new version of iMovie, and when i try to start the program, i can't because it says that it is looking for some movie files from the Iphoto, so all the program is locked up... how can i do to restart the program??

    Hi
    Did You ever use - iPhoto ?
    Did You may be direct iPhoto to a different Photo Library
    As iMovie tries to find the appropriate photo library - it can get lost if iPhoto direct it into a Library on a not connected external hard disk or to a strange location - And iMovie HANGS.
    Do - When no other program is running that might interfere
    • Start iPhoto - BUT NOW KEEP alt-key (option key) DOWN during the full Start-Up process
    • Now iPhoto let's You select Photo Library
    • Select the one in Your Account / Home folder / Pictures ! !
    • Then iPhoto should start up OK
    • Now Quit iPhoto
    • START iMovie
    Does it still hangs - then I would suspect - iMovie Pref. file
    If it Run's OK - Then HURRAY !
    Yours Bengt W

  • In Dreamweaver 6, I created a new fluid layout. I set up (4) DIVs. In the 3rd div, I changed the font color. The new color shows up on the website when viewed in my computer desktop, but, when viewed in a tablet and a cell phone, the color of the font doe

    In Dreamweaver 6, I created a new fluid layout. I set up (4) DIVs. In the 3rd div, I changed the font color. The new color shows up on the website when viewed in my computer desktop, but, when viewed in a tablet and a cell phone, the color of the font does not change. It's the same in Dreamweaver's Live view. It shows the new color on Desktop view and not in the cell phone or tablet view. Also, I changed the font itself in one of the DIVs and it shows up in the new font on the desktop view and website viewed thru the computer, but, not on the tablet or cell phone. Can someone please explain. I want to be able to change the fonts and colors for viewing in the tablet and cell phone, also. The fonts were all standard fonts. Sans-erif and Verdana and Arial were tried. Thanks.

    I will lock this discussion because of duplicate post.

Maybe you are looking for