From 9fd5a2c05f6c88ed620723bcddcd23af9dd612d4 Mon Sep 17 00:00:00 2001 From: Dominik Gruntz Date: Wed, 1 Aug 2018 18:59:06 +0200 Subject: [PATCH 1/7] Declaration of final not necessary In this example the final declaration of final TextArea textArea = new TextArea(); is not necessary. --- .../controls-textarea/src/main/java/de/javafxbuch/MainApp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kapitel 4/4.2.4.1/controls-textarea/src/main/java/de/javafxbuch/MainApp.java b/Kapitel 4/4.2.4.1/controls-textarea/src/main/java/de/javafxbuch/MainApp.java index 345b3fa..32e281e 100644 --- a/Kapitel 4/4.2.4.1/controls-textarea/src/main/java/de/javafxbuch/MainApp.java +++ b/Kapitel 4/4.2.4.1/controls-textarea/src/main/java/de/javafxbuch/MainApp.java @@ -15,7 +15,7 @@ public static void main(String[] args) throws Exception { @Override public void start(Stage primaryStage) { - final TextArea textArea = new TextArea(); + TextArea textArea = new TextArea(); textArea.setPrefRowCount(10); textArea.setPrefColumnCount(20); textArea.setWrapText(true); From 31ddc6d74d7a646c98b374d8cf43b74cba5aa2ce Mon Sep 17 00:00:00 2001 From: Dominik Gruntz Date: Wed, 1 Aug 2018 20:20:00 +0200 Subject: [PATCH 2/7] removes final on local variable The final modifier is removed from the declaration final ContextMenu contextMenu = new ContextMenu(); Although this field is used in a lambda, the final property is inferred automatically by the compiler. --- .../src/main/java/de/javafxbuch/MainApp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kapitel 4/4.2.6/controls-contextmenu/src/main/java/de/javafxbuch/MainApp.java b/Kapitel 4/4.2.6/controls-contextmenu/src/main/java/de/javafxbuch/MainApp.java index d55f38a..d282748 100644 --- a/Kapitel 4/4.2.6/controls-contextmenu/src/main/java/de/javafxbuch/MainApp.java +++ b/Kapitel 4/4.2.6/controls-contextmenu/src/main/java/de/javafxbuch/MainApp.java @@ -31,7 +31,7 @@ public void start(Stage primaryStage) { root.setTop(menuBar); ImageView imageView = new ImageView(new Image(getClass().getResource("javaduke_html5.png").toExternalForm())); root.setCenter(imageView); - final ContextMenu contextMenu = new ContextMenu(); + ContextMenu contextMenu = new ContextMenu(); MenuItem halloMenuItem = new MenuItem("Sag 'Hallo'"); halloMenuItem.setOnAction( e -> System.out.println("Duke: 'Hallo!'")); From 7f115056a0e58492398d32541f090429fc853774 Mon Sep 17 00:00:00 2001 From: Dominik Gruntz Date: Fri, 3 Aug 2018 10:18:10 +0200 Subject: [PATCH 3/7] Removes final declaration The final modifier at the declaration of the two stack panes final StackPane stackPane = new StackPane(...); final StackPane stackPane1 = new StackPane(...); can be removed, the panes are not used in an anonymous class. --- .../src/main/java/de/javafxbuch/MainApp.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kapitel 4/4.3.4/controls-splitpane-resize/src/main/java/de/javafxbuch/MainApp.java b/Kapitel 4/4.3.4/controls-splitpane-resize/src/main/java/de/javafxbuch/MainApp.java index 4b4bf39..5559710 100644 --- a/Kapitel 4/4.3.4/controls-splitpane-resize/src/main/java/de/javafxbuch/MainApp.java +++ b/Kapitel 4/4.3.4/controls-splitpane-resize/src/main/java/de/javafxbuch/MainApp.java @@ -16,11 +16,11 @@ public static void main(String[] args) throws Exception { @Override public void start(Stage primaryStage) { SplitPane splitPane = new SplitPane(); - final StackPane stackPane = new StackPane(new Label("Hilfsfenster1")); + StackPane stackPane = new StackPane(new Label("Hilfsfenster1")); SplitPane.setResizableWithParent(stackPane, false); splitPane.getItems().add(stackPane); splitPane.getItems().add(new StackPane(new Label("Dokumentenfenster"))); - final StackPane stackPane1 = new StackPane(new Label("Hilfsfenster2")); + StackPane stackPane1 = new StackPane(new Label("Hilfsfenster2")); SplitPane.setResizableWithParent(stackPane1, false); splitPane.getItems().add(stackPane1); StackPane pane = new StackPane(splitPane); From c5e3817186367feb9d02a87cac0ebe272c8258d4 Mon Sep 17 00:00:00 2001 From: Dominik Gruntz Date: Fri, 3 Aug 2018 23:42:23 +0200 Subject: [PATCH 4/7] Removes final declaration it is not cecessary to declare the two fields CardStackLayout cardStackLayout = new CardStackLayout(); CardStackLayout cardStackLayout2 = new CardStackLayout(); as fnal. --- .../layout-custom/src/main/java/de/javafxbuch/MainApp.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kapitel 5/5.9/layout-custom/src/main/java/de/javafxbuch/MainApp.java b/Kapitel 5/5.9/layout-custom/src/main/java/de/javafxbuch/MainApp.java index 52a5f0e..aa68ca4 100644 --- a/Kapitel 5/5.9/layout-custom/src/main/java/de/javafxbuch/MainApp.java +++ b/Kapitel 5/5.9/layout-custom/src/main/java/de/javafxbuch/MainApp.java @@ -30,8 +30,8 @@ public void start(Stage primaryStage) throws URISyntaxException { String[] values = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "ace", "jack", "king", "queen"}; String[] colors = {"clubs", "diamonds", "hearts", "spades"}; EventHandler clickHandler; - final CardStackLayout cardStackLayout = new CardStackLayout(); - final CardStackLayout cardStackLayout2 = new CardStackLayout(); + CardStackLayout cardStackLayout = new CardStackLayout(); + CardStackLayout cardStackLayout2 = new CardStackLayout(); clickHandler = new EventHandler() { @Override From af3b41931abb04e80d3f3ae87cf5fa6b84fcd491 Mon Sep 17 00:00:00 2001 From: Dominik Gruntz Date: Sat, 4 Aug 2018 17:05:38 +0200 Subject: [PATCH 5/7] Removes final declaration Removes the final declaration from final HomeTimeline homeTimeline = new HomeTimeline(); This field is used in an action listener, but the final proeprty can be inferred. --- .../5.10/tweetalot/src/main/java/de/javafxbuch/MainApp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kapitel 5/5.10/tweetalot/src/main/java/de/javafxbuch/MainApp.java b/Kapitel 5/5.10/tweetalot/src/main/java/de/javafxbuch/MainApp.java index 3361883..8135e63 100644 --- a/Kapitel 5/5.10/tweetalot/src/main/java/de/javafxbuch/MainApp.java +++ b/Kapitel 5/5.10/tweetalot/src/main/java/de/javafxbuch/MainApp.java @@ -35,7 +35,7 @@ public void start(Stage stage) throws Exception { Button button = new Button("\uf015"); button.setFont(Font.font("FontAwesome", 40)); BorderPane root = new BorderPane(); - final HomeTimeline homeTimeline = new HomeTimeline(); + HomeTimeline homeTimeline = new HomeTimeline(); homeTimeline.refresh(); root.setCenter(homeTimeline); ToolBar toolBar = new ToolBar(); From 5b594541d9fd0324c4d202aed967736b07c7332c Mon Sep 17 00:00:00 2001 From: Dominik Gruntz Date: Sat, 4 Aug 2018 17:06:48 +0200 Subject: [PATCH 6/7] Adds final modifier Declares the toolbar as final as well, as all other fields in this class (except to the status field, as that one is created lazily). --- .../5.10/tweetalot/src/main/java/de/javafxbuch/StatusView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kapitel 5/5.10/tweetalot/src/main/java/de/javafxbuch/StatusView.java b/Kapitel 5/5.10/tweetalot/src/main/java/de/javafxbuch/StatusView.java index c836e4b..1229310 100644 --- a/Kapitel 5/5.10/tweetalot/src/main/java/de/javafxbuch/StatusView.java +++ b/Kapitel 5/5.10/tweetalot/src/main/java/de/javafxbuch/StatusView.java @@ -20,7 +20,7 @@ public class StatusView extends HBox { private final VBox textBox; private final Label screenName; private final Label statusText; - private VBox toolbar; + private final VBox toolbar; public StatusView() { setPadding(new Insets(4)); From 488bbdd9a09e28cce58ed35e332e9a48930fa45a Mon Sep 17 00:00:00 2001 From: Dominik Gruntz Date: Sun, 5 Aug 2018 22:59:18 +0200 Subject: [PATCH 7/7] Removes final modifiers Removes final modifiers from local variables where the compiler can derive the final proprty. --- .../9.2.2/task-simple/src/main/java/de/javafxbuch/MainApp.java | 2 +- .../9.4/tweetalot/src/main/java/de/javafxbuch/MainApp.java | 2 +- .../9.4/tweetalot/src/main/java/de/javafxbuch/StatusView.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Kapitel 9/9.2.2/task-simple/src/main/java/de/javafxbuch/MainApp.java b/Kapitel 9/9.2.2/task-simple/src/main/java/de/javafxbuch/MainApp.java index 27a32f4..d52775a 100644 --- a/Kapitel 9/9.2.2/task-simple/src/main/java/de/javafxbuch/MainApp.java +++ b/Kapitel 9/9.2.2/task-simple/src/main/java/de/javafxbuch/MainApp.java @@ -22,7 +22,7 @@ public static void main(String[] args) throws Exception { public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Run"); - final Task task = new Task() { + Task task = new Task() { @Override protected Integer call() throws Exception { int iterationen; diff --git a/Kapitel 9/9.4/tweetalot/src/main/java/de/javafxbuch/MainApp.java b/Kapitel 9/9.4/tweetalot/src/main/java/de/javafxbuch/MainApp.java index ac1a91a..1248295 100644 --- a/Kapitel 9/9.4/tweetalot/src/main/java/de/javafxbuch/MainApp.java +++ b/Kapitel 9/9.4/tweetalot/src/main/java/de/javafxbuch/MainApp.java @@ -26,7 +26,7 @@ public void start(Stage stage) throws Exception { button.getStyleClass().add("view-button"); button.setFont(Font.font("FontAwesome", 40)); BorderPane root = new BorderPane(); - final HomeTimeline homeTimeline = new HomeTimeline(); + HomeTimeline homeTimeline = new HomeTimeline(); // homeTimeline.refresh(); root.setCenter(homeTimeline); ToolBar toolBar = new ToolBar(); diff --git a/Kapitel 9/9.4/tweetalot/src/main/java/de/javafxbuch/StatusView.java b/Kapitel 9/9.4/tweetalot/src/main/java/de/javafxbuch/StatusView.java index c836e4b..1229310 100644 --- a/Kapitel 9/9.4/tweetalot/src/main/java/de/javafxbuch/StatusView.java +++ b/Kapitel 9/9.4/tweetalot/src/main/java/de/javafxbuch/StatusView.java @@ -20,7 +20,7 @@ public class StatusView extends HBox { private final VBox textBox; private final Label screenName; private final Label statusText; - private VBox toolbar; + private final VBox toolbar; public StatusView() { setPadding(new Insets(4));