Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > OutOfMemoryError with socket communication

Reply
Thread Tools

OutOfMemoryError with socket communication

 
 
jan V
Guest
Posts: n/a
 
      08-17-2005
> *******s.
>
> Dangerous *******s at that. Extending classes without need is pure
> incompetence.


I agree, but instead of standing on your soap box on Hyde Corner for half an
hour, you might have taken the trouble of suggesting that people should
subclass JComponent or JPanel instead. [Yes, I know, I've done plenty of
time on Hyde Corner myself - mea culpa]


 
Reply With Quote
 
 
 
 
Thomas Hawtin
Guest
Posts: n/a
 
      08-17-2005
jan V wrote:
>
> I agree, but instead of standing on your soap box on Hyde Corner for half an
> hour, you might have taken the trouble of suggesting that people should
> subclass JComponent or JPanel instead. [Yes, I know, I've done plenty of
> time on Hyde Corner myself - mea culpa]


You misunderstand. Not only am I suggesting that Thread and JFrame not
be extended (if no method is overriden/implemented, the class is not a
decorator, there isn't an overriding issue with class size, etc) I am
suggesting that largely applies to any class.

(BTW: the arguments for extending JPanel instead of JComponent are
largely bogus.)

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
Reply With Quote
 
 
 
 
jan V
Guest
Posts: n/a
 
      08-18-2005
> (BTW: the arguments for extending JPanel instead of JComponent are
> largely bogus.)


Bogus? What are you talking about?

Does Container.add(Component) look bogus to you? If you have to write an AWT
or Swing GUI, you'll have to subclass, I don't think you'll get very far
without subclassing classes that are several levels down from Object.


 
Reply With Quote
 
Thomas Hawtin
Guest
Posts: n/a
 
      08-18-2005
jan V wrote:
>>(BTW: the arguments for extending JPanel instead of JComponent are
>>largely bogus.)

>
>
> Bogus? What are you talking about?
>
> Does Container.add(Component) look bogus to you? If you have to write an AWT
> or Swing GUI, you'll have to subclass, I don't think you'll get very far
> without subclassing classes that are several levels down from Object.


Sorry, what on Earth are you talking about?!

JComponent extends Container too!!

What I'm talking about is the oft repeated advice to extend JPanel
instead of JComponent (who would have guessed it?). From the
comp.lang.java.gui FAQ (http://www.physci.org/guifaq.jsp#4.1):

"Q4.1 What is the equivalent of AWT's Canvas in Swing?

"JPanel, if you want to have a "complete" component with a UI delegate
which handles opaque settings (if paintComponent() is correctly
overridden)."

Unfortunately JPanel does not necessarily have opaque set on it. Without
any further set up on my machine:

[tackline@localhost janv]$ cat Opaque.java
import javax.swing.JPanel;
import javax.swing.UIManager;

class Opaque {
public static void main(String[] args) throws Throwable {

UIManager.setLookAndFeel(UIManager.getSystemLookAn dFeelClassName());
System.out.println(new JPanel().isOpaque());
}
}
[tackline@localhost janv]$ javac Opaque.java
[tackline@localhost janv]$ java Opaque
false

So, don't rely on what the PL&F for the particular JRE you are running
on your machine with your configuration does. Extend JPanel if you are
creating a panel and need to extend it (seems hideously unlikely to me).
If you genuinely are creating a new widget (say a tri-state 'toggle'
button), extend JComponent and go to all the bother of calling setOpaque
yourself.

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 1 02-03-2009 06:20 AM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Steve Holden Python 0 02-01-2009 12:45 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM



Advertisments