This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I think you did a good job . I would change three things:
Put the code in rubyframe.myframe into the constructor of Rubyframe.
Put the code in main into a instance method of Mainprog and create in main an instance.
Create the actionslisteners in mainprog instead of in myframe and use them as parameters in the Rubyframe constructor.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Joined: Jan 05, 2010
I'll have to go and do some reading on constructor(s) now haha
The code confuses me in the way you have used Listeners and how you are executing listener methods in your Mainprog class. Could you explain what you think this program should do?
Joined: Jan 05, 2010
Gregg Bolinger wrote:The code confuses me in the way you have used Listeners and how you are executing listener methods in your Mainprog class. Could you explain what you think this program should do?
No worries, I'll try
Please keep in mind that i'm only learning what I can via the 'net and a couple of Java books. Not to mention that I've only been mucking about with Java for around two weeks now. Now that I have my noob justification for crappy code out of the way here goes.
Assuming each class is a blueprint of a particular (re)usable action that I would like the application to perform.
1. I created a class for my the application interface. (Rubyframe.java)
2. I created a class to hold a actionlistener for a quit JButton belonging to the interface.(Leave.java)
3. I created another class to hold a second actionlistener for a JOptionPanel popup message.(Message.java)
4. I presumed that methods for these classes should be placed in the main Java file. (Mainprog.java)
I presumed that when Mainprog.java was executed the methods contained within were made available, which when called upon called the associated class into action.