Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > composition or inheritance for a jdialog

Reply
Thread Tools

composition or inheritance for a jdialog

 
 
-
Guest
Posts: n/a
 
      04-08-2005
i current have a subclass of JDialog that has only these two lines in
the constructor:

getRootPane().getInputMap(JComponent.WHEN_IN_FOCUS ED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
DISPOSE_ACTION_KEY);
getRootPane().getActionMap().put(DISPOSE_ACTION_KE Y,
new AbstractAction() {
public void actionPerformed(ActionEvent evt) {
dispose();
}
});


is it right to subclass it? or should i switch to composition?
 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      04-11-2005
- wrote:

> i current have a subclass of JDialog that has only these two lines in
> the constructor:
>
> getRootPane().getInputMap(JComponent.WHEN_IN_FOCUS ED_WINDOW).put(
> KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
> DISPOSE_ACTION_KEY);
> getRootPane().getActionMap().put(DISPOSE_ACTION_KE Y,
> new AbstractAction() {
> public void actionPerformed(ActionEvent evt) {
> dispose();
> }
> });
>
>
> is it right to subclass it? or should i switch to composition?


I try to avoid subclassing GUI components. There are sometimes good
reasons to do it, but the example you have presented does not exhibit one.

--
John Bollinger
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
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
Composition vs. inheritance Todd Java 22 04-26-2008 06:18 PM
Python Design Patterns - composition vs. inheritance snewman18@gmail.com Python 18 11-18-2007 05:43 PM
Composition versus Implementation Inheritance chsalvia@gmail.com C++ 8 07-29-2007 07:28 PM
inheritance and composition Gary Wessle C++ 3 11-17-2006 12:45 AM
C++ and Interfaces, Multiple Inheritance or Composition? Code4u C++ 9 05-13-2005 10:47 PM



Advertisments