Results 1 to 5 of 5

Thread: Page Navigation

  1. #1
    Deliverance is offline Member
    Join Date
    Apr 2012
    Location
    Kilkenny, Ireland
    Posts
    3
    Rep Power
    0

    Default Page Navigation

    Hi all,

    What is the best way (also best practise!) to navigate through pages? Would it be advisable to use
    setVisibility on multiple JFrames? Multiple JPanels? I would like to separate each page into its own separate class also.

    Thanks :)

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Page Navigation

    CardLayout or JTabbedPane.

    In future, please post Swing related questions in the AWT/Swing section.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Deliverance is offline Member
    Join Date
    Apr 2012
    Location
    Kilkenny, Ireland
    Posts
    3
    Rep Power
    0

    Default Re: Page Navigation

    Quote Originally Posted by DarrylBurke View Post
    CardLayout or JTabbedPane.

    In future, please post Swing related questions in the AWT/Swing section.

    db
    Thanks :)

    Would it be considered bad practise to remove all components and then add the neccessary ones again?

    As in:

    Java Code:
    // User presses a button to pull up page2
    getContentPane().removeAll(); // This removes the current page, sidebar and header
    guiDesign(); // This repaints the sidebar and header
    getContentPane().add(page2, BorderLayout.CENTER); // This will paint page2
    The reason I ask is because each page will have separate database queries on them so if they were all loaded at the start with a layout would that slow it all down?

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Page Navigation

    Quote Originally Posted by Deliverance View Post
    Would it be considered bad practise to remove all components and then add the neccessary ones again?
    Yes.

    The reason I ask is because each page will have separate database queries on them so if they were all loaded at the start with a layout would that slow it all down?
    You can do a lazy loading: load each 'page' when it is to be shown for the first time.

    Database access should be done in a Thread other than the EDT. Find and go through the tutorial on Concurrency in Swing to know your options for that.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Deliverance is offline Member
    Join Date
    Apr 2012
    Location
    Kilkenny, Ireland
    Posts
    3
    Rep Power
    0

Similar Threads

  1. navigation b/w frames
    By imrankhan in forum AWT / Swing
    Replies: 3
    Last Post: 03-19-2012, 12:25 PM
  2. File Navigation?
    By Moncleared in forum New To Java
    Replies: 3
    Last Post: 01-07-2011, 01:51 AM
  3. navigation in jsf
    By riya_nap in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 10-04-2010, 08:53 AM
  4. Page to page navigation
    By leovach in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-17-2010, 09:29 AM
  5. Wep page navigation buttons
    By anthony417 in forum Advanced Java
    Replies: 1
    Last Post: 07-26-2007, 08:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •