🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

JDialog and CardLayout problem switching between panels

#7708
From: Ed
Date: Thu, 04 Jan 2001 17:00
169 lines
5300 bytes
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: <3a54aca1$1_1@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!195.161.0.180!newsfeed.rt.ru!news.algonet.se!algonet!neel.uni2.net!newssuck.uni2.dk!bornews.borland.com!dnews!12.39.173.65

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,346c49090a946af6,start
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2001-01-04 09:10:20 PST
Reply-To: "Ed" <ereyes@telynx.com>
From: "Ed" <ereyes@telynx.com>
Newsgroups: borland.public.jbuilder.java.swing
Subject: JDialog and CardLayout problem switching between panels
Date: Thu, 4 Jan 2001 11:00:41 -0600
Lines: 173
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MIMEOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
NNTP-Posting-Host: 12.39.173.65
Message-ID: <3a54aca1$1_1@dnews>
X-Trace: 4 Jan 2001 09:02:25 -0800, 12.39.173.65
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!195.161.0.180!newsfeed.rt.ru!news.algonet.se!algonet!neel.uni2.net!newssuck.uni2.dk!bornews.borland.com!dnews!12.39.173.65