How do i put an array of panels into a frame with a flow layout?

I just want to have my array of Jpanels displayed in a Jframe with a flow layout, how do i do this?
thanks

saru88 wrote:
The problem is:
cards.setBackground(Color.red);
No, the real problem was before that. I saw SD before the stack trace in your original code, but the code 'ignored' that and continued on to the second exception you saw.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MemoryFrame extends JFrame{
     private CardPanel[] cards;
     final int noCards = 24;
     public MemoryFrame(){
          setTitle("Apple");
          Toolkit tk = Toolkit.getDefaultToolkit();
          int screenWidth = tk.getScreenSize().width;
          int screenHeight = tk.getScreenSize().height;
          int halfWidth = screenWidth/2;
          int halfHeight = screenHeight/2;
          setBounds(halfWidth/2,halfHeight/2,halfWidth-45, halfHeight+50);
          Container c = getContentPane();
          c.setLayout(new FlowLayout());
          addWindowListener(new WindowAdapter () {
               public void windowClosing(WindowEvent e) {
                    System.exit(0);
          // this creates an array for 10 CardPanels, but they all start out as 'null'
          cards = new CardPanel[noCards];
          for(int i=0; i<noCards; i++){
               try{
                    // this creates each individual CardPanel
                    cards[i] = new CardPanel();
                    cards.setBackground(Color.red);
                    // if there is an exception, it is pointless continuing
                    c.add(cards[i]);     
               }catch(Exception e){
                    System.out.println("SD");
                    e.printStackTrace();
     public static void main(String[] args) {
          // very hackish
          new MemoryFrame().setVisible(true);
class CardPanel extends JPanel {

Similar Messages

  • How do I put 2 or more pictures into one frame?

    Please help.

    Hi
    No not in iMovie'13 (vers. 10.0.x)
    You have the Picture in Picture function - but it is limited and can not do 2 half frames.
    You need to create this outside iMovie'13 (vers. 10.0.x)
    - QuickTime Pro - Can do it (but it costs $20 about and is a very tedious task)
    - FinalCut Pro-X - Can do it (but cost is $300 - and a bit of learning - but easier than QT-P)
    Free alternative: I know of NO ONE - anybody ?
    Yours Bengt W

  • How do I put all my live feeds into one channel? I don't want to have to cick on each feed source separately.

    How do I put all my live feeds into one channel? I don't want to have to click on each feed source separately. Instead of one feed per website I want just ONE feed for all my sources together.

    Hi there old45,
    You may find the information in the article below helpful.
    iTunes 11 for Windows: Change where your iTunes files are stored
    http://support.apple.com/kb/PH12365
    Consolidate your files in the iTunes folder
    You can consolidate all the files in your library in the iTunes folder—for example, to make it easier to move your library to a new computer.
    Choose File > Library > Organize Library.
    Select “Consolidate files.”Files remain in their original locations, and copies are placed in the iTunes folder.
    To create folders (Music, Movies, TV Shows, Podcasts, Audiobooks, and so on) inside your iTunes folder, and place all your imported media files in the appropriate folders, select “Reorganize files in the folder ‘iTunes Media.’”
    Locate your iTunes files
    Do either of the following:
    Find out where a file is stored: Select the item in iTunes, and choose File > Get Info. The path to the file is shown at the bottom of the Summary pane (next to Where).
    Show the file in Windows Explorer: Select the song, and choose File > Show in Explorer.
    -Griff W.

  • How do I put a group of tracks into one album

    How do I put a group of songs into one album?  They copied separately into iTunes.

    Generally, in iTunes, all you need to do is fill in an appropriate Album Artist to keep things together. For older iPods each track from the same album should have the same artist, or be marked as a compilation where appropriate. On iOS devices you may need to go to Settings > Music > Group By Album Artist > On. For more details see my article on Grouping Tracks Into Albums, in particular the topic One album, too many covers.
    tt2

  • HT4847 How do I put my iPhone stored items into my iCloud storage?i have bought an upgrade but none of my phones stored items have moved to iCloud.i can't download new update from apple. due to not enough and yet iCloud space is empty??please help thanks

    How do I put my iPhone stored items into my iCloud storage?i have bought an upgrade but none of my phones stored items have moved to iCloud.i can't download new update from apple. due to not enough and yet iCloud space is empty??please help I don't know what I doing all I know is my phone is iPhone 4 and I can't update it. My phone on contract with t-mobile . Thanks

    You can't have content in iCloud without having it on your phone, you will need to look at deleting items from your device that you don't need. Movies and TV shows from iTunes are possibly a good start because they tend to be large and can be redownloaded at a later date.

  • Hi... I am looking for an inexpensive app for my macbook pro that I can put pictures and videos together into a slideshow with captions and music WITHOUT a watermark and that also will burn the slideshow to a DVD in its own app. Help?

    Hi... I am looking for an inexpensive app for my macbook pro that I can put pictures and videos together into a slideshow with captions and music WITHOUT a watermark and that also will burn the slideshow to a DVD in its own app. Help?

    The issue with the A1400 is that like most economy compact cameras, they will not have very fast focus times in indoor lighting situations. Many people have gone to entry level DSLR's (Canon T3i) or micro 4/3 cameras. They are fairly expensive, but a late model refurbished T3i can sometimes be found with a kit lens for about $300.00. With Auto and scene modes, as well as full manual modes, these are very versatile cameras that focus very quickly, even in lower lighting situations. Canon is not really into the micro 4/3 cameras, instead they are focusing on the new G7x and G1x cameras, which are way out of your price range. The A720 is still available used at some places such as KEH camera, but you'll need to check often as their stock changes constantly. Obviously the DSLR's don't use AA batteries, but the T3i is good for about 600 photos (or more) per charge.
    My refurbished DSLR was practically brand new condition when I got it. I could not find any sign of wear at all, so I feel they are a real bargain. These are rugged cameras that are made to last. The A1400 is a $99.00 camera, so it's not intended for heavy usage, plus the image quality of a DSLR (even entry level) is far better than the A1400. That would be my recommendation.
    Steve M.

  • How can I access a thumb drive plugged into an airport with my iPad?

    how can I access a thumb drive plugged into an airport with my iPad? I am trying to set up an information point to serve weekly info over a NOT connected to the internet airport.

    You can't. There are a couple of devices such as AirStash and the GoFlex drive that you can access over WiFi. They are limited, as I understand it, though.

  • (HELP!)How can I import Windows Media Player Playlists, into iTunes Playlists, with Music . .  for an iPod

    How can I import Windows Media Player Playlists, into iTunes Playlists, with Music . .  for an iPod
    We are having no luck with the thousands of songs we have to manualy add to a particular playlist in iTunes alone. .. there must be a simpler way! How can this be done . . . if there is and it's complicated, is the Genius allowed to help us out with this? They seem to only master Mac's only. .  or can they help us? PL E A SE E E  HELLPPP!

    tt2,
    Your very helpful and knowledgeable. I for one appreciate all the hardwork and help you have been giving the people on theses lists, especially with the problems associated with the "importing playlists" from windows media. Unfortunately I need more help if you or someone else can provide it. I followed all the steps you have instructed so far in the threads I have seen. Unfortunately nothing so far works for me. Maybe you or someone can help me, I'd really appreciate it. I tried the notepad++ method and when I click on save I always get a notepad file that my iTunes can't do anything with. I click the "convert to UTF-8 without BOM" then click save as and it still saves as a notepad file. I am also unable to find the \n\ file path to replace with my \C:\ filepath. Here is a copy of the first part of one of my playlists:
    <?wpl version="1.0"?>
    <smil>
        <head>
            <meta name="Generator" content="Microsoft Windows Media Player -- 12.0.7601.17514"/>
            <meta name="ItemCount" content="161"/>
            <author/>
            <title>Power Surge</title>
        </head>
        <body>
            <seq>
                <media src="..\Various Artists\Mixed Tape 2\13 Out of Control.wma" tid="{650561AF-AA9D-4EA3-84CC-2F09C24DF3B3}"/>
                <media src="..\Various Artists\Mixed Tape 1\12 One Step Closer.wma" tid="{EE5ADD9D-A879-404A-BC60-CE841045BCB6}"/>
                <media src="..\Various Artists\Mixed Tape 1\15 Click Click Boom.wma" tid="{0F71941C-1B67-425F-BDAA-246618709179}"/>
    Now I went and switched the part from  <media src="..\ to <media src="C:\ in all the files in hopes that was where I am supposed to have my drive letter but it didn't seem to help. Please forgive my encoding ignorance if that's what my problem is. I hope you can help.  Thanks in advance.
    Madmaxneo

  • How can I convert an array off byte into an Object ?

    Hi folks...
    I�m developing an application that comunicates a PDA and a computer via Wi-Fi. I�m using a DataStream ( Input and Output ) to receive / send information from / to the computer. Most off the data received from him is in the byte[] type...
    How can I convert an array off byte ( byte[] ) into an Object using MIDP 2.0 / CLDC 1.1 ?
    I found on the web 2 functions that made this... but it uses a ObjectOutputStream and ObjectInputStream classes that is not provided by the J2ME plataform...
    How can I do this ?
    Waiting answers
    Rodrigo Kerkhoff

    There are no ObjectOutputStream and ObjectInputStream classes in CLDC. You must know what you are writing to and reading from the DataStream. You should write the primitives like int, String to the DataOutputstream at one end and read those in exactly the same sequence at the outher end using readInt(), readUTF() methods.

  • How do I put parts of multiple songs into one song?

    I'm trying to make a mix of songs for my friends party and I was wondering how I could put parts of multiple songs together into one soundfile? If iTunes can't do this are their any other softwares that could do this? Thanks, appreciate it.

    Prosper,
    That is beyond the ability of iTunes, and requires the use of an audio editor.
    A free one that many people like is Audacity.
    After you do the editing in Audacity, you can export an MP3 and add it in to your iTunes library.  The original files remain unchanged.

  • How can I put my iPod's songs into my pc?

    Hi!I bought my iPod in November and this week I putted all the music which was in my PC into my iPop, and there is a thing I don't understand: how can I do to put my iPod's music into my PC? I'll be really pleased if you asnwer my question!bye

    1. Double-click on the My Computer icon on the Desktop.
    2. Locate your iPod in the window that appears and select it.
    3. Choose Folder Options from the Tools menu in the My Computer window.
    4. Click the View tab in the Folder Options window that appears.
    5. Look for the Hidden Files and Folders entry. Below this entry enable the Show Hidden Files and Folders option and click Apply to reveal the hidden files.
    6. Dismiss the Folder Options windows by clicking the OK button.
    7. Double-click the iPod’s icon in the My Computer window.
    8. Move to the Finder and double-click on the iPod’s icon on the Desktop.
    You’ll discover that several more items now appear in the iPod window. Among them is a folder called iPod_Control.
    9. Double-click the iPod_Control folder.
    Inside the iPod_Control folder you’ll find the Device, iTunes, and Music folders along with the iPodPrefs file.
    10. Drag the Music folder to your Mac’s Desktop to copy it to your computer.
    As the name implies, this is where music is stored on the iPod.
    11. Return to iTunes and drag the Music folder you just copied to iTunes’ main window.
    The songs you copied from the iPod will be added to iTunes. If you’re a tidy type, before copying those files to iTunes, open iTunes’ preferences, click the Advanced tab, and make sure the Keep iTunes Music Folder Organized and Copy File to iTunes Music Folder When Adding to Library options are enabled. Enabling these options will organize your iTunes library in the way iTunes prefers.

  • HT1386 I do not have internet on my home computer, how can I put my pics and music into iTunes so I don't lose them all.

    How can I put my photos and music in iTunes so I don't lose them if something happens to my phone

    You don't need an internet connection to sync the phone with iTunes- cable or WiFi

  • I've got my email folders showing but how can i put back my email messages into the folders from time machine

    my mac has been restored & i can see my email folders but how do i put back the saved emails from my time macine i can locate n see them but cant restore them

    Csound1 wrote:
    Into one of the domain accounts, or a specific mailbox in a domain account, that's your choice but:
    Remember that you are moving mail over the internet, and you are uploading (slower). If the quantities are large you must use caution.
    1. Copy, don't move, in the event of a failure the original will still exist, delete it later.
    2. Limit copies to <500 emails
    3. Single copy operations are more reliable than multiple.
    Take your time.
    Thanks, but impractical. Many of the folders have more than 500 emails. Total is about 2 GB (which I have free on iCloud btw)
    I tried creating a folder "Archive" in my iCloud, then tried dragging one iMac folder into the new "iCloud > Archive" folder on my iMac. I got the error message:
         Some items could not be created:
         The IMAP command “CREATE” failed with server error: Invalid mailbox name.

  • How can i put songs from my ipod into my itunes library?

    I want to sort out all mu music on my ipod and start fresh, but i want to keep all my music. Is there a way of putting music from my ipod into my iTunes library? I understand that if there is music on my ipod then i mustve put it on there from the library but i dont think i did! It's just not there! all i need to do is transfer it from my ipod to my itunes library Pls help. Ta.

    iTunes includes an option to transfer iTunes content that was purchased/downloaded from the iTunes store from an iPod, iPad, or iPhone, but this is for iTunes content that was purchased/downloaded from the iTunes store only.
    With your iPod connected, at the iTunes menu bar go to File and select Transfer Purchases From - the name of your iPod.
    If you had Sync Music selected under the Music tab for your iPod sync preferences with iTunes, after downloading a song from the iTunes store direct with your iPod, the song would be copied to your iTunes library automatically the first time you sync your iPod with iTunes after doing so.
    Manually managing music and videos is manual all the way.

  • How do I put and sort string data into an array?

    I have a txt file that has the following sample data:
    Sample.txt----
    Jones Bill 12,500 Salesperson
    Adams Frank 34,980 Manager
    Adams John 23,000 Salesperson
    Thompson Joe 59,500 Trainee
    I need to incorporate each line of data into an individual array element, while using a user-defined method
    (ex. setAllValues(String last, String first, String salary, String job)
    How do I loop the data into the array to be displayed and what is the best way to do sorts on this sample data. Any code or clues would be super helpful.
    Sanctos

    If you set up an array of Strings you can use the java.util.Arrays.sort() method to sort it. If you need to sort arbitrary Objects (i.e. your 3 strings as a whole entity) your 3-way object will have to either implement Comparable or you could write a Comparitor class to do the ordering. Not much to it, though.
    Dom.

Maybe you are looking for

  • MB5B report having discrepancies in stock

    Dear All, I have checked the stock balance using MB5B for date 07.04.2009. The system while executing the transaction gives a warning message saying u201CFI document summarization is active / the results may be incorrect But on 31.03.2009 in MB5B sto

  • Wifi packet loss after upgrading to 10.7.4

    After upgrading all three macs (mb pro, mb air, imac) in the house to 10.7.4 they all experience wifi packet loss.  I ping to the local router.  I have connected to a multitude of wireless routers with similar result. But here is strong evidence that

  • Unsupported Content-Type: text/html;charset=utf-8 Supported ones are: [text

    Hi I am in trouble with JAX-WS 2.1.2M1 I try to call my Webservice like this: Service service = Service.create(serviceName);         service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, "http://spblue.liberty:8084/SPBlue/GlobalLogoutService"); D

  • Date and time formatting not responding

    I'm trying to total a column based on a date or date window.  My formula looks like this. SUMIF(Date,B1,'$') I have 2 tables.  The table with the formula references the other table, and compares Date in table 1 to B1 in table 2.  B1 is a date I enter

  • Inbound interface found more than once for outbound interface

    Hello everybody, i have a simple problem. I build a interface with XI3.0 File to idoc for each file i need crate 2 idoc. It's not a problem when Idoc type is different, but in my case i need crate 2 idoc of same type but with a different mapping. so