<AWT Dev> [PATCH] Cleanup AWT peer interfaces

Roman Kennke roman.kennke at aicas.com
Tue Sep 16 02:45:33 PDT 2008


Hi Artem,

> AWT peer interfaces are really not a part of specification and can be 
> changed at any moment, so we/you shouldn't bother about backwards 
> compatibility. That's why I consider this suggested cleanup valuable.
> 
> Could you provide some more details about what methods and interfaces 
> are changed/removed, please?

Sure:

ChoicePeer.addItem()             removed, use add() instead.
ComponentPeer.enable()           removed, use setEnabled() instead.
ComponentPeer.disable()          removed, use setEnabled() instead.
ComponentPeer.show()             removed, use setVisible() instead.
ComponentPeer.hide()             removed, use setVisible() instead.
ComponentPeer.preferredSize()    removed, use getPreferredSize().
ComponentPeer.minimumSize()      removed, use getMinimumSize().
ContainerPeer.insets()           removed, use getInsets() instead.
ListPeer.addItem()               removed, use add() instead.
ListPeer.clear()                 removed, use removeAll() instead.
ListPeer.setMultipleSelections() removed, use setMultipleMode().
ListPeer.preferredSize(int)      removed, use getPreferredSize(int).
ListPeer.minimumSize(int)        removed, use getMinimumSize(int).
MenuItemPeer.enable()            removed, use setEnabled() instead.
MenuItemPeer.disable()           removed, use setEnabled() instead.
TextAreaPeer.insertText()        removed, use insert() instead.
TextAreaPeer.replaceText()       removed, use replaceRange().
TextAreaPeer.preferredSize(..)   removed, use getPreferredSize(..).
TextAreaPeer.minimumSize(..)     removed, use getMinimumSize(..).
TextFieldPeer.setEchoCharacter() removed, use setEchoChar().
TextFieldPeer.preferredSize(..)  removed, use getPreferredSize(..).
TextFieldPeer.minimumSize(..)    removed, use getMinimumSize(..).

Removed, because not used (anymore?) by AWT:
ComponentPeer.repaint()
ComponentPeer.getBounds()
ComponentPeer.reshape()
ContainerPeer.isPaintPending()
TextComponentPeer.getIndexAtPoint()
TextComponentPeer.getCharacterBounds()
TextComponentPeer.filterEvents()
WindowPeer.requestWindowFocus()

Hope this helps,
/Roman

> 
> Thanks,
> 
> Artem
> 
> Roman Kennke wrote:
> > Hello,
> > 
> > The peer interfaces have a lot of duplicate methods, where one is
> > deprecated and 'replaced' by a new one (for example, preferredSize() and
> > getPreferredSize() ). I see that this makes sense for public API
> > _classes_ to maintain backward compatibility, but it does _not_ make
> > sense for interfaces. It only confuses those who have to implement those
> > interfaces (which method should I implement? Which one is called, and
> > which should call which?), and adds no value at all. Also: the new
> > interface methods are not used (i.e. called by AWT) at all. As part of
> > the Caciocavallo project I went through this stuff and removed the
> > duplicates, leaving the new methods in the interfaces and made AWT call
> > the new methods instead. There were also a couple of methods that are
> > never called from AWT (like ComponentPeer.repaint() ), which I also
> > removed (some of such methods are used, but only in the interface
> > implementation, so it is not required to have them in the public
> > interface). What do you think? Should this be merged into main JDK7?
> > 
> > Cheers, Roman
> > 
> > 
-- 
Dipl.-Inform. (FH) Roman Kennke, Software Engineer, http://kennke.org
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-48
USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe
Geschäftsführer: Dr. James J. Hunt




More information about the awt-dev mailing list