Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
55fcd3b
JavaFX tutorials 1 through 3, branch teamwork
ivyrodriguez Jul 2, 2016
cfc3fe3
JavaFX tutorials 1 through 3, branch teamwork
ivyrodriguez Jul 2, 2016
d06cb7b
Merge branch 'teamwork' of https://github.com/OpenSourceJavaProject/J…
ivyrodriguez Jul 2, 2016
3985bb0
Tutorial 1, creating a basic window added
RonyAlvarez Jul 3, 2016
895b841
Tutorial 2, handling user events added
RonyAlvarez Jul 3, 2016
449aac1
JavaFX Tutorials
Jul 4, 2016
9020219
Merge branch 'teamwork' of https://github.com/OpenSourceJavaProject/J…
Jul 4, 2016
bc886fe
Added 4 FX Tutorials - Clossing Windows Properly, Communication Betwe…
kazoo135 Jul 5, 2016
3b1309c
Tutorials 4 through 6
ivyrodriguez Jul 6, 2016
d52884c
Merge branch 'teamwork' of https://github.com/OpenSourceJavaProject/J…
ivyrodriguez Jul 6, 2016
e27fbde
Added FX Tutorial Extracting and Validating Input
kazoo135 Jul 6, 2016
e34213f
Merge branch 'teamwork' of https://github.com/OpenSourceJavaProject/J…
kazoo135 Jul 6, 2016
4040e00
Added two FX Tutorials - CheckBox and ChoiceBox
kazoo135 Jul 6, 2016
189fd3b
Added two FX Tutorials, ComboBox and TreeView
kazoo135 Jul 7, 2016
94571ae
Added two FX Studies Tutorials. Completed ListView Tutorial, conflate…
kazoo135 Jul 9, 2016
c08a47d
Finished JavaFX Tutorial
Jul 11, 2016
8b0f0ae
Added FX_Menus project which contains all tutorials related to build …
kazoo135 Jul 11, 2016
4a23c37
Merge branch 'teamwork' of https://github.com/OpenSourceJavaProject/J…
kazoo135 Jul 11, 2016
17c3b1c
Tutorials 7-9
ivyrodriguez Jul 11, 2016
076fb56
Tutorials 10-12
ivyrodriguez Jul 13, 2016
20e4bfa
first test on JavaFxStudies, branch teamwork
Chent03 Jul 13, 2016
992f732
Added FX Tutorial - working with CSS
kazoo135 Jul 14, 2016
1e79c74
Added FX Tutorial on working with Properties of objects
kazoo135 Jul 14, 2016
119be31
Added FX Tutorial on Binding Properties
kazoo135 Jul 14, 2016
d537b34
Add two FXML tutorials. Basci FXML example and one demonstrating Bin…
kazoo135 Jul 14, 2016
289a422
Added FX Tutorial 35. Working with Scene Builder
kazoo135 Jul 14, 2016
8a89dd8
Added tutorials 4 and 5
RonyAlvarez Jul 15, 2016
8c486d7
Added tutorial 5
RonyAlvarez Jul 15, 2016
5ce488b
JavaFxTutorials
Chent03 Jul 17, 2016
fce1d1a
others
Chent03 Jul 17, 2016
2d82118
Added tutorials 6 to 18
RonyAlvarez Jul 18, 2016
4aa526c
Added tutorials 19 and 20
RonyAlvarez Jul 18, 2016
da5ff1f
Tutorials 13-16
ivyrodriguez Jul 18, 2016
6d9eb33
Added tutorials 21 to 24
RonyAlvarez Jul 18, 2016
4bc515c
Merge branch 'teamwork' of https://github.com/OpenSourceJavaProject/J…
RonyAlvarez Jul 18, 2016
8864292
Added tutorials 24 to 27
RonyAlvarez Jul 18, 2016
fe34f1e
Added tutorials 28 to 30
RonyAlvarez Jul 19, 2016
28e4a0f
Tutorials 17 - 20
ivyrodriguez Jul 19, 2016
95635ba
Added FXML tutorials
RonyAlvarez Jul 19, 2016
171c5db
Tutorials 21-30
ivyrodriguez Jul 20, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tutorials 13-16
  • Loading branch information
ivyrodriguez committed Jul 18, 2016
commit da5ff1fd301fb0c592480404bf2f23183bcc9edf
65 changes: 65 additions & 0 deletions ivyrodriguez/Main13.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package JavaFXDemo;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ChoiceBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;


public class Main13 extends Application {
//Application is the class that inherits all the functionality

Stage window;
Scene scene;
Button button;

public static void main(String[] args) {
launch(args);
//launch(args) is a method that is called once the main program starts and goes inside the application class
//it sets ups your javafx application
}

@Override
public void start(Stage primaryStage) throws Exception {
//the application will call a method called start, start is actually overridden because you are inheriting
//it from the application class. The start method passes in the primaryStage which is the main window for
//the application.

window = primaryStage;
window.setTitle("ChoiceBox Demo");//sets the title of the window
button = new Button("Click me");

ChoiceBox<String> choiceBox = new ChoiceBox<>();

//getItems returns the ObservableList object which you can add items to
choiceBox.getItems().add("Apples"); //add one at a time
choiceBox.getItems().add("Bananas");
choiceBox.getItems().addAll("Bacon", "Ham", "Meatballs");//add more then one item

//Set a default value
choiceBox.setValue("Apples");

//Listen for selection changes
//Method getSelectionModel depends on object type
//v stands for property of the list item
//To the left of the -> three parameters and to the right the code you want to execute upon the change
choiceBox.getSelectionModel().selectedItemProperty().addListener( (v, oldValue, newValue) ->
System.out.println(oldValue) );

//Layout
VBox layout = new VBox(10);
layout.setPadding(new Insets(20, 20, 20, 20));
layout.getChildren().addAll(choiceBox, button); //add button and dropdown list to the layout

scene = new Scene(layout, 300, 250); //Create scene of the Scene class, pass in layout object and hw
window.setScene(scene); //pass in scene object to set Scene of window
window.show(); //show the window

}


}
58 changes: 58 additions & 0 deletions ivyrodriguez/Main14.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package JavaFXDemo;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Main14 extends Application {

Stage window;
Scene scene;
Button button;
ComboBox<String> comboBox;

public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) throws Exception {
window = primaryStage;
window.setTitle("ComboBox Demo");
button = new Button("Click me");

comboBox = new ComboBox<>();
comboBox.getItems().addAll(
"Good Will Hunting",
"St.Vincent",
"Speed"
);

comboBox.setPromptText("What is your favorite movie?");

comboBox.setEditable(true);
button.setOnAction(e -> printMovie());

//ComboBoxes also generate actions if you need to get value instantly
comboBox.setOnAction(e -> System.out.println("User selected " + comboBox.getValue()));


VBox layout = new VBox(10);
layout.setPadding(new Insets(20, 20, 20, 20));
layout.getChildren().addAll(comboBox, button);

scene = new Scene(layout, 300, 250);
window.setScene(scene);
window.show();
}

private void printMovie(){
System.out.println(comboBox.getValue());
}


}
57 changes: 57 additions & 0 deletions ivyrodriguez/Main15.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package JavaFXDemo;

import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.SelectionMode;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.scene.control.ListView;

public class Main15 extends Application {

Stage window;
Scene scene;
Button button;
ListView<String> listView;

public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) throws Exception {
window = primaryStage;
window.setTitle("ListView Demo");
button = new Button("Submit");

listView = new ListView<>();
listView.getItems().addAll("Iron Man", "Titanic", "Contact", "Surrogates");
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

button.setOnAction(e -> buttonClicked());

VBox layout = new VBox(10);
layout.setPadding(new Insets(20, 20, 20, 20));
layout.getChildren().addAll(listView, button);

scene = new Scene(layout, 300, 250);
window.setScene(scene);
window.show();
}

private void buttonClicked(){
String message = "";
ObservableList<String> movies;
movies = listView.getSelectionModel().getSelectedItems();

for(String m: movies)
message += m + "\n";

System.out.println(message);
}


}
68 changes: 68 additions & 0 deletions ivyrodriguez/Main16.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package JavaFXDemo;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main16 extends Application {

Stage window;
TreeView<String> tree;

public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
window = primaryStage;
window.setTitle("JavaFX - thenewboston");

TreeItem<String> root, bucky, megan; // root and branches go here

//Root
root = new TreeItem<>();
root.setExpanded(true); //So that user doesn't have to expand root to see branches

//Bucky
bucky = makeBranch("Bucky", root); //two parameters: branch name, it's parent
makeBranch("thenewboston", bucky); //two parameters: item name, it's parent
makeBranch("YouTube", bucky);
makeBranch("Chicken", bucky);

//Megan
megan = makeBranch("Megan", root);
makeBranch("Glitter", megan);
makeBranch("Makeup", megan);

//Create the tree and hide the main Root
tree = new TreeView<>(root);
tree.setShowRoot(false); //hide a root with no item it in
tree.getSelectionModel().selectedItemProperty()
.addListener((v, oldValue, newValue) -> {//adds a listener to the item so when user clicks, it fires off
if (newValue != null)
System.out.println(newValue.getValue());
});

//Layout
StackPane layout = new StackPane();
layout.getChildren().add(tree); //different for treeview object
Scene scene = new Scene(layout, 300, 250);
window.setScene(scene);
window.show();
}

//Create branches
public TreeItem<String> makeBranch(String title, TreeItem<String> parent) {
TreeItem<String> item = new TreeItem<>(title);
item.setExpanded(true);
parent.getChildren().add(item);
return item; //method that adds the items noted above and the branches
}


}