alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (PasswordField.scala)

This example Scala source code file (PasswordField.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

array, awt, char, char, event, gui, int, int, jpasswordfield, jpasswordfield, passwordfield, string, string, supermixin, swing, textfield

The Scala PasswordField.scala source code

/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2007-2011, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */



package scala.swing

import event._
import javax.swing._
import java.awt.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) with SuperMixin
  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
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala PasswordField.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.