Results 1 to 6 of 6

Thread: Gui

  1. #1
    c_walker is offline Member
    Join Date
    Oct 2009
    Posts
    17
    Rep Power
    0

    Default Gui

    Hi! It's me again. I still need help, now it's about GUI.

    I am to create an application using JFrame and my program includes many options and methods. Do I need to create different variables for every JTextFields. I mean, if my whole program needs 10 text fields, should I create 10 text field variables. For example, JTextField departmentData, JTextField copyData, JTextField copierData, etc. Can't I use just one text field, JTextField data for an instance and just reuse it in the other options/methods? Same goes for the buttons.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Say this, if you don't have a unique id, variable, for each component how did you going to refer them? Just think about that...

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

    Default

    GUIs are no different from non-GUI code in this respect. If you need 10 distinct int vars, then you need 10 int vars -- sometimes held in a single array.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by Fubarable View Post
    sometimes held in a single array.
    Agreed! There are lots of way to store those variables, but identifying how many variables you want is may confuse. As I said earlier think that how we can access/call components.

  5. #5
    c_walker is offline Member
    Join Date
    Oct 2009
    Posts
    17
    Rep Power
    0

    Default

    Ok, I see. I thought we could reuse the variables :D Thanks!

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Posting Permissions

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