Question about using Viewport, BorderLayout related.

  • I initialize my Viewport with a west and center region. The center region is a regular Panel with some content. I have another Panel with some other content. Based on a button click in the west region, I want to replace the center panel in the viewport with the other panel. My understanding is that I do something like this:


    viewport.remove('initialcenter');
    viewport.add('newpanel');
    viewport.doLayout();


    Some supplemental information. The newpanel's config has the region set as center as well (not sure if this is needed or not, but I couldn't figure out via the API docs where else I could set it). The interesting thing is that the original panel does get removed (you no longer see it) but the new panel never shows up. the .add call does return a reference to the panel being added, so I'm assuming that it's not an error.

    Is this the right way to do it, or is it bad practice? The examples and API doc doesn't, surprisingly, show anything like this (maybe it does, if so, let me know.)

    Thanks!

    Taylor


  • Taylor -

    Create an additional container panel with a layout of card in your center region. You can then add/remove panels as you please and use the layout's setActiveItem method. Check out the docs for CardLayout for further info.


  • i would suggest you leave the centerpanel alone and add and remove the the two panels to the centerpanel.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Question about using Viewport, BorderLayout related. , Please add it free.