Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can anyone answer this question asap, please? I need those to be done with JavaF

ID: 3756812 • Letter: C

Question

Can anyone answer this question asap, please? I need those to be done with JavaFX library only, thank you!

Homework Topics: When you have an activity that requires the behavior of threading, you have a choice of which type of threading you want to use. This homework provides practice for three different types of threading behaviors: Threads/Runnable, and the Timer classes from avax.swing and java.util packages. This homework also includes: Changing label fonts via HTML or Java classes, File I/O, Color class, JProgressBar, anonymous inner classes, Date class, SimpleDateFormat class, Thread's sleep0 method and possibly arrays. Problem Statement: Duplicate the following display and behavior using the three different threading techniques specified in this assignment. When the program is started it presents (1) the date/time in format shown, (2) a rainbow of colors (ROYGBIV), and (3) at least two progress bars at the bottom of the screen. The three different behaviors are controlled by three different threading controls as specified for each. Timer Fun File Help Mon 13 Aug 2018 08:47:01 Words progress: Opening Words.. Unabridged progress: Opening Unabridged.

Explanation / Answer

package demos.sevenguis.timer

import kotlinfx.builders.*

import kotlinfx.properties.*

import kotlinfx.bindings.*

import kotlinfx.abbreviations.*

import javafx.application.Application

import javafx.stage.Stage

import javafx.beans.property.SimpleDoubleProperty

import javafx.animation.Timeline

import javafx.animation.KeyFrame

import javafx.util.Duration

import javafx.event.ActionEvent

import javafx.event.EventHandler

import javafx.animation.Animation

import javafx.beans.binding.Bindings

import java.util.concurrent.Callable

fun main(args: Array<String>) {

Application.launch(javaClass<Timer>())

}

class Timer : Application() {

override fun start(stage: Stage?) {

val progress = ProgressBar()

val numericProgress = Label()

val slider = Slider(min=1.0, max=400.0, value=200.0)

val reset = Button("Reset")

val elapsed = SimpleDoubleProperty(0.0)

progress.progressp bind (elapsed / slider.valuep)

// TODO: closure instead of callable

numericProgress.textp bind Bindings.createStringBinding(object : Callable<String> { override fun call(): String? =

formatElapsed(elapsed.v)

}, elapsed)

reset.setOnAction { elapsed.v = 0.0 }

// TODO: Why can't I use closure syntax here?

val timeline = Timeline(KeyFrame(Duration.millis(100.0), object : EventHandler<ActionEvent> {

override fun handle(event: ActionEvent?) {

if (elapsed.v < slider.getValue()) elapsed.set(elapsed.v + 1)

}

}))

timeline.setCycleCount(Animation.INDEFINITE) // TODO: Why not Timeline.INDEFINITE?

timeline.play()

Stage(stage, title = "Timer") {

scene = Scene {

root = VBox(spacing=10.0, padding=Insets(10.0)) {

+ HBox(10.0) { + Label("Elapsed Time: ") + progress }

+ numericProgress

+ HBox(10.0) { + Label("Duration: ") + slider }

+ reset

}

}

}.show()

}

}

fun formatElapsed(elapsed: Double): String {

val seconds = Math.floor(elapsed / 10.0)

val dezipart = elapsed % 10

return "${seconds.toInt()}.${dezipart.toInt()}s"

}