Projekat

Općenito

Profil

Prijedlozi #19688 » Hello.scala

pivot example - Ernad Husremović, 16.02.2010 18:39

 
import java.awt.Color;
import java.awt.Font;
import org.apache.pivot.collections.Map;
import org.apache.pivot.wtk._;
/*
import org.apache.pivot.wtk.Alert;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.HorizontalAlignment;
import org.apache.pivot.wtk.Label;
import org.apache.pivot.wtk.PushButton;
import org.apache.pivot.wtk.ButtonPressListener;
import org.apache.pivot.wtk.VerticalAlignment;
import org.apache.pivot.wtk.Window;
import org.apache.pivot.wtk.Application;
*/
import org.apache.pivot.wtkx.WTKXSerializer;


class HelloJava extends org.apache.pivot.wtk.Application {
private var window:Window = null
def startup(display:Display, properties:Map[String, String]) = {
val wtkx = new WTKXSerializer()
val window: Window = wtkx.readObject(this, "form.wtkx").asInstanceOf[Window]
val push_button = wtkx.get("pushButton").asInstanceOf[PushButton]

push_button.getButtonPressListeners().add(new ButtonPressListener() {
def buttonPressed(button: Button) {
Alert.alert(MessageType.ERROR, "You clicked me đŠđpšđšđ!", window)
}
})
val label = new Label()
label.setText("Hello World xxx !")
label.getStyles().put("font", new Font("Arial", Font.BOLD, 24))
label.getStyles().put("color", Color.GREEN)
label.getStyles().put("horizontalAlignment",
HorizontalAlignment.CENTER)
label.getStyles().put("verticalAlignment",
VerticalAlignment.CENTER)
//window = new Window()
val component = window.getContent()
//content.add(label)
window.setContent(component)
window.setTitle("Hello World!")
window.setMaximized(true)
window.open(display)
}
def shutdown(optional:Boolean):Boolean = {
if (window != null) {window.close}
return false;
}
def suspend():Unit = {}
def resume():Unit = {}
}
object App {
def main(args: Array[String]) = {
DesktopApplicationContext.main(classOf[HelloJava], args)
}
}
(1-1/5)