🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #7713

Re: JDialog and CardLayout problem switching between panels

#7713
From: Torsten Welches
Date: Thu, 04 Jan 2001 18:37
199 lines
5998 bytes
Ed,

unfortunately you didn't show QueryWizardDialog's jbInit(), I assume this is
the method where you are a) applying the CardLayout and b) add the JPanels
to the Container that uses the CardLayout.

Basically it's like that:
//add a panel
cardPanel.add(aPanel, someString); //someString identifies the component
being added - use it for show(...) later!
...
//switch card
CardLayout cl = (CardLayout)(cardPanel.getLayout());
cl.show(cardPanel, someString);

Good luck,
Torsten

Ed schrieb in Nachricht <3a54aca1$1_1@dnews>...
>I have created a JDialog that is instantiated once my application is
running
>by selecting a button.  In other words it is not built on top of the Frame
>of the application's project.
>
>I passed this frame into the Dialog's constructor thinking the JDialog
super
>constructor needs the Frame reference in it's constructor - I am not sure
>about that though.
>
>Here is what I did essentially:
>
>
>public class Frame1 extends JFrame
>{
>JPanel contentPane;
>XYLayout xYLayout = new XYLayout();
>JButton jRunButton = new JButton();
>
>  ...
>
>
> void jRunButton_actionPerformed(ActionEvent e)
>   {
>      String CommandString = e.getActionCommand();
>      int nReportRequest = jReportList.getSelectedIndex();
>      JReportManager reportManager = new JReportManager( this,
>nReportRequest);
>   }
>
>} // end of Frame1 class
>
>
>
>
>import telynx.QueryWizard.QueryWizardDialog;
>import javax.swing.JFrame;
>
>public class JReportManager
>{
>
>// the report type options - passed into the JReportManager Constructor
>private static final int CUSTOMIZE_REPORT = 8;
>
>
>   public JReportManager()
>      {}
>
>   public JReportManager( JFrame parentFrame, int reportRequest )
>   {
>      switch ( reportRequest )
>         {
>         case CUSTOMIZE_REPORT:
>            try
>               {
>               QueryWizardDialog QueryWizard = new
>QueryWizardDialog(parentFrame);
>               QueryWizard.show();
>               }
>            catch( Exception e )
>               { e.printStackTrace(); }
>            break;
>
>         }
>   }
>
>}
>
>
>
>
>
>
>public class QueryWizardDialog extends JDialog
>{
>static final int TABLE_SELECTOR_PANEL_INDEX = 0;
>static final int FILTER_PANEL_INDEX = TABLE_SELECTOR_PANEL_INDEX + 1;
>static final int SORT_PANEL_INDEX = FILTER_PANEL_INDEX + 1;
>static final int FINISH_PANEL_INDEX = SORT_PANEL_INDEX + 1;
>static final int MAX_OVERLAPPING_PANEL = FINISH_PANEL_INDEX + 1;
>
>int iiPanelIndicator = 0;
>JPanel jQueryWizardPanel = new JPanel();
>JPanel jOverlappingPanels = new JPanel();
>
>CardLayout cardLayout = new CardLayout();
>JPanel jColumnSelectionPanel = new JPanel();
>JPanel jFilterDataPanel = new JPanel();
>JPanel jSortOrderPanel = new JPanel();
>JPanel jFinishPanel = new JPanel();
>
>
>   public QueryWizardDialog(JFrame parentFrame)
>   {
>   super( (Frame) parentFrame, "QUERY WIZARD MANAGER", true );
>      try
>         { jbInit(); }
>      catch (Exception e)
>         { e.printStackTrace();
>         }
>   }
>
>
>
>
>   void jShowPanel( int panelIndicator )
>   {
>      try
>         {
>         switch ( panelIndicator )
>            {
>            case TABLE_SELECTOR_PANEL_INDEX:
>
>((CardLayout)jColumnSelectionPanel.getLayout()).show(jColumnSelectionPanel,
"
>Query Wizard - Table/Column Selector");
>               break;
>            case FILTER_PANEL_INDEX:
>               cardLayout.show( jFilterDataPanel, "Query Wizard -
Filter" );
>               break;
>            case SORT_PANEL_INDEX:
>
>(CardLayout)jSortOrderPanel.getLayout()).show( jSortOrderPanel, "Query
>Wizard - Sort" );
>               break;
>            case FINISH_PANEL_INDEX:
>               ((CardLayout)jFinishPanel.getLayout()).show( jFinishPanel,
>"Query Wizard - Finish" );
>               break;
>            default:
>               break;
>            }
>         }
>      catch ( Exception e )
>         {
>         e.printStackTrace();
>         }
>   }
>
>
>
>When I call the two different methods of changing panels:
>
>
>((CardLayout)jColumnSelectionPanel.getLayout()).show(jColumnSelectionPanel,
"
>Query Wizard - Table/Column Selector");
>    or
>            cardLayout.show( jFilterDataPanel, "Query Wizard - Filter" );
>
>I get the same result.   I get an exception.  I believe it may be because I
>am not getting the correct layout pointer.  (C++ background - sorry).
>Should I be passing the original frame of the panel that is creating the
new
>JDialog or will JDialog create it's own frame?????
>
>
>Can any one provide some insight into this.
>
>
>
>I have seen the two methods
>
>
>((CardLayout)jColumnSelectionPanel.getLayout()).show(jColumnSelectionPanel,
"
>Query Wizard - Table/Column Selector");
>    or
>            cardLayout.show( jFilterDataPanel, "Query Wizard - Filter" );
>
>used in changing between panels in a CardLayout arrangment of overlapping
>panels.  Can someone clarify which is the right one to use???
>
>Thanks In Advance,
>Ed
>
>
>
>
Technical Details
Message-ID: <3a54c374_2@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!newsfeed.online.be!newsfeeds.belnet.be!naxos.belnet.be!news.belnet.be!bornews.borland.com!dnews!195.14.251.181
References: <3a54aca1$1_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,346c49090a946af6
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2001-01-04 10:41:36 PST
From: "Torsten Welches" <torsten.welches@who.cares.netcologne.de>
Newsgroups: borland.public.jbuilder.java.swing
References: <3a54aca1$1_1@dnews>
Subject: Re: JDialog and CardLayout problem switching between panels
Date: Thu, 4 Jan 2001 19:37:10 +0100
Lines: 201
X-Newsreader: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
NNTP-Posting-Host: 195.14.251.181
Message-ID: <3a54c374_2@dnews>
X-Trace: 4 Jan 2001 10:39:48 -0800, 195.14.251.181
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!newsfeed.online.be!newsfeeds.belnet.be!naxos.belnet.be!news.belnet.be!bornews.borland.com!dnews!195.14.251.181