Results 1 to 3 of 3
  1. #1
    dcojocaru is offline Member
    Join Date
    Jul 2007
    Posts
    2
    Rep Power
    0

    Default Sharing variables between 2 custom components. Please help.

    Hi,

    I'm a beginner in java and I have a problem.
    I need to use 2 classes, defined in 2 separate files, in a thisrd, main class.
    Actually I copy/paste the 2 classes (are made as swing jpanels with controls, textboxes, combos, etc) in the main class, so in the main class they appear as components.
    I need to read a value from one ( a combobox selected item), and use it in the second one.

    how could this be done ?

  2. #2
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    Normally this is done by creating a custom constructor for the components. Send the reference of the objects of the other component to these components with their constructor.

  3. #3
    dcojocaru is offline Member
    Join Date
    Jul 2007
    Posts
    2
    Rep Power
    0

    Default Still not working

    I tried but is not working. what I need is to read a combo box from first component every time when it is updated and use it in second component , when a buton from second component is pushed. I don't know how to make this.

Similar Threads

  1. GUI components not display
    By Eranga in forum AWT / Swing
    Replies: 2
    Last Post: 03-12-2008, 02:16 AM
  2. what is the best ADT to use in p2p sharing
    By a_maged in forum Networking
    Replies: 0
    Last Post: 12-02-2007, 08:15 PM
  3. sharing of data between sites
    By jyovasinedu in forum Advanced Java
    Replies: 1
    Last Post: 11-02-2007, 08:56 AM
  4. 2 threads sharing a data base connection
    By Ed in forum Advanced Java
    Replies: 2
    Last Post: 07-04-2007, 04:41 AM
  5. Gui Components
    By Marty in forum New To Java
    Replies: 1
    Last Post: 05-28-2007, 04:04 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
  •