- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Why doesn't FormattedTextField extend TextField?
Sat, 2010-09-04, 07:38
Why doesn't scala.swing.FormattedTextField extend scala.swing.TextField?
I can't see any reason for this. A FormattedTextField conceptually is
also a TextField, and javax.swing.JFormattedTextField does extend
javax.swing.JTextField. Moreover, some properties are missing from
scala.swing.FormattedTextField, like 'columns' and
'horizontalAlignment', so I have to call into the peer in order to use
them.
By the way, I noticed that, for the properties where
scala.swing.TextField takes a function and wraps it in one of Java
Swing's interfaces (like InputVerifier), scala.swing.TextField is both
wrapping the function in a Java Swing interface in the setter method AND
wrapping the Java Swing interface with a function in the getter method.
This appears to have an unpleasant potential for wasting memory.