CardLayout does not work

I'm building a dynamic UI which has "x" number of labels and "x" no of fields. I'm able build the UI.
When I make a selection in the ComboBox the UI(labels and fields change). For this I'm using a cardlayout.
It does not seem to work.
AttributesPanel builds the UI(Labels, Fields)
import java.util.*;
import java.util.List;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class AttributesPanel extends JPanel {
    private JTextField[] fields;
    private List attributes;
    public AttributesPanel(String templateName) throws Exception{
        JSeparator sep = new JSeparator();
        JButton okButton = new JButton("OK");
        JButton cancelButton = new JButton("Cancel");
        com.insignia.profileManagement.dataLoader.NewProfileMetaDataLoader loader = new com.insignia.profileManagement.dataLoader.NewProfileMetaDataLoader();
        attributes = loader.BuildAttributes(templateName);
        for(int i = 0; i< attributes.size(); i ++) {
          String attributename = (String)attributes.get(i);
          System.out.println("Names of the attribute: " +attributename);
        fields = new JTextField[attributes.size()];
        JLabel[] labels = new JLabel[attributes.size()];
        for(int i = 0; i< attributes.size(); i++) {
            labels[i] = new JLabel((String)attributes.get(i));
            fields[i] = new JTextField(15);
        GridBagLayout gb1 = new GridBagLayout();
        GridBagConstraints gbc = new GridBagConstraints();
        setLayout(gb1);
        gbc.anchor = GridBagConstraints.NORTHWEST;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        add(new JLabel("Assign Profile Template"), gbc);
        gbc.anchor = GridBagConstraints.NORTH;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(0,0,10,0);
        add(sep, gbc);
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(0,0,0,0);
        for(int i = 0;i < attributes.size(); i ++){
            gbc.gridwidth = 1;
            add(labels[i] ,gbc);
            add(Box.createHorizontalStrut(10));
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            add(fields,gbc);
JPanel buttonPanel = new JPanel();
buttonPanel.add(okButton);
buttonPanel.add(cancelButton);
gbc.anchor = GridBagConstraints.SOUTH;
gbc.insets = new Insets(15,0,0,0);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridwidth = 7;
add(buttonPanel,gbc);
2nd class which calls AttributesPanel
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.lang.*;
import java.util.*;
import java.util.List;
public class ProfileUI extends JPanel implements ActionListener{
private JPanel templatePanel;
JComboBox comboBox = new JComboBox();
private CardLayout cardLayout;
com.insignia.profileManagement.dataLoader.NewProfileMetaDataLoader loader = new com.insignia.profileManagement.dataLoader.NewProfileMetaDataLoader();
public ProfileUI() throws Exception {
templatePanel = new JPanel();
List templates = loader.BuildTemplates();
comboBox.addActionListener(this);
for(int i = 0; i< templates.size(); i ++) {
comboBox.addItem(templates.get(i));
//attributes = loader.BuildAttributes((String)templates.get(i));
templatePanel.add(comboBox);
List attributes = loader.BuildAttributes("Email Template");
// //creating no of card layouts.
cardLayout = new CardLayout();
JPanel mainCardPanel = new JPanel(cardLayout);
AttributesPanel[] cardPanels = new AttributesPanel[attributes.size()];
for (int i = 0; i < attributes.size(); i++) {
mainCardPanel.add(cardPanels[i], i);
// createCardPanel(cardPanels[i], (String)comboBox.getItemAt(i));
cardLayout.show(cardPanels[i], "" + i);
templatePanel.add(mainCardPanel);
//updateLabel(0);
cardLayout.show(cardPanels[0], "" + 0);
public void actionPerformed(ActionEvent e){
if(e.getSource() == comboBox) {
public static void main (String args []) throws Exception {
JFrame frame = new JFrame("ProfileUI");
JComponent newContentPane= new ProfileUI();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // use this or a
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
frame.setSize(400,390);
frame.setVisible(true);
//frame.setResizable(false);
thnx

Personally, I've had numerous issues with CardLayout -- I'd suggest you try CardPanel instead:
http://java.sun.com/products/jfc/tsc/articles/cardpanel/
- Fromage

Similar Messages

  • Installed Premiere Pro CS4 but video display does not work?

    I just got my copy of CS$. After installing Premiere I found two things that seem very wrong:
    1) video display does not work, not even the little playback viewer next to improted film clips located on the project / sequence window. Audio works fine.
    2) the UI is way too slow for my big beefy system.
    My pc is a dual boot Vista-32 and XP system with 4GB of memory installed and nvidia geforce 280 graphics board with plenty of GPU power. The CS4 is installed on the Vista-32 partition. My windows XP partition on the same PC with Premiere CS2 works great and real fast.
    Any ideas how to solve this CS4 install issue?
    Ron

    I would like to thank Dan, Hunt, and Haram:
    The problem is now very clear to me. The problem only shows up with video footage imported into PP CS4 encoded with "MS Video 1" codec. So this seems to be a bug. The codec is very clearly called out and supported within various menues but video with this codec just will not play in any monitor or preview window. In addition the entire product looks horrible with respect to performance while PP CS4 trys its best to play the video. Audio will start playing after about 30 seconds. And once in awhile part of video shows up at the wrong magnification before blanking out again.
    My suggestion to the Adobe team: fix the bug and add some sample footage to the next release so new installations can test their systems with known footage.
    My PC is brand new with the following "beefy" components:
    Motherboard
    nForce 790i SLI FTW
    Features:
    3x PCI Express x16 graphics support
    PCI Express 2.0
    NVIDIA SLI-Ready (requires multiple NVIDIA GeForce GPUs)
    DDR3-2000 SLI-Ready memory w/ ERP 2.0 (requires select third party system memory)
    Overclocking tools
    NVIDIA MediaSheild w/ 9 SATA 3 Gb/sec ports
    ESA Certified
    NVIDIA DualNet and FirstPacket Ethernet technology
    Registered
    CPU: Intel Core 2 Quad Q9550
    S-Spec: SLAWQ
    Ver: E36105-001
    Product Code: BX80569Q9550
    Made in Malaysia
    Pack Date: 09/04/08
    Features:
    Freq.: 2.83 GHz
    L2 Cache: 12 MHz Cache
    FSB: 1333 MHz (MT/s)
    Core: 45nm
    Code named: Yorkfield
    Power:95W
    Socket: LGA775
    Cooling: Liquid Cooled
    NVIDIAGeForce GTX 280 SC graphics card
    Features:
    1 GB of onboard memory
    Full Microsoft DirectX 10
    NVIDIA 2-way and 3-way SLI Ready
    NVIDIA PureVideo HD technology
    NVIDIA PhysX Ready
    NVIDI CUDA technology
    PCI Express 2.0 support
    Dual-link HDCP
    OpenGL 2.1 Capaple
    Output: DVI (2 dual-link), HDTV
    Western Digital
    2 WD VelociRaptor 300 GB SATA Hard Drives configured as Raid 0
    Features:
    10,000 RPM, 3 Gb/sec transfer rate
    RAM Memory , Corsair 4 GB (2 x 2 GB) 1333 MHz DDR3
    p/n: TW3X4G1333C9DHX G
    product: CM3X2048-1333C9DHX
    Features:
    XMS3 DHX Dual-Path 'heat xchange'
    2048 x 2 MB
    1333 MHz
    Latency 9-9-9-24-2T
    1.6V ver3.2

  • A2109 tablet autorotate does not work

    The autorotation on my recently purchased tablet A2109 does not work. I look in settings and the auto rotate field is not highlighted, I therefore cannot choose to turn it on.The tablet has the Android jellybean OS and I did update it but to no avail. Can anyone help?
    Thanks
    Solved!
    Go to Solution.

    Dear tdsouza
    Welcome in lenovo forums
    just a clarification , do you mean option Rotate is dimmed in setting 
    Please let me know 
    Thanks
    Alaa
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • For what reason on my tablet with OS Android 4.1 does not work flash on the sites?

    Hi! I recently bought a Google Nexus 7 tablet with Android 4.1 operating system and on my tablet does not work flash sites. Why adobe does not release a new version of flash for android 4.1? Why it was necessary to buy a company Macromedia, if adobe does not want to develop web technology? I think against Adobe can sue for violation of antitrust

    I found this for example:
    http://www.slashgear.com/adobe-no-jelly-bean-flash-flash-player-pulled-altogether-august-1 5-29236404/

  • My flash flayer does not work on my Windows 8 Surface Tablet, it also won't let me see if i already

    My flash flayer does not work on my Windows 8 Surface Tablet, it also won't let me see if i already have it installed...

    1.      Are you getting any error message?
    2.      Which browser are you using?
    3.      Were there any recent changes made on the computer prior to the issue?

  • My flash player does not work on my tablet.

    My flash player does not work on my tablet

    Your tablet uses Android OS.
    There is no more Flash Player for Android and there won't be another. Android is no longer compatible with Flash Player. Playing Flash content is very processor consumptive and it drains your battery, also shortening the life of it. Android (Google) recommends using either "Dolphin" or "Puffin" as your browser if you need to view Flash content with a mobile device running Android. They're both free in the GooglePlay store. These browsers use "server side" rendering to reduce the load on your device.

  • Dynamic image does not work in the template builder plug-in (Apex-BI Intgr)

    Hi all, I posted this problem in the BI Publisher topic but nobody responded maybe this is because mods thought this is an Apex-BI integration issue.
    If I'm in the wrong place, please do warn me.
    The documentation says:
    Direct Insertion
    Insert the jpg, gif, or png image directly in your template.
    ...This works obviously
    URL Reference
    1. Insert a dummy image in your template.
    2. In Microsoft Word's Format Picture dialog box select the Web tab. Enter the following syntax in the Alternative text region to reference the image URL:
    url:{'http://image location'}
    For example, enter: url:{'http://www.oracle.com/images/ora_log.gif'}
    ...This works too when I hardcode an url as url:{'http://www.google.com.tr/images/firefox/mobiledownload.png'}
    Element Reference from XML File
    1. Insert a dummy image in your template.
    2. In Microsoft Word's Format Picture dialog box select the Web tab. Enter the following syntax in the Alternative text region to reference the image URL:
    url:{IMAGE_LOCATION}
    where IMAGE_LOCATION is an element from your XML file that holds the full URL to the image.
    ...This, however, does not work.
    I use Apex' report query tool and My query is like
    select 'http://www.google.com.tr/images/firefox/mobiledownload.png' IMAGE_LOCATION from ... (a single result set for my template)
    the xml data is generated with an IMAGE_LOCATION tag. I load it to word template plug-in. The Url successfully displays in the report if I make it a plain-simple field.
    But when it's in the image format->web->alt text as url:{IMAGE_LOCATION} no image displayed.
    I need to keep this design procedure simple so a simple word user could design a report via using just template builder plug-in. I don't wish to explore the xsl-fo area...yet.
    Could you tell me why I can't get this url:{IMAGE_LOCATION} to work?
    Regards
    PS: My BI version: 10.1.3.4.1

    Hi Oeren,
    your steps seem basically to be correct. I have a tutorial how to do this here (in german)
    http://www.oracle.com/webfolder/technetwork/de/community/apex/tipps/pdf-dyn-images/index.html
    when you see the URL corrently as long as you have it as a plain text field, the XML tag and the
    referencing seem to be OK.
    Here are two thought - the issue might be one of these ...
    How did you insert the dummy image into the word document - did you do it via "insert" or
    via "link to file". "Link to File" does not work - you must choose the simple "insert".
    Another one: Does your BI Server have a connection to the internet - is the proxy server correctly set ..?
    Does this help ..?
    Regards
    -Carsten
    Cloud Computing mit APEX umsetzen. Jetzt!
    http://tinyurl.com/apexcloudde
    SQL und PL/SQL: Tipps, Tricks & Best Practice
    http://sql-plsql-de.blogspot.com

  • I have an event in my calendar that was sent by someone who does not work for the company anymore and I am reminded 2 times a week. How can I remove it?

    I have an event in my calendar that was sent by someone that does not work for the company anymore and I am reminded 2 times a week. How do I delete it?

    Tap on the event to open the event. Click the 'Edit' button in the event bubble, then press the 'Delete Event' button at the bottom of the Edit pop-up. It's a little different for events that come through Microsoft Exchange, you tap the event to bring up bubble and click the 'Details' button, and then press 'Decline' to remove the event.

  • Thanks for responding.  Since I upgraded ITUNES to IOS 6, my IPOD Touch no longer works at all.  I had numerous apps, music and videos on this touch.  It made me restore to factory reset and it still does not work!!! Nothing I do will work on this touch n

    Thanks for responding. Since I upgraded ITUNES to IOS 6, my IPOD Touch no longer works at all. I had numerous apps, music and videos on this touch. It made me restore to factory reset and it still does not work!!! Nothing I do will work on this touch now. I have so much data on this, I don't want to loose or have to restore!
    Can you help me?
    Thanks

    If you restored to factory settings/new iPod and still have the problem that indicates a hardware problem.
    Make an appointment at the Genius Bar of an Apple store..
    Apple Retail Store - Genius Bar

  • "HP laserjet professional utility" does not work in osx 10 (Yosemite)

    All the major functions of this printer work fine in Yosemite, but not the "HP laserjet professional utility"The driver shown in System Preferences/Printer for my Laserjet P1606dn is version 6.9 (I am unable to knowif this is the version provided by the latest HP printer update, which was installed via the App Store.) I note this exact issue was raised for OSX7 in November 2014, but for a diiferent model printer.  My printer is on my local wifi network, and that earlier case seemed to invove a direct USB connection. The solution offered in that thread, 4694464,may not be applicable now, so I seek advice In the panel for my 1606dn within System Preferences/Printer offers a button to launch the "HP Professional Utility", but when clicked an app launches called the "HP Professional Utility" but then nothing.  I am trying to access the printer controls that will keep it from turning itself off when idle, and the documentation says the "HP Professional Utility" will allow that change. Please advise 

    Hey , Welcome to the HP forums! I hope you enjoy your stay here. I see that you are having some issues with adjusting the power save mode settings on your Laserjet P1606dn. I can help with that. First make sure the printer is plugged directly into a wall outlet and not a surge protector. If the printer is connected with an ethernet cable to a router then you may be able to do this instead:On the printer hold down the button that looks like a sheet of paper with an arrow on it for about ten seconds. This should print out a report.On your Mac open a browser and enter the printer's IP Address in your Address bar exactly as it appears on the page. When you are finished click on enter/return.This will open the printer's Embedded Web Server. In here you may be able to find some options to adjust the power save settings.If the above does not work then this troubleshooting may assist you with the utility:Go to Applications, and if you have it open the Hewlett-Packard folder.Run HP Uninstaller to remove any existing software from you system.On the Mac go to the Apple icon and Sytem Preferences.Open Printers and Scanners.Hold down the Command key and click on the picture of your printer on the left.Click on Reset Printing System.Go to Applications and Utilities.Open Disk Utility.Click on Macintosh HD on the left.Click on Verify Disk Permissions. This should take about ten minutes.Click on Repair Disk Permissions. This should take about ten minutes.Restart your Mac.Plug in the USB cable between the printer and the router.Check for Product Updates on your Mac.Try running the tool again.If this resolves everything please let others know by clicking on Accept as Solution below my post.
    I hope this helps and I hope you have a great day! 

  • I have recently upgraded my iMac Intel G5 iSight to OS 10.6.8 and now the internal mic does not work with skype or facebook. I can here static when playing back clips. Do I need to update firmware or reload old sys parts

    I have recently upgraded my iMac Intel G5 iSight (iMac5,1) to OS 10.6.8 and now the internal mic does not work with skype or facebook. I can here static when playing back clips. Do I need to update firmware or reload old system parts. I have zapped PRAM. The blue indicator in system audio panel will appear for a second as I slide the bar for internal mic but then it disappears. Is there a fix?

    The sound seems very faint but can here static on playback.

  • TS1702 When I update to IOS6 on my 4S Facebook does not work properly, the news feed never updates it only says no new storeys and shows a picture of an antenna. When I reset my phone and go back to IOS5 Facebook works fine. What's up with IOS6 ????

    When I update my iPhone 4S to iOS six Facebook does not work properly the newsfeed doesn't load properly and I can never see what's going on all I see is a picture of an antenna and a little thing underneath it says no new stories when I reset my phone back to iOS 5 then it works just fine and I don't have any issues so there must be something wrong with iOS six that isn't letting Facebook load properly

    No I did not use any unauthorized methods for anything, I simply reset my phone back to factory.
    <Edited By Host>

  • Home sharing does not work after update to snow leopard 10.6.4 and iTunes 9

    I am using home sharing since about a year without any problems. After updating to snow leopard 10.6.4 and iTunes 9.2 it suddenly does not work anymore.
    On my iMac and my Mac Book Pro I get error code 3259 and it tells me to check my firewall and to enable Port 3689.
    I did not change anything in the firewall settings, itunes on both allows data traffic in both directions. I also do not find any option to activate a port ( also wondering why this is suddenly now necessary)
    I deactivated home sharing on both machines and enabled it again. It still does not work.
    On both machines iTunes displays the the library on the left side but like said it is not accessable
    With Finder I can access the other computer from both machines without any problem.
    Any help to solve this would be very much appreciated

    first of all, if you are behind a router firewall, and have your network secured (WPA2 and a long, non-dictionary password made up of letters and numbers), you don't need the software firewall on your Mac(s).
    @ least turned if off for troubleshooting purposes.
    turn home sharing off on both computers, and make sure
    (a) both Macs have access to the internet
    (b) iTunes on both machines is authorized for the same iTunes account.
    turn home sharing back on on both Macs.
    does it work ?
    JGG

  • Adobe photoshop cs2 download on adobe website does not work-  the serial number does not work?

    photoshop cs2 download on adobe website does not work - the serial number given isn't recognised when you enter it when trying to install. the live chat at adobe cannot help and suggested that I may find the answer here. Can anyone help with this?

    Adobe has decommissioned the CS2 activation servers, so your old serial number is no longer usable.
    If you download the special non-activating version of CS2 that Adobe has made available to licensed CS2 users, you MUST also use the new serial number provided by Adobe on that download page:
    https://www.adobe.com/cfusion/entitlement/index.cfm?e=cs2_downloads
    That S/N does work.  I double checked.

  • Unable to install "Mavericks" as it asks for my 'Admin Password" and it does not work. Have not used it since I got my iMac in 2008. First upgrade to do so. Any solutions please?

    I have a 2008 iMac which had Leopard initially and I have upgraded to each new OS without a hitch. I downloaded "Mavericks" and began the install, it asked me for my "Admin Password" which I have never ever used since I set the Mac up, I have it safely tucked away so entered it, it rejected it each time. Am sort of lost now, as if my "Admin P/W" does not work here can I go from here?
    I have seen many others with this problem but so far most of the solutions seem to be for the "log in" or "User" password not the Admin one.
    I am running Mountain Lion successfully.
    I have my original disks as supplied and also a Snow Leopard install disk.
    I have seen some info about fixing this via Lion Recovery partition which I must have due to using Mt Lion.
    How can I repair this situation.
    Thank you to all those who respond.

    Thanks for your reply.
    I have visited both the sites you listed but it seems to me that the solutions mentioned are to fix the User or log in p/w's.They do not seem to refer to the admin one again.
    I understand about it being just like other user accts but the fixes do not really refer to it only the above two.
    I have no problem booting up my Mac, I do not use a log in p/w so my problem is with the Admin p/w that was set up back in 2008. This is what I need to reset etc.
    I am quite confused over these pw's as to just what is what and I need to make sure I understand all before I get into deeper trouble following these links.
    This Admin p/w that was set up has never been used and is the only p/w I have except for my Apple ID. All previous upgrades only required my user name log in which has no p/w set up.
    I hope you can follow me here butI have read so much on this it is becoming very confusing about whcih p/w's are what.

Maybe you are looking for

  • Error while assigning external event

    Hi Guys! I'm getting error, while trying to assign an external event on table output. I've got a button with action POSTPO, that is residing in standalone form. That action should send data form some form and a table to BAPI. When I try to configure

  • I deleted an app then tried to install another app but it won't allow.also I can't tap on items attached to emails

    I deleted an app then tried to download a different app but system now won't let me? Also when reading emails the frame freezes if I tap on any attachments .

  • Dynamic File name in FTP Communication Channel

    Hi All, We have requirement where ,we create a filenames dynamically ( runtime).These filenames whihc do change for every execution needs to be added in FTP communication channel. 1. How can we add the this generated file name in FTP CC Communication

  • Importing video from sony handycam disc

    I am trying to load a DVD created from a Sony handycam and import the video to iMove HD. Does anyone know how to do this or do I need to connect the camera. I have 7 half hour discs that I am trying to combine for my mother. I thought I could do it w

  • Encoding still image files - quality problems

    The project is almost over, and of course problems are now rearing their ugly heads. The .pct files I'm using for the menus seemed to encode just fine last week, with very little noticeable MPEG2 compression. Now however, without any changes to the f