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

Scala example source code file (Label.scala)

This example Scala source code file (Label.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

component, emptyicon, gui, icon, icon, int, int, jlabel, jlabel, label, string, string, supermixin, swing

The Scala Label.scala source code

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



package scala.swing

import javax.swing._
import scala.swing.Swing._

/**
 * A label component that display either a text, an icon, or both.
 *
 * @see javax.swing.JLabel
 */
class Label(text0: String, icon0: Icon, align: Alignment.Value) extends Component {
  override lazy val peer: JLabel = 
    new JLabel(text0, toNullIcon(icon0), align.id) with SuperMixin
  
  def this() = this("", EmptyIcon, Alignment.Center)
  def this(s: String) = this(s, EmptyIcon, Alignment.Center)
  def text: String = peer.getText
  def text_=(s: String) = peer.setText(s)
  def icon: Icon = peer.getIcon
  def icon_=(i: Icon) = peer.setIcon(i)
  
  /**
   * The alignment of the label's contents relative to its bounding box.
   */
  def xAlignment: Alignment.Value = Alignment(peer.getHorizontalAlignment)
  def xAlignment_=(x: Alignment.Value) { peer.setHorizontalAlignment(x.id) }
  def yAlignment: Alignment.Value = Alignment(peer.getVerticalAlignment)
  def yAlignment_=(x: Alignment.Value) { peer.setVerticalAlignment(x.id) }
  
  /** @see javax.swing.JLabel#getHorizontalAlignment() */
  def horizontalAlignment: Alignment.Value = Alignment(peer.getHorizontalAlignment)
  /** @see javax.swing.JLabel#setHorizontalAlignment() */
  def horizontalAlignment_=(x: Alignment.Value) { peer.setHorizontalAlignment(x.id) }

  def verticalAlignment: Alignment.Value = Alignment(peer.getVerticalAlignment)
  def verticalAlignment_=(x: Alignment.Value) { peer.setVerticalAlignment(x.id) }
     
  def horizontalTextPosition: Alignment.Value = Alignment(peer.getHorizontalTextPosition)
  def horizontalTextPosition_=(x: Alignment.Value) { peer.setHorizontalTextPosition(x.id) }
 
  def verticalTextPosition: Alignment.Value = Alignment(peer.getVerticalTextPosition)
  def verticalTextPosition_=(x: Alignment.Value) { peer.setVerticalTextPosition(x.id) }
     
  def disabledIcon: Icon = peer.getDisabledIcon
  def disabledIcon_=(icon: Icon) { peer.setDisabledIcon(icon) }
  
  def iconTextGap: Int = peer.getIconTextGap
  def iconTextGap_=(gap: Int) { peer.setIconTextGap(gap) }
  
  def displayedMnemonicIndex: Int = peer.getDisplayedMnemonicIndex
  def displayedMnemonicIndex_=(index: Int) { peer.setDisplayedMnemonicIndex(index) }
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala Label.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.