Reputation: 15
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
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