Sharing variables between 2 custom components. Please help.

Hi,

I'm a beginner in java and I have a problem. I'm using Netbeans 5.5.1

I need to use 2 classes, defined in 2 separate files, in a third, 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.

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 haw could this be done.

Thanks,

Dan

[586 byte] By [dcojocarua] at [2007-11-27 11:21:49]
# 1

You must be more specific if you need help.

Luana67a at 2007-7-29 14:51:17 > top of Java-index,Java Essentials,New To Java...
# 2

http://en.wikipedia.org/wiki/Model-view-controller

What you need is a controller. Let your gui classes do nothing but interact with the user and tell the controller class when they do something (like push the button on the second component). Then the controller gives the guis their updated data to display.

hunter9000a at 2007-7-29 14:51:17 > top of Java-index,Java Essentials,New To Java...
# 3

Do you know how to listen?

http://java.sun.com/docs/books/tutorial/uiswing/events/index.html

BigDaddyLoveHandlesa at 2007-7-29 14:51:17 > top of Java-index,Java Essentials,New To Java...