Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hello
- import scalafx.application.JFXApp
- import scalafx.application.JFXApp.PrimaryStage
- import scalafx.geometry.Insets
- import scalafx.scene.Scene
- import scalafx.scene.control.Button
- import scalafx.scene.effect.DropShadow
- import scalafx.scene.layout.HBox
- import scalafx.scene.paint.Color._
- import scalafx.scene.paint.{LinearGradient, Stops}
- import scalafx.scene.text.Text
- import scalafx.application.JFXApp
- import scalafx.application.JFXApp.PrimaryStage
- import scalafx.collections.ObservableBuffer
- import scalafx.geometry.Orientation
- import scalafx.scene.control.{ChoiceBox, ComboBox, Label, ListCell, ListView, RadioButton}
- import scalafx.scene.input.MouseEvent
- import scalafx.scene.{Cursor, Scene}
- import scalafx.scene.paint.Color
- import scalafx.Includes._
- import scalafx.beans.property.DoubleProperty
- import scalafx.event.ActionEvent
- //to download files
- import sys.process._
- import java.net.URL
- import java.io.File
- import scala.language.postfixOps
- //to use scrapper
- import net.ruippeixotog.scalascraper.browser.JsoupBrowser
- import net.ruippeixotog.scalascraper.model._
- import net.ruippeixotog.scalascraper.dsl.DSL._
- import net.ruippeixotog.scalascraper.dsl.DSL.Extract._
- import net.ruippeixotog.scalascraper.dsl.DSL.Parse._
- object Html {
- def fileDownloaderMusic(url: String, filename: String) = {
- new URL(url) #> new File(filename) !!
- }
- def fileDownloaderHtml(url: String, filename: String) = {
- new URL(url) #> new File(filename) !!
- }
- }
- object Scraper {
- def test() = {
- val browser = JsoupBrowser()
- // val doc = browser.parseFile("./example.html")
- // val doc2 = browser.get("http://example.com")
- // print(doc)
- // val header = doc >> text("#header")
- // print("\nheader :\n" + header)
- // val items = doc >> elementList("#menu span")
- //// val items = doc >> text("#menu")
- // print("\nitems: " + items)
- val doc = browser.parseFile("./jedynka.html")
- // val doc2 = browser.get("http://example.com")
- // print(doc)
- val header = doc >> text("#ajax-wrap-body")
- print("\nheader :\n" + header)
- // val items = doc >> elementList("#menu span")
- // val items = doc >> text("#menu")
- // print("\nitems: " + items)
- }
- }
- object Hello extends JFXApp {
- val Wed_songs: List[String] = List("Hello", "World", "Enjoy","a","b","c","d","e","f")
- val Pon_songs: List[String] = List("POniedzialek", "fajny", "jest","o")
- val Wt_songs: List[String] = List("Wtorek", "zamknij", "rozporek","lol")
- var selected_song = 2 //??
- var selected_day = 2
- stage = new PrimaryStage {
- title = "ListViewExample"
- scene = new Scene(800,600) {
- val label = new Label("Feedback")
- label.layoutX = 20
- label.layoutY = 20
- var listView_songs = new ListView(List("Maryla","Jozin z Bazin"))
- listView_songs.layoutX = 500
- listView_songs.layoutY = 50
- fill = LightBlue
- val button_play = new Button("Play")
- button_play.layoutX = 20
- button_play.layoutY = 300
- val comboBox_day = new ComboBox(List("Pon","Wt","Sr"))
- comboBox_day.layoutX = 20
- comboBox_day.layoutY = 50
- val button_select_day = new Button("Select Day")
- button_select_day.layoutX = 100
- button_select_day.layoutY = 50
- button_select_day.onAction = (e: ActionEvent) =>{
- val action = comboBox_day.selectionModel.apply.getSelectedItem
- listView_songs.items = new ObservableBuffer[String]()
- if("Sr" == action){
- for(i <- Wed_songs) {
- listView_songs.items.apply += i
- }
- }
- else if("Pon" == action){
- for(i <- Pon_songs) {
- listView_songs.items.apply += i
- }
- }else if("Wt" == action){
- for(i <- Wt_songs) {
- listView_songs.items.apply += i
- }
- }
- else {
- println(comboBox_day.selectionModel.apply.getSelectedItem.getClass)
- println(comboBox_day.selectionModel.apply.getSelectedItem)
- listView_songs.items.apply += comboBox_day.selectionModel.apply.getSelectedItem
- }
- }
- button_play.onAction = (e: ActionEvent) => {
- val selected = listView_songs.selectionModel.apply.getSelectedItems
- println("GRA:"+selected)
- }
- content = List(label,comboBox_day,listView_songs,button_play,button_select_day)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement