|
Red Squirrel Reflections
Dave Hoover explores the psychology of software development
|
|
Thu, 20 Jan 2005I need to thank Wilkes for providing me and my teammates with a hearty afternoon laugh. Or more specifically, I should thank Richard Mansfield and his take on object-oriented programming and reusability:"A frequent argument for OOP is it helps with code reusability, but one can reuse code without OOP--often by simply copying and pasting." Quote Manager Project -- Day 4 An ongoing pet project blog...I set up a project in IDEA. It's time to start hacking together some GUI code. The first task I am looking to complete is to simply add a new quote to the XML file. OK, so let's do some GUI work. Hopefully I will be able to write a test or two along the way... Here's what I'm starting with:
package com.redsquirrel.quotes.gui;
public class MAIN {
public static void main(String[] args) {
new QuoteManagerPanel();
}
}
IDEA tells me to Create Class 'QuoteManagerPanel', and I hit the magical ALT-ENTER combination.
And away we go!
Hack, hack, hack.
I've got something visible...
Here's the code that did it:
package com.redsquirrel.quotes.gui;
import javax.swing.JFrame;
public class MAIN {
private static final String TITLE = "Quote Manager";
public static void main(String[] args) {
JFrame frame = new JFrame(TITLE);
frame.getContentPane().add(new QuoteManagerPanel());
frame.pack();
frame.setVisible(true);
}
}
package com.redsquirrel.quotes.gui;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class QuoteManagerPanel extends JPanel {
public QuoteManagerPanel() {
add(new JLabel("Quote: "));
add(new JTextArea(3, 15));
}
}
Time to add all of the data field for a quote.
I won't bore you with anymore Swing code for a while.
It's gonna get ugly...
|