473,471 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Talking to different forms and passing information

2 New Member
Hi all

I am using netbeans to make my hci.

now in my form1 i have a button that when pressed takes me to form2 (class2) on form2 i want to press a button to change the color of button in form 1. as well as this i want to pass information between the two forms.

can any one help


thankyou in advance

LBALAL
Mar 14 '07 #1
8 1960
r035198x
13,262 MVP
Hi all

I am using netbeans to make my hci.

now in my form1 i have a button that when pressed takes me to form2 (class2) on form2 i want to press a button to change the color of button in form 1. as well as this i want to pass information between the two forms.

can any one help


thankyou in advance

LBALAL
What are your forms? Are they JFrames?

You can pass information between objects of different classes by passing one of the objects to the constructor of the other object's class.
e.g
Expand|Select|Wrap|Line Numbers
  1.  class A { 
  2. }
  3.  
  4. class B {
  5.  B(A a) {
  6.     a.setColor(Color.red);
  7.   }
  8. }
  9.  
Mar 15 '07 #2
hirak1984
316 Contributor
it is not that tough if you use jsp.even let us know if you are using swing.
Hi all

I am using netbeans to make my hci.

now in my form1 i have a button that when pressed takes me to form2 (class2) on form2 i want to press a button to change the color of button in form 1. as well as this i want to pass information between the two forms.

can any one help


thankyou in advance

LBALAL
Mar 15 '07 #3
lBalal
2 New Member
hi I am using Swing
Mar 15 '07 #4
r035198x
13,262 MVP
hi I am using Swing
Did you understand the idea I gave you?
Mar 15 '07 #5
N002199B
41 New Member
What are your forms? Are they JFrames?

You can pass information between objects of different classes by passing one of the objects to the constructor of the other object's class.
e.g
Expand|Select|Wrap|Line Numbers
  1.  class A { 
  2. }
  3.  
  4. class B {
  5.  B(A a) {
  6.     a.setColor(Color.red);
  7.   }
  8. }
  9.  
That's interesting to note. I suppose by so doing you will be forced to create a constructor with that signature.... ie that takes arguments of type 'class A'.

That should be tha only way we can get class A's member values into an instace of class B. Am I right?
Mar 15 '07 #6
r035198x
13,262 MVP
That's interesting to note. I suppose by so doing you will be forced to create a constructor with that signature.... ie that takes arguments of type 'class A'.

That should be tha only way we can get class A's member values into an instace of class B. Am I right?
Another way Aib, would be to pass the object to a method
Expand|Select|Wrap|Line Numbers
  1.  class A { 
  2. }
  3. class B {
  4.  void b(A a) {
  5.    a.setColor();
  6.   }
  7. }
  8.  
There are implications of course and which approach to take depends on the design of your classes.
Mar 15 '07 #7
N002199B
41 New Member
Another way Aib, would be to pass the object to a method
Expand|Select|Wrap|Line Numbers
  1.  class A { 
  2. }
  3. class B {
  4.  void b(A a) {
  5.    a.setColor();
  6.   }
  7. }
  8.  
There are implications of course and which approach to take depends on the design of your classes.
U kno wat "V....",
that is possible very much. However, then it would require the class design to have an instance of class A to be declared within class B for it to be in the scope of class B. ..........or else........

the method being used to receive the class A object has to made public like:
Expand|Select|Wrap|Line Numbers
  1. public void b(A a) {
and have instaces of class B and A in another class to communicate.

In the case of the matter at hand, of buttons and forms being passed about, the second method would be more appropriate
Mar 15 '07 #8
r035198x
13,262 MVP
U kno wat "V....",
that is possible very much. However, then it would require the class design to have an instance of class A to be declared within class B for it to be in the scope of class B. ..........or else........

the method being used to receive the class A object has to made public like:
Expand|Select|Wrap|Line Numbers
  1. public void b(A a) {
and have instaces of class B and A in another class to communicate.

In the case of the matter at hand, of buttons and forms being passed about, the second method would be more appropriate
You're probably right.


Notice that

Expand|Select|Wrap|Line Numbers
  1.  class A{ 
  2.    A(B b) {
  3.    }
  4. }
  5.  
  6. class B {
  7.   B(A a) {
  8.   }
  9. }
  10.  
====> Chicken and Egg situation.
Mar 15 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bryan | last post by:
I have this function below function checkLength(field, nextField) { var letters = document.form1.elements.value.length +1; if (letters <= 2) {document.form1.elements.focus()} else...
7
by: Tim Chmielewski | last post by:
The following page is a test for a form that is meant to accept extra order information for certain products: http://www.humanedge.biz/tim/testtotals.htm The extra field at the bottom is meant...
7
by: Paolo | last post by:
I know I should not be doing this, but I find it very useful. I have a database in Access which stores data for a small company. Sometimes we need to add similar information to different tables....
1
by: MattBell | last post by:
I'm trying to force a user to be authorized in forms authentication by extending the login control class and overriding the OnAuthorize function. I set my eventArgs.Authorized = true but I'm not...
1
by: TheSailor | last post by:
Forgive me - I am a bit new to cURL and passing form elements from one site to the next... If you can help with a HOW TO or by holding my hand a bit with examples - so I can learn - I would be in...
13
by: anil.rita | last post by:
When the user chooses an AV file to play, based upon the type of file, I want to use the default installed media player to play it. I am wondering if this is a good way - any alternatives,...
1
by: Pumpkin Carver | last post by:
I have a form that has a listview on it and a serious of strings in the listiew. When i doubel click on the listview item it opens a new form and displays the text that i pass to the constructor....
3
by: Bazza | last post by:
Hiya, New to VB.NET so this is probably a fairly easy solution(?!?!) I have an application which currently uses singleton forms. Great - everything worked fine except the users now want the...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.