aspose file tools*
The moose likes Beginning Java and the fly likes Keeping gui and processing code seperate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Keeping gui and processing code seperate" Watch "Keeping gui and processing code seperate" New topic
Author

Keeping gui and processing code seperate

Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
I'm making a little Notepad clone in Swing. Actually, I made it awhile ago but I had a class for each action event by buttons would throw. Each of them were nested in the same class as the gui. I thought this was bad practice so I'm trying to move them into their own class. I keep getting a StackOverflowError when I try and run my app now. I didn't know how I should have the Controller class see the gui items from my Layout class, so I just extended it. From this error, I don't think that was correct. Can anyone help me out here?
Layout.java

Controller.java
Nicholas Turner
Ranch Hand

Joined: May 24, 2003
Posts: 126
do a stack trace
Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
If anybody would try and run this, that would be awesome! Here is the output I get:
Nicholas Turner
Ranch Hand

Joined: May 24, 2003
Posts: 126
The reason whi is your controller class.
WHy would you extned the layout class?
Your creating an action listener that executes some functions. make these methods and give a reference like COntainer parent; and add a set parent to them which you can probably reach some how
fix that and it will work. Your basically recursively creating both of the classes until your RAM runs out
Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
I knew why I was getting the error, I'm just not sure how to fix it. The goal of extending the Layout class was so the Controller class could perform it's functions. Are the events normally in the same class or what?
Nicholas Turner
Ranch Hand

Joined: May 24, 2003
Posts: 126
then create a layout class as a panel and keep al the other frame code separate
Nicholas Turner
Ranch Hand

Joined: May 24, 2003
Posts: 126
The problem is you are recursing everything
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Keeping gui and processing code seperate