summaryrefslogtreecommitdiff
path: root/src/swing/scala/swing/PasswordField.scala
blob: 4769759a0c2421c5e2470aee7e5f467cff4dd136 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package scala.swing

import javax.swing._
import java.awt.event._
import event._

/**
 * A password field, that displays a replacement character for each character in the password.
 *
 * @see javax.swing.JPasswordField
 */
class PasswordField(text0: String, columns0: Int) extends TextField(text0, columns0) {
  override lazy val peer: JPasswordField = new JPasswordField(text0, columns0)
  def this(text: String) = this(text, 0)
  def this(columns: Int) = this("", columns)
  def this() = this("")

  def echoChar: Char = peer.getEchoChar
  def echoChar_=(c: Char) = peer.setEchoChar(c)

  /**
   * The text property should not be used on a password field for
   * security reasons.
   */
  override def text: String = ""
  override def text_=(s: String) {}
  def password: Array[Char] = peer.getPassword
}