Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By doWhile

Thread: How does a jframe communicate with other classes

  1. #1
    nino23 is offline Member
    Join Date
    Jun 2011
    Rep Power

    Default How does a jframe communicate with other classes

    Hello people, sorry for my bad english and for my question that can be very dumb. But how does the frame communicate with other casses?
    Ok, my situation is the follow, i have a main class that contains :
    1- a array of class 'employees' and
    2- two 'frames' ( 'startscreen' and 'addemployee' screen)

    My intention is:
    1- in main class run the main frame ( asking if u want to add employees) then
    2- in addemployee, to grab data from the textfield of the created frame to create personalized employees and add them to the array of the main class when someone press the jbutton.

    My doubt is how will be the communication.
    What must i do?
    I call the second frame inside the first one? But if i do this, how will it communicate with the main screen?

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Rep Power


    Pass a reference (or references) of one Object to another - in your case you could pass a reference of the first frame to the second frame - then the second object has access to the public methods of the first.

    Java Code:
    public class ClassA{
        public void saySomething(){
    public class ClassB{
        private ClassA ca;
        public ClassB(ClassA ca){
   = ca;
    Fubarable likes this.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

Similar Threads

  1. communicate with xml-rpc
    By tah_206207 in forum New To Java
    Replies: 2
    Last Post: 04-18-2011, 09:14 PM
  2. trying to communicate between classes
    By rippon in forum New To Java
    Replies: 8
    Last Post: 02-10-2011, 12:20 AM
  3. Communicate JFrame with JDialog
    By BeRniTo in forum AWT / Swing
    Replies: 2
    Last Post: 08-31-2009, 02:07 PM
  4. JFrame and two JPanel Classes
    By YellowPainting in forum AWT / Swing
    Replies: 9
    Last Post: 08-25-2009, 12:49 PM
  5. Communicate vb.NET with Java
    By cachi in forum Advanced Java
    Replies: 1
    Last Post: 08-02-2007, 12:41 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