A CardLayout problem--wrong parent for CardLayout

I am trying to use CardLayout so that only one of the several panels I crete will be display at a time. However, JBuilder gives me the "java.lang.IllegalArgumentException:wrong parent for CardLayout
"error. What's wrong?
package nestedlayouts;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
public class Frame1 extends JFrame implements ActionListener{
CardLayout cl = new CardLayout();
JPanel cardPanel = new JPanel(cl);
JPanel welcomePane;
JPanel balancePane;
JButton balanceButton = new JButton();
JButton welcomeButton = new JButton();
//Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
catch (Exception e) {
e.printStackTrace();
//Component initialization
private void jbInit() throws Exception {
Container content = getContentPane();
content.add(cardPanel );
welcomePane = new JPanel();
welcomePane.setLayout(null);
welcomeButton.setText("Welcome");
welcomeButton.setBounds(new Rectangle(90, 180, 196, 56));
welcomeButton.addActionListener(this);
welcomePane.setName("welcomePane");
cardPanel.add("welcomePane",welcomePane);
welcomePane.add(welcomeButton, null);
balanceButton.setText("ShowBalance");
balanceButton.setBounds(new Rectangle(154, 181, 196, 56));
balanceButton.addActionListener(this);
balancePane = new JPanel();
balancePane.setLayout(null);
balancePane.add(balanceButton, null);
balancePane.setName("balancePane");
cardPanel.add("balancePane",balancePane);
this.setSize(new Dimension(509, 333));
this.setTitle("ATM");
show();
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
public void actionPerformed(ActionEvent e) {
if ( ( (JButton) e.getSource()).getText().equals("ShowBalance")) {
showPanel(1);
else if ( ( (JButton) e.getSource()).getText().equals("Welcome")){
showPanel(2);
private void showPanel(int num) {
if (num == 2) {
cl.show(balancePane, "balancePane");
else if (num == 1){
}

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//import com.borland.jbcl.layout.*;
public class bigeyes extends JFrame implements ActionListener{
  CardLayout cl = new CardLayout();
  JPanel cardPanel = new JPanel(cl);
  JPanel welcomePane;
  JPanel balancePane;
  JButton balanceButton = new JButton();
  JButton welcomeButton = new JButton();
  //Construct the frame
  public bigeyes() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    catch (Exception e) {
      e.printStackTrace();
  //Component initialization
  private void jbInit() throws Exception {
    Container content = getContentPane();
    content.add(cardPanel );
    welcomePane = new JPanel();
    welcomePane.setLayout(null);
    welcomeButton.setText("Welcome");
    welcomeButton.setBounds(new Rectangle(90, 180, 196, 56));
    welcomeButton.addActionListener(this);
    welcomePane.setName("welcomePane");
    cardPanel.add("welcomePane",welcomePane);
    welcomePane.add(welcomeButton, null);
    balanceButton.setText("ShowBalance");
    balanceButton.setBounds(new Rectangle(154, 181, 196, 56));
    balanceButton.addActionListener(this);
    balancePane = new JPanel();
    balancePane.setLayout(null);
    balancePane.add(balanceButton, null);
    balancePane.setName("balancePane");
    cardPanel.add("balancePane",balancePane);
    this.setSize(new Dimension(509, 333));
    this.setTitle("ATM");
    show();
  //Overridden so we can exit when window is closed
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
  public void actionPerformed(ActionEvent e) {
    if ( ( (JButton) e.getSource()).getText().equals("ShowBalance")) {
      showPanel(1);
    else if ( ( (JButton) e.getSource()).getText().equals("Welcome")){
      showPanel(2);
  private void showPanel(int num) {
    if (num == 2) {
      // cardPanel is the parent, balancePane is the child (card)
      // that you added to the parent and now want to show
      // key: parent,     card name
      cl.show(cardPanel, "balancePane");  // error was pointing to this line
    else if (num == 1){
  public static void main(String[] args) {
    new bigeyes();
}

Similar Messages

  • Wrong Parent for CardLayout

    I have a frame class in which I have added one panel and inside that 3 frames.I want to see the frames depending upon each request,the panle is has CardLayout.When i create an instance of the this class in my main and try to show one of the cards it gives wrong parent for CardLayout error???

    You haven't called setLayout on the frame/panel (I'm confused as to your precise setup) to tell it to use the CardLayout.

  • IPhoto - My iPhoto is not responding. When I click on iPhoto I get a never ending spinning beachball.  I almost think it is looking in the wrong place for the pictures.  How do I redirect it back to the Mac hard drive?

    My iPhoto is not responding.  Whenever I click on the iPhoto icon I get a twirling beachball.  It is as if the machine is looking in the wrong place for the photos.  How can I see where the machine is looking to find out if this is really the problem.  How can I see the path?

    Try this:  launch iPhoto with the Option key held down and create a new, test library.  Import some photos and check to see if the same problem persists. If it doesn't then the problem lies with your current library.
    If that's the case  Apply the two fixes below in order as needed: 
    Fix #1
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
    Since only one option can be run at a time start with Option #3, followed by #4 and then #1 as needed.
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    1 - download iPhoto Library Manager and launch.
    2 - click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    3 - Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option.
    4 - In the next  window name the new library and select the location you want it to be placed.
    5 - Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments.  However, books, calendars, cards and slideshows will be lost. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    OT

  • Content Search Web Part displaying wrong Results for anonymous Users.

    HI Forum Group,
    I am getting Wrong results for my content search web part. The requirement is to show the News Description for the selected news item.
    I have a catalog site which stores News like 
    News1
    News2
    News3
    as Items. and i have connected this catalog in publishing site which is anonymous. In the publishing site created one page "News.aspx"added search results webpart which shows all the news item. Added one page "Description.aspx" to show
    description to show the selected news item.
    When ever user selects any news from news.aspx page it will redirected to description.aspx with the selected item ID
    The "Description.aspx" the search results page gets the data based on the URL by QueryString parameter as shown below
    The problem is, if i multiple items to open in tabs all the items are showing the data same as the first selected item, though the article ID is different.
    Thanks
    Sithender

    Hi,
    Thank you for your feedback on how you were successful in resolving this issue.
    Your solution will benefit many other users, and we really value having you as a Microsoft customer.
    Have a nice day!
    Best Regards,
    Lisa Chen
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • URL links wrongly created for adjucent characters

    The URL links are wrongly created for the following characters after the URL like “)”, “]” etc.
    For E.g. (www.adobe.com), the URL links for adobe is in active for closing parenthesis in PDF which should not have a URL link.
    Any one suggests what would be problem and how to avoid this?
    We are using Acrobat Pro 8.

    Use the Link Tool in Acrobat and create the link.

  • Messages received before september 4th are not more readable. However , not problem of reading for incoming messages for yesterday and today. How can I recover old messages ??ges dated

    Hi , All my incoming messages up to September 4th on one of my mail accounts are impossible to be read again !!  When I 'click" on any of the messages a blank window appears instead of the text..!!  However , all the incoming messages received yesterday and today are perfectly readable.
    How can I solve this problem ?
    Sorry for my poor English..Thanks in advance
    Francois

    Hi Francois, nothing wrong with your English at all!
    Not certain, but this can fix myriad Mail problems...
    Safe Boot from the HD, (holding Shift key down at bootup),  it will try to repair your Disk Directory while the spinning radian is happening, so let it go, run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, then move this folder & file to the Desktop.
    Move this Folder to the Desktop...
    /Users/YourUserName/Library/Caches/Mail/
    Move this file to the Desktop...
    /Users/YourUserName/Library/Mail/Envelope Index
    Reboot.
    If that doesn't do it and you can afford to redo all your Rules, try these & reboot...
    /Users/YourUserName/Library/Mail/MessageRules.plist
    /Users/YourUserName/Library/Mail/MessageRules.plist.backup

  • Business area wrongly posted for invoice

    Hi All,
    Business area wrongly posted for invoice.
    The user was posted the invoice with two line items one with posting key 40 for debit and one is 31 for credit vendor, these two line items are posted with different business areas.  and the the invoice is cleared also.
    Could any one please suggest what the above issue affects the business.  what would be the resolution to be done for this.
    Thanks in advance
    Nandha

    Hi All,
    The balances are not matching in fbl3n and fs10n, Due to the above wrong document posted and cleared also.  what is the better way to match the two balances (fbl3n and fs10n).
    Can i reverse the cleared wrong document and reset it in fbra,  if i do this is there any problems occur in production.
    please suggest to tally the balances of fbl3n and fs10n.
    one more thing if i double click on the fs10n the another screen will open in the the total balances are matching in fbl3n and fs10n.
    Please any suggest me to come out of this issue
    Thanks in advance
    Nandha

  • Calling GUI jar from C++ and setting parent for JDialog

    Hi,
    i am calling a GUI jar from in C++ code using ShellExecuteEx API as follows.
    l_sei->cbSize=sizeof(SHELLEXECUTEINFO);
              l_sei->fMask = SEE_MASK_NOCLOSEPROCESS;
              l_sei->hwnd =l_hwndFound;          
              l_sei->lpVerb = "open";
              l_sei->lpFile = "java";     
              l_sei->lpParameters ="test.jar";
              l_sei->lpDirectory = NULL;
              l_sei->nShow = SW_HIDE;
              l_sei->hInstApp = NULL;
              ShellExecuteEx(l_sei);This GUI opens up from the parent application .
    The problem i am facing is the jar runs as an independent application. I want to set application as the parent window for my GUI.
    The frame is a JDialog. Can i set a parent for a JDialog? So that doing Alt+Tab would not open the GUI on any window other than the parent application.
    thanks.

    Well, you can certainly set a parent for a JDialog (an owner, anyway, since it isn't a "parent" in the GUI hierarchy)... but that won't necessarily make the windows task switch together.
    Now, the real problem is that the "parent" needs to be a Java Dialog or Frame object in the same JRE as the dialog, and in order to get what OS-specific task switching features can be provided by AWT, it needs to be set at the Dialog's creation. Since a JDialog does have a native peer at some level, (although I'm not sure if it actually would be a native dialog window), you might be able to use the Java Invocation API instead of ShellExecuteEx to set up the JAR, watch for the JDialog to be created, and then link its peer through native code... but I don't think there's any easy way to do what you want, since Java windows aren't even supposed to be aware of native ones.

  • The disc is the wrong type for the operation

    Hello!
    I'm using DVD Studio Pro 4 and as I try to burn a double layer DVD I get a message saying "The disc is the wrong type for the operation". I've tried several brands, but I get the same message. What can possibly be wrong?
    Thanks for helping me!
    /Andreas from Sweden

    If you are trying to do this on the internal Superdrive they have problems writing to Dual Layer DVD disks of any make and or type.
    IMHO the DVD drive Apple uses is not very good.
    If this is a fairly new Mac system I suggest you take it to an Apple store and show them that it can't write to Dual Layer DVD discs of any make and maybe they will replace it with on e that will.

  • E71X: wrong mode for media transfer, Nokia Ovi Pla...

    I know this subject has been touched on before, but I'm frustrated!  I connect my e71x to the USB port with the cable, and select PC Suite mode.  I go into Nokia PC Suite, and then select Explore Ovi Music.  That invokes the Nokia Ovi Player, which tells me "your Nokia device is connected in the wrong mode for music transfer.  To connect in the right mode, try unplugging and reconnecting your device and ... choose one of the following: Media Player, Printing & Media, Media Transfer".  It also says to click on a "connect" button, but that doesn't do anything.
    So I unplug and reconnect my E71x, which I have configured to prompt me on connection.  I select Media Transfer per the above message.  Then I get the information: "connecting your device: 1) Connect your mobile or MTP-compatible  device to your PC using a compatible USB cable, 2) on the device, select the mode that allows you to transfer media and, if prompted, select OK".
    It appears that Nokia Ovi Player does not respond to either mode PC Suite or Media Transfer.  I tried reinstalling, and the version of Nokia Ovi Player I have is 2.0.1106.00.  The version of Nokia PC Suite is 7.1.40.1 - both should be pretty current!   Any ideas?

    I have just tried to use the Ovi Player for the first time and encountered the same problems as above on my 6500 Slide.  I had issues with the Ovi Suite (which I recently uninstalled) only to find that the Nokia Suite had adopted 'Ovi Player' for transferring music. Why? It worked perfectly!  I've read a few posts on both features,  and, it seems that the new programmes aren't going down too well with users! Are Nokia going to iron out these problems, and, how did they release this new software with so many inherent faults?  Anyone out there any solutions as to how I can transfer music from my PC (Windows Vista home premium) to my mobile in the meantime.  

  • I'm unable to correct a wrong url for my home page in Firefox

    I'm unable to correct a wrong url for my home page and have to manually use a separate bookmark that works once the home page loads. I use 3 url's total for the home page and the other 2 load properly.
    I've searched for the incorrect url and find it in 'about:config at browser.startup.homepage'. I've made the correction to the url but it does not seem to save when I close out of about:config.
    I've reset the home page under Tools and Options many, many times and it still doesn't change what is in
    'about:config at browser.startup.homepage
    I have been able to save the bookmark with the correct url in other folders.
    I've had this problem for quite awhile, at least 8 months or so and keep FF up to date, currently using V33.0.2 and Win7 Home Premium SP1

    I changed the pref.js file and that fixed the problem. thanks to those who responded to this question and for the quick replies. jjg18

  • VBR problems, wrong track length.

    I have a problem. I listen to a lot of audiobooks for work. I like them to be organized so I rip them on the computer in WAV format. I then use Audacity to combine them into chapters. Here is where the problem with iTunes starts. I can import all of the audio tracks fine, but the track lengths are wrong. For example, when importing one track it says that it is 2:40:18 long. In reality it is only 43:24 long. The only way I have found to fix it is to have iTunes make a copy of it, but I don't want to do this for every track.
    I know that it is an iTunes problem, because in the folder in Vista it says the correct length. It also says the correct length in; VLC Windows Media Player, Audacity, and every media program in Linux that I have used.
    Is there a way to fix this?

    I have a problem. I listen to a lot of audiobooks for work. I like them to be organized so I rip them on the computer in WAV format. I then use Audacity to combine them into chapters. Here is where the problem with iTunes starts. I can import all of the audio tracks fine, but the track lengths are wrong. For example, when importing one track it says that it is 2:40:18 long. In reality it is only 43:24 long. The only way I have found to fix it is to have iTunes make a copy of it, but I don't want to do this for every track.
    I know that it is an iTunes problem, because in the folder in Vista it says the correct length. It also says the correct length in; VLC Windows Media Player, Audacity, and every media program in Linux that I have used.
    Is there a way to fix this?

  • I was wrongly billed for two songs EIGHT times?

    I just want to know why I was wrongly billed for something that occurred this morning whilst using iTunes Store to buy music. I was told that I owed them $3.58, which I then tried to pay, but was told that my Security Code Number was not valid, which is wrong because I put in the correct number, but when I checked my card balance I was billed a whopping $28.64! That means I was billed $3.58 on EIGHT separate occasions. That's not right.
    What I want to know is a) why won't it let me pay for the songs (that I bought in July and was attempting to pay but wouldn't let me, and b) if I am ever going to get a response and my refund. Cause according to My Account, I still haven't payed the $3.58 and now I'm just plain furious at the Store for their blunder.

    Welcome to AD!
    This is a user-to-user forum, so the only help on billing I can give is to tell you that using the "Report A Problem" link in iTunes does not always work.
    Try this page instead:
    http://www.apple.com/support/itunes/
    The "itunes store account and billing" section will let you send an email.

  • Wrong tags for some songs?

    I have the 160 gig classic... I love the fact that it can hold so much but some songs have the wrong tag to the....for instance ...I choose Blondie one way or another and the song played will be a Johnny cash song.... You get the gist....
    When I play that song song in iTunes on my pc it is correct as in the tag corresponds to the song.....
    Any help would be appreciated.....

    Restoring an iPod removes all the data from it, builds a fresh database on the device, then puts back on the content that your request. If the database on the device becomes corrupt then it may index the wrong file for playback and a restore would be the recommended fix. At the very least you should confirm the problem persists after a restore. If so then some more details are likely to be required to pinpoint what is going on, e.g. is the file that plays the next/previous in the song menu for example? Is the one song always replaced by a specific other one and what are the details of both tracks?
    If you've selected an album to play, and have more than one album with the same title, then that is best explained by pointing you to http://samsoft.org.uk/iTunes/grouping.asp
    There are some tips in there about not using Sort fields to merge albums. It's quite some time now since I explored that behaviour in detail and I can't recall it actually being responsible for the wrong song being played in the way you originally described which is why I recommeded a restore first. If however, you have tried to use the sort fields in this way then perhaps all you need to do is correct the relevant tags in the ways I recommend in the article and re-sync the device.
    tt2

  • FLOWS_020200 decimal and comma setting, wrong definition for Croatian lang

    Hi!
    In what table (view) is definition that define for certain language that decimal point and comma.
    Problem is that for Croatian language these two items are flipped. When we change language to German, these two chars are OK.
    So we'd like to change value in some system table where is definition for Croatian language.
    P.S.
    For future versions please put that decimal point =',' and comma ='.' (opposite to current setting)
    THX

    Scott,
    we have successfully solved NLS problem in a way that I have described before.
    Now remaining problem is when we change language (hr-en) with code like:
      IF #OWNER#.tool.get_lang='hr' THEN
        :FSP_LANGUAGE_PREFERENCE := 'en';
        :G_PLEASE_WAIT := 'Searching...please wait!';
      ELSE
        :FSP_LANGUAGE_PREFERENCE := 'hr';
        :G_PLEASE_WAIT := 'Pretražujem...molim pričekajte!';
      END IF;
      htmldb_application.g_unrecoverable_error := true;
      htp.init;
    owa_util.redirect_url('f?p='||:APP_ID||':'||:APP_PAGE_ID||':'||:APP_SESSION);then we get an error because it seems that redirect_url is noto working with alter session (which execute Before page header and Before computations and validations for the same page).
    ORA-06502: PL/SQL: numeric or value error: character to number conversion errorlanguage change process is fired before "alter session" proceses...
    For us it is unacceptable to show wrong number format signs on WEB page.
    Is there any way to solve this problem?
    So please is there any table where we can replace that ...
    Just want to say that when we define "de" (German) as primary language (without our NLS_SETTING processes), that decimal and group format are OK as well as date format (DD.MM.YYYY).
    So please, these settings are placed somewher in Apex table...which one?
    THX!
    Message was edited by:
    Funky

Maybe you are looking for

  • HighResDownload of magazine with Adobe Reader X - Error Msg

    Am using AdobeReader X.  Subscribe to magazine that comes as a pdf.  When I download the low-resolution magazine, all works fine.  I typically download the High-resolution magazine and sometimes I get the following Adobe Reader X error:  "The file is

  • Menues in english and spanish languages

    Hi! I was given a Swing interface: 10 menu items, each one launches 5 to 10 submenues, each one launches several panels all in Spanish Language like this: private JMenu jMenuFile = new JMenu(); jMenuFile.setText("Archivo"); Now I was asked to change

  • How to Disable cache completely

    Please suggest me a way to load changed values from Session and remove cache. I do not want to use cache. After making a change in a page, I want to load the changed page using session. I am able to see changes when I hit "Refresh" only. All the time

  • SAP Netweaver XI Basis...

    Hey, Can nybody give me the most useful documents for learnng SAP Netweaver XI Basis. Cheers., Xeon

  • Why does my sound stop working

    Why does my sound stop working when listening to music or watching videos? I have to cut my phone off and then back on for it to start working again. Its happening more and more often.