Today I studied Liaoliang's Scala learning lecture 70th, about Scala's interface programming, so let's take a preliminary look at the process of programming in Scala.
Information from DT Big Data Dream Factory public account: Dt_spark
Follow the account to learn more about the Liaoliang Teacher's course content
Teacher Wang qq:1740415547
No.: 18610086859
First of all, the interface programming in Scala is to encapsulate and improve the Java interface programming of the Swing library, of course, when we are using Scala interface programming, we should first introduce such a library, let us start from the code in combat.
Import Scala.swing._
Object Hello_gui extends simpleswingapplication{
def top = new mainframe{
title = "Hello GUI"
Contents = new button{
Text = "Scala = Spark!!!"
}
}
}
Simpleswingapplication defines some preliminary settings for the interface, which contains the main method, so in the above program, there is no main method, our program can also run.
The top method here is actually the simpleswingapplication of the top method, which is the type of frame.
Mainframe is a main framework of the method class, is an easy, containing elements such as title,contents, so we override the top method, set the corresponding components of the various properties:
title = "Hello GUI"
Contents = new button{
Text = "Scala = Spark!!!"
}
70th: Scala interface GUI programming practical explanation