Results 1 to 6 of 6
  1. #1
    fred2482 is offline Member
    Join Date
    Dec 2009
    Posts
    7
    Rep Power
    0

    Default JFrames or Panels to perform different tasks

    Wondering what the best way to perform different tasks in one application is? I want to create a program that requires a logon (verifies through Database). After Loggin in I want to have a JFrame full of buttons that are assigned different tasks. For example: If user has permissions, they can click on button1 to bring a database entry screen up to add, delete and modify database entries. They also could click button2 to display a report of the data on the database. Button3 would bring up a screen that changes their user preferences. I can not figure out how to do this with out opening numerous JFrames at one time. The only other way I know is to create different panels and have the buttons display a different panel according to what the request is. Is there a better way? If not is the JFrame or Panel idea better? Thanks so much in advance!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    It is almost always a better idea to code to the panel and not the frame. Having said that you should need to extend JPanel infrequently (usually when displaying graphics on the panel), and will almost never need to extend a JFrame.

  3. #3
    fred2482 is offline Member
    Join Date
    Dec 2009
    Posts
    7
    Rep Power
    0

    Default

    Thank you for your quick reply. I will try the entire program with populating different panels instead of frames when the buttons are clicked.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    If swapping panels, are you thinking about using a CardLayout?

  5. #5
    fred2482 is offline Member
    Join Date
    Dec 2009
    Posts
    7
    Rep Power
    0

    Default

    Yes, a card layout should work as long as I can direct which "Card" or panel I need to go to and not have to perform it in sequential order. Each panel should allow me to connect to the database, have buttons of their own and abstract input from text fields, correct?

  6. #6
    fred2482 is offline Member
    Join Date
    Dec 2009
    Posts
    7
    Rep Power
    0

    Default

    Thanks so much for your help. I have just searched the already posted threads and noticed that there has been many questions similar to the one I asked (And you have answered most of them with the same answer you gave to me). After reading through them I think the card layout is good for me. Thanks so much for helping me out even though the question has been asked a million times!!

Similar Threads

  1. Cannot perform a PING
    By mnementh64 in forum Networking
    Replies: 1
    Last Post: 09-17-2009, 04:39 PM
  2. Scheduling tasks using Threads
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-11-2007, 10:24 AM

Posting Permissions

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