Re: Swing in different 2 threads
dimitrik107@hotmail.com wrote:
Thomas Hawtin wrote:
If you've got a class extending JFrame, you are probably extending
classes inappropriately. But apparently bad coding is fine for GUI
applications...
Thank you for answer it is more clear now. I don't understand this
point about extendin classed inappropriately? Most sample code for
Swing tutorial has class MyFrame extends JFrame {...} Are you saying
the tutorial code are probably extending classes inappropriately?
Yes.
See Effective Java, Item 14: Favor composition over inheritance.
Indeed almost all of the code should not be dependent on being in a
JFrame. There's two main motivations for this: Firstly, you want to keep
your code as simple as possible, so don't involve inheritance. A
secondary point is that you may want to move your JFrame contents to,
say, a JInternalFrame, a JDialog, a JSplitPane, a JApplet, a JFrame
subclassed for some genuine purpose, another layer of panels between
frame and your contents, or something you haven't thought of yet.
Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/