Skip to content
Snippets Groups Projects
Commit df125ba6 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

removed start button (combined into stop button)

parent dd50a36e
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ public class Main extends Application
FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("de/deadlocker8/loadingbar/ui/GUI.fxml"));
Parent root = (Parent)loader.load();
Scene scene = new Scene(root, 600, 600);
Scene scene = new Scene(root, 600, 500);
((Controller)loader.getController()).init(stage);
......
......@@ -37,6 +37,7 @@ public class Controller
private int targetPercentage;
private boolean swapped;
private final String BACKGROUND_COLOR = "#333333";
private boolean running;
public void init(Stage stage)
{
......@@ -50,9 +51,11 @@ public class Controller
labelUser.setStyle("-fx-text-fill: white; -fx-font-size: 30; -fx-font-weight: bold;");
labelMessage.setStyle("-fx-text-fill: white; -fx-font-size: 30; -fx-font-weight: bold;");
buttonStop.setStyle("-fx-background-color: transparent; -fx-border-color: white; -fx-border-width: 3; -fx-border-radius: 0; -fx-text-fill: white;");
buttonStop.setText("START");
}
public void buttonStart()
public void start()
{
if(swapped)
{
......@@ -60,8 +63,11 @@ public class Controller
swapped = false;
}
running = true;
buttonStop.setText("STOP");
Random random = new Random();
targetPercentage = 15 + random.nextInt(90 - 15 + 1);
targetPercentage = 20 + random.nextInt(90 - 20 + 1);
labelTarget.setText(String.valueOf(targetPercentage));
labelUser.setText("");
labelMessage.setText("");
......@@ -73,9 +79,16 @@ public class Controller
}
public void buttonStop()
{
if(running)
{
stop(timer.stop());
}
else
{
start();
}
}
public void updateProgress(double value)
{
......@@ -91,6 +104,9 @@ public class Controller
public void stop(double value)
{
running = false;
buttonStop.setText("START");
int userPercentage = (int)(value * 100);
labelUser.setText(String.valueOf(userPercentage));
progressBar.setProgress(userPercentage / 100.0);
......
......@@ -63,7 +63,6 @@ public class CountdownTimer
timer.cancel();
timer.purge();
return time / count;
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="mainPane" prefHeight="400.0" prefWidth="400.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.deadlocker8.loadingbar.ui.Controller">
<AnchorPane fx:id="mainPane" prefHeight="450.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.deadlocker8.loadingbar.ui.Controller">
<children>
<VBox alignment="TOP_CENTER" layoutX="25.0" layoutY="16.0" prefHeight="363.0" prefWidth="350.0" AnchorPane.bottomAnchor="25.0" AnchorPane.leftAnchor="25.0" AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="25.0">
<children>
......@@ -53,17 +53,12 @@
</Label>
<Button fx:id="buttonStop" mnemonicParsing="false" onAction="#buttonStop" text="STOP">
<VBox.margin>
<Insets top="20.0" />
<Insets top="40.0" />
</VBox.margin>
<font>
<Font name="System Bold" size="24.0" />
</font>
</Button>
<Button mnemonicParsing="false" onAction="#buttonStart" text="Start">
<VBox.margin>
<Insets top="50.0" />
</VBox.margin>
</Button>
</children>
</VBox>
</children>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment