-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3352e38
Showing
7 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> | ||
<classpathentry kind="con" path="at.bestsolution.efxclipse.tooling.jdt.core.JAVAFX_CONTAINER"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>JavaFXConcurrentSample</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.7 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
jfx.build.stagingdir = ${workspace}/JavaFXConcurrentSample/build | ||
jfx.build.apptitle = JavaFXConcurrentSample | ||
jfx.build.vendorname = mas0061.net | ||
jfx.build.appversion = 1.0 | ||
jfx.build.applicationClass = net.mas0061.javafx.sample.concurrent.ConcurrentSampleMain | ||
jfx.deploy.nativePackage = true |
89 changes: 89 additions & 0 deletions
89
src/net/mas0061/javafx/sample/concurrent/ConcurrentSampleControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package net.mas0061.javafx.sample.concurrent; | ||
|
||
import java.net.URL; | ||
import java.util.ResourceBundle; | ||
|
||
import javafx.concurrent.Task; | ||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.ProgressBar; | ||
import javafx.scene.control.ProgressIndicator; | ||
import javafx.scene.paint.Color; | ||
|
||
public class ConcurrentSampleControl implements Initializable { | ||
|
||
@FXML | ||
private Label msgLabel; | ||
@FXML | ||
private Button pushButton; | ||
@FXML | ||
private Button startButton; | ||
@FXML | ||
private Button stopButton; | ||
@FXML | ||
private ProgressBar sampleBar; | ||
@FXML | ||
private ProgressIndicator sampleIndicator; | ||
|
||
Task<Void> task; | ||
|
||
@Override | ||
public void initialize(URL arg0, ResourceBundle arg1) { | ||
msgLabel.setTextFill(Color.RED); | ||
msgLabel.setText("initialize."); | ||
} | ||
|
||
@FXML | ||
protected void start(ActionEvent event) { | ||
msgLabel.setTextFill(Color.BLACK); | ||
msgLabel.setText("start"); | ||
|
||
if (task == null || task.isCancelled()) { | ||
task = new Task<Void>() { | ||
@Override | ||
protected Void call() { | ||
try { | ||
for (double c = 1; c <= 100; c++) { | ||
if (isCancelled()) { break; } | ||
|
||
sampleBar.setProgress(c / 100); | ||
sampleIndicator.setProgress(c / 100); | ||
|
||
Thread.sleep(100); | ||
} | ||
} catch (InterruptedException e) { | ||
} | ||
|
||
return null; | ||
} | ||
@Override protected void cancelled() { | ||
super.cancelled(); | ||
updateMessage("Cancelled!"); | ||
} | ||
}; | ||
|
||
Thread thread = new Thread(task); | ||
thread.setDaemon(true); | ||
thread.start(); | ||
} | ||
} | ||
|
||
@FXML | ||
protected void stop(ActionEvent event) { | ||
if (task != null) { | ||
msgLabel.setTextFill(Color.BLACK); | ||
msgLabel.setText("stop"); | ||
task.cancel(); | ||
} | ||
} | ||
|
||
@FXML | ||
protected void push(ActionEvent event) { | ||
msgLabel.setTextFill(Color.BLACK); | ||
msgLabel.setText("push"); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/net/mas0061/javafx/sample/concurrent/ConcurrentSampleMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package net.mas0061.javafx.sample.concurrent; | ||
|
||
import java.io.IOException; | ||
|
||
import javafx.application.Application; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
|
||
public class ConcurrentSampleMain extends Application { | ||
|
||
@Override | ||
public void start(Stage primaryStage) throws IOException { | ||
primaryStage.setTitle("Concurrent sample"); | ||
Parent root = FXMLLoader.load(getClass().getResource("concurrent.fxml")); | ||
|
||
Scene scene = new Scene(root); | ||
primaryStage.setScene(scene); | ||
primaryStage.show(); | ||
} | ||
|
||
public static void main(String[] args) { | ||
launch(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import java.lang.*?> | ||
<?import javafx.scene.control.*?> | ||
<?import javafx.scene.layout.*?> | ||
<?import javafx.scene.layout.AnchorPane?> | ||
|
||
<AnchorPane prefHeight="206.0" prefWidth="427.0" xmlns:fx="http://javafx.com/fxml" fx:controller="net.mas0061.javafx.sample.concurrent.ConcurrentSampleControl"> | ||
<!-- TODO Add Nodes --> | ||
<children> | ||
<Button fx:id="pushButton" layoutX="277.0" layoutY="131.0" mnemonicParsing="false" onAction="#push" text="Push!" /> | ||
<ProgressBar fx:id="sampleBar" layoutX="52.0" layoutY="47.0" prefWidth="282.0" progress="0.0" /> | ||
<Label fx:id="msgLabel" layoutX="52.0" layoutY="92.0" prefWidth="282.0" /> | ||
<Button fx:id="startButton" layoutX="52.0" layoutY="131.0" mnemonicParsing="false" onAction="#start" text="Start" /> | ||
<ProgressIndicator fx:id="sampleIndicator" layoutX="352.0" layoutY="38.0" progress="0.0" /> | ||
<Button fx:id="stopButton" layoutX="121.0" layoutY="131.0" mnemonicParsing="false" onAction="#stop" text="Stop" /> | ||
</children> | ||
</AnchorPane> |