user2202767
user2202767

Reputation: 15

Sending/Creating An Object To/In A Separate Class in Java

How might I use a method inside one class to create an object in a separate class?

IE: I have a class extending JFrame with an ActionListener inside it. On button click, the ActionListener should then create an object within the Main class rather than the JFrame class. Is this possible? If so, how is this accomplished?

Upvotes: 0

Views: 48

Answers (1)

Ankit
Ankit

Reputation: 6622

create a static method in main class (or if u have access to object of main class in jframe even a instance method would do), that creates the object of that class. and then call it from your action listener.

Upvotes: 1

Related Questions