4

I am writing a sample application with Sakila Sample Database for some experience. I am using eclipse/windowsbuilder for GUI. I have 3 class; VALIDATION to check component values, CONNECTOR to complete SQL queries and MAIN class which one has components. My problem is, I can not access components from another class. All of them in the same package access modifiers public for the classes.

I have tried below one;

 public class Connector{

    MovieDB mdb;

    public Connector(MovieDB m){

        mdb = m;
    }
 }

 public class MovieDB extends JFrame {

    Connector db = new Connector(this);
 }

But still I can not access components and I m in depression pls help:)

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
HRgiger
  • 2,750
  • 26
  • 37
  • 4
    GUI inter-object communication is the same as inter object communication for any other non-GUI program, often using design patterns if need be. For example: [sending-messages-between-two-jpanel-objects](http://stackoverflow.com/questions/7053283/sending-messages-between-two-jpanel-objects/7054114#7054114) – Hovercraft Full Of Eels Aug 15 '11 at 19:48
  • Nice example [schema](http://dev.mysql.com/doc/sakila/en/images/sakila-schema.png). – trashgod Aug 15 '11 at 19:51
  • Thank you Hovercraft solution was simple, I just needed to access variables so I took below part from your code block; public String getNorthFieldText() { return northField.getText(); } – HRgiger Aug 15 '11 at 20:57

1 Answers1

2

Check the access modifier of the components and verify that they are not private.

Perception
  • 79,279
  • 19
  • 185
  • 195
Anil Olakkal
  • 3,734
  • 2
  • 17
  • 17