added location and icon methods to Frame, implicit conversion for pairs to Dimension and Point

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@16483 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
imaier 2008-11-02 09:13:05 +00:00
parent 3af95caec5
commit d133cf5613
2 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package scala.swing
import java.awt.{Image, Point}
import javax.swing._
import event._
@ -34,6 +35,10 @@ class Frame extends UIElement with RootPanel with Publisher {
def menuBar_=(m: MenuBar) = peer.setJMenuBar(m.peer)
def setLocationRelativeTo(c: UIElement) { peer.setLocationRelativeTo(c.peer) }
def location_=(p: Point) { peer.setLocation(p) }
def iconImage: Image = peer.getIconImage
def iconImage_=(i: Image) { peer.setIconImage(i) }
peer.addWindowListener(new java.awt.event.WindowListener {
def windowActivated(e: java.awt.event.WindowEvent) { publish(WindowActivated(Frame.this)) }

View File

@ -2,7 +2,7 @@ package scala.swing
import java.awt.event._
import javax.swing.event._
import java.awt.{Color, Dimension}
import java.awt.{Color, Dimension, Point}
import javax.swing.border._
import javax.swing.{JComponent, Icon, BorderFactory}
@ -16,6 +16,12 @@ object Swing {
protected[swing] def toNoIcon(i: Icon): Icon = if(i == null) EmptyIcon else i
protected[swing] def toNullIcon(i: Icon): Icon = if(i == EmptyIcon) null else i
implicit def pair2Dimension(p: (Int, Int)): Dimension = new Dimension(p._1, p._2)
implicit def pair2Point(p: (Int, Int)): Point = new Point(p._1, p._2)
/**
* Allows one to use blocks as runnables.
*/
implicit def block2Runnable(block: =>Unit): Runnable = new Runnable {
override def run = block
}