├── .gitignore ├── README.md ├── build.xml ├── manifest.mf ├── pom.xml ├── sc1.jpg └── src └── main ├── java ├── jfxtaskwindow │ ├── HomeController.java │ ├── TaskItemController.java │ ├── TaskManagementDash.java │ └── TasksModel.java └── utilities │ └── Constants.java └── resources ├── fxml ├── Home.fxml └── TaskItem.fxml ├── icons ├── icons8_checked_filled_24px.png └── icons8_checked_filled_24px_1.png └── styles └── fullpackstyling.css /.gitignore: -------------------------------------------------------------------------------- 1 | ############################## 2 | ## Java 3 | ############################## 4 | .mtj.tmp/ 5 | *.class 6 | *.jar 7 | *.war 8 | *.ear 9 | *.nar 10 | hs_err_pid* 11 | 12 | ############################## 13 | ## Maven 14 | ############################## 15 | target/ 16 | pom.xml.tag 17 | pom.xml.releaseBackup 18 | pom.xml.versionsBackup 19 | pom.xml.next 20 | release.properties 21 | dependency-reduced-pom.xml 22 | buildNumber.properties 23 | .mvn/timing.properties 24 | .mvn/wrapper/maven-wrapper.jar 25 | 26 | ############################## 27 | ## Gradle 28 | ############################## 29 | bin/ 30 | build/ 31 | .gradle 32 | .gradletasknamecache 33 | gradle-app.setting 34 | !gradle-wrapper.jar 35 | 36 | ############################## 37 | ## IntelliJ 38 | ############################## 39 | out/ 40 | .idea/ 41 | .idea_modules/ 42 | *.iml 43 | *.ipr 44 | *.iws 45 | 46 | ############################## 47 | ## Eclipse 48 | ############################## 49 | .settings/ 50 | bin/ 51 | tmp/ 52 | .metadata 53 | .classpath 54 | .project 55 | *.tmp 56 | *.bak 57 | *.swp 58 | *~.nib 59 | local.properties 60 | .loadpath 61 | 62 | ############################## 63 | ## NetBeans 64 | ############################## 65 | nbproject/private/ 66 | build/ 67 | nbbuild/ 68 | dist/ 69 | nbdist/ 70 | nbactions.xml 71 | nb-configuration.xml 72 | 73 | ############################## 74 | ## OS X 75 | ############################## 76 | .DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JavaFX Task Management Sample 2 | 3 | A project to showcase custom list views using fxml files - incorporating modern UI design systems. 4 | 5 | ![](sc1.jpg) 6 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | Builds, tests, and runs the project TaskManagementDash. 3 | 4 | 53 | 54 | -------------------------------------------------------------------------------- /manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.appplus 6 | javafx-tasks 7 | 1.0-SNAPSHOT 8 | jar 9 | 10 | TaskManagementDash 11 | 12 | 13 | UTF-8 14 | jfxtaskwindow.TaskManagementDash 15 | 16 | 17 | 18 | 19 | Your Organisation 20 | 21 | 22 | 23 | 24 | 25 | org.apache.maven.plugins 26 | maven-dependency-plugin 27 | 2.6 28 | 29 | 30 | unpack-dependencies 31 | package 32 | 33 | unpack-dependencies 34 | 35 | 36 | system 37 | junit,org.mockito,org.hamcrest 38 | ${project.build.directory}/classes 39 | 40 | 41 | 42 | 43 | 44 | org.codehaus.mojo 45 | exec-maven-plugin 46 | 1.2.1 47 | 48 | 49 | unpack-dependencies 50 | 51 | package 52 | 53 | exec 54 | 55 | 56 | ${java.home}/../bin/javafxpackager 57 | 58 | -createjar 59 | -nocss2bin 60 | -appclass 61 | ${mainClass} 62 | -srcdir 63 | ${project.build.directory}/classes 64 | -outdir 65 | ${project.build.directory} 66 | -outfile 67 | ${project.build.finalName}.jar 68 | 69 | 70 | 71 | 72 | default-cli 73 | 74 | exec 75 | 76 | 77 | ${java.home}/bin/java 78 | ${runfx.args} 79 | 80 | 81 | 82 | 83 | 84 | org.apache.maven.plugins 85 | maven-compiler-plugin 86 | 3.1 87 | 88 | 1.8 89 | 1.8 90 | 91 | ${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar 92 | 93 | 94 | 95 | 96 | org.apache.maven.plugins 97 | maven-surefire-plugin 98 | 2.16 99 | 100 | 101 | ${java.home}/lib/jfxrt.jar 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | com.jfoenix 111 | jfoenix 112 | 8.0.8 113 | 114 | 115 | org.projectlombok 116 | lombok 117 | 1.18.8 118 | provided 119 | 120 | 121 | com.google.code.gson 122 | gson 123 | 2.8.2 124 | jar 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /sc1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k33ptoo/javafx-tasks/71146e28d3235edf568aad6c15f3c6f79c30f617/sc1.jpg -------------------------------------------------------------------------------- /src/main/java/jfxtaskwindow/HomeController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package jfxtaskwindow; 7 | 8 | import com.google.gson.Gson; 9 | import com.google.gson.reflect.TypeToken; 10 | 11 | import java.io.BufferedReader; 12 | import java.io.InputStreamReader; 13 | import java.net.URL; 14 | 15 | import java.util.List; 16 | import java.util.ResourceBundle; 17 | import java.util.concurrent.ExecutorService; 18 | import java.util.concurrent.Executors; 19 | 20 | import javafx.collections.FXCollections; 21 | import javafx.collections.ObservableList; 22 | import javafx.concurrent.Task; 23 | import javafx.fxml.FXML; 24 | import javafx.fxml.FXMLLoader; 25 | import javafx.fxml.Initializable; 26 | import javafx.scene.Node; 27 | import javafx.scene.control.Label; 28 | import javafx.scene.input.MouseEvent; 29 | import javafx.scene.layout.VBox; 30 | import lombok.Cleanup; 31 | import utilities.Constants; 32 | 33 | /** 34 | * 35 | * @author Too 36 | */ 37 | public class HomeController implements Initializable { 38 | 39 | @FXML 40 | private Label lblToday; 41 | 42 | @FXML 43 | private Label lblUpcoming; 44 | 45 | @FXML 46 | private VBox vTaskItems; 47 | 48 | private ObservableList listOfTasks; 49 | 50 | @FXML 51 | private void closeWindow(MouseEvent event) { 52 | System.exit(0); 53 | } 54 | 55 | @Override 56 | public void initialize(URL url, ResourceBundle rb) { 57 | ExecutorService executorService = Executors.newCachedThreadPool(); 58 | executorService.submit(fetchList); 59 | 60 | fetchList.setOnSucceeded((event) -> { 61 | 62 | listOfTasks = FXCollections.observableArrayList(fetchList.getValue()); 63 | int size = listOfTasks.size(); 64 | lblToday.setText("Today(" + size + ")"); 65 | lblUpcoming.setText("Upcoming(" + 0 + ")"); 66 | 67 | try { //load task items to vbox 68 | Node[] nodes = new Node[size]; 69 | for (int i = 0; i < nodes.length; i++) { 70 | //load specific item 71 | FXMLLoader loader = new FXMLLoader(getClass().getResource(Constants.FXML_ITEM_TASK)); 72 | TaskItemController controller = new TaskItemController(); 73 | loader.setController(controller); 74 | nodes[i] = loader.load(); 75 | vTaskItems.getChildren().add(nodes[i]); 76 | controller.setTask(listOfTasks.get(i)); 77 | } 78 | 79 | // Optional 80 | for (int i = 0; i < nodes.length; i++) { 81 | try { 82 | nodes[i] = FXMLLoader.load(getClass().getResource(Constants.FXML_ITEM_TASK)); 83 | //vTaskItemsupcoming.getChildren().add(nodes[i]); 84 | } catch (Exception e) { 85 | } 86 | } 87 | } catch (Exception e) { 88 | System.err.println("Error Creating Tasks..."); 89 | System.err.println(e.getMessage()); 90 | } 91 | }); 92 | } 93 | 94 | private final Task> fetchList = new Task() { 95 | 96 | @Override 97 | protected List call() throws Exception { 98 | List list = null; 99 | try { 100 | String url = readUrl(Constants.JSON_URL); 101 | System.out.println(url); 102 | list = new Gson().fromJson(url, new TypeToken>() { 103 | }.getType()); 104 | } catch (Exception e) { 105 | e.printStackTrace(); 106 | } 107 | return list; 108 | } 109 | 110 | }; 111 | 112 | private static String readUrl(String urlString) throws Exception { 113 | 114 | @Cleanup 115 | BufferedReader reader = null; 116 | 117 | URL url = new URL(urlString); 118 | reader = new BufferedReader(new InputStreamReader(url.openStream())); 119 | StringBuilder buffer = new StringBuilder(); 120 | int read; 121 | char[] chars = new char[1024]; 122 | while ((read = reader.read(chars)) != -1) { 123 | buffer.append(chars, 0, read); 124 | } 125 | 126 | return buffer.toString(); 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/jfxtaskwindow/TaskItemController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package jfxtaskwindow; 7 | 8 | import java.net.URL; 9 | import java.util.ResourceBundle; 10 | import javafx.fxml.FXML; 11 | import javafx.fxml.Initializable; 12 | import javafx.scene.control.Button; 13 | import javafx.scene.control.ContextMenu; 14 | import javafx.scene.control.Label; 15 | import javafx.scene.control.MenuItem; 16 | import javafx.scene.image.Image; 17 | import javafx.scene.image.ImageView; 18 | import utilities.Constants; 19 | 20 | /** 21 | * FXML Controller class 22 | * 23 | * @author Too 24 | */ 25 | public class TaskItemController implements Initializable { 26 | 27 | @FXML 28 | private ImageView iconSelect; 29 | 30 | @FXML 31 | private Label lblTaskName; 32 | 33 | @FXML 34 | private Button btnInfo; 35 | 36 | /** 37 | * Initializes the controller class. 38 | * 39 | * @param url 40 | * @param rb 41 | */ 42 | @Override 43 | public void initialize(URL url, ResourceBundle rb) { 44 | // TODO 45 | } 46 | 47 | public void setTask(TasksModel model) { 48 | ContextMenu menu = new ContextMenu(); 49 | System.out.println(model.toString()); 50 | lblTaskName.setText(model.getTitle()); 51 | 52 | if (model.getCompleted()) { 53 | btnInfo.setText("Complete"); 54 | iconSelect.setImage(new Image(getClass().getResourceAsStream(Constants.ICON_CHECK_FILL))); 55 | menu.getItems().add(new MenuItem("Set Task InComplete")); 56 | } else { 57 | btnInfo.setText("InComplete"); 58 | iconSelect.setImage(new Image(getClass().getResourceAsStream(Constants.ICON_CHECK_UNFILL))); 59 | menu.getItems().add(new MenuItem("Set Task Complete")); 60 | } 61 | 62 | lblTaskName.setContextMenu(menu); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/jfxtaskwindow/TaskManagementDash.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package jfxtaskwindow; 7 | 8 | import java.net.URL; 9 | import javafx.application.Application; 10 | import javafx.fxml.FXMLLoader; 11 | import javafx.scene.Parent; 12 | import javafx.scene.Scene; 13 | import javafx.scene.input.MouseEvent; 14 | import javafx.stage.Stage; 15 | import javafx.stage.StageStyle; 16 | import utilities.Constants; 17 | 18 | /** 19 | * 20 | * @author Too 21 | */ 22 | public class TaskManagementDash extends Application { 23 | 24 | // Define your offsets here 25 | private double xOffset = 0; 26 | private double yOffset = 0; 27 | 28 | @Override 29 | public void start(Stage stage) throws Exception { 30 | 31 | URL path = getClass().getResource(Constants.FXML_HOME); 32 | if (path != null) { 33 | Parent root = FXMLLoader.load(path); 34 | Scene scene = new Scene(root); 35 | 36 | stage.setScene(scene); 37 | stage.setTitle(Constants.APP_TITLE); 38 | stage.initStyle(StageStyle.TRANSPARENT); 39 | 40 | // Grab your root here 41 | root.setOnMousePressed((MouseEvent event) -> { 42 | xOffset = event.getSceneX(); 43 | yOffset = event.getSceneY(); 44 | }); 45 | 46 | // Move around here 47 | root.setOnMouseDragged((MouseEvent event) -> { 48 | stage.setX(event.getScreenX() - xOffset); 49 | stage.setY(event.getScreenY() - yOffset); 50 | }); 51 | 52 | stage.show(); 53 | } else { 54 | System.exit(-1); 55 | } 56 | 57 | } 58 | 59 | /** 60 | * @param args the command line arguments 61 | */ 62 | public static void main(String[] args) { 63 | launch(args); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/jfxtaskwindow/TasksModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package jfxtaskwindow; 7 | 8 | import lombok.Getter; 9 | import lombok.NoArgsConstructor; 10 | import lombok.Setter; 11 | import lombok.ToString; 12 | 13 | /** 14 | * 15 | * @author Too 16 | */ 17 | @Getter 18 | @Setter 19 | @NoArgsConstructor 20 | @ToString 21 | public class TasksModel { 22 | 23 | private String title; 24 | private Boolean completed; 25 | 26 | public TasksModel(String title, boolean completed) { 27 | this.title = title; 28 | this.completed = completed; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/utilities/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package utilities; 7 | 8 | /** 9 | * 10 | * @author Tony Manjarres 11 | */ 12 | public class Constants { 13 | 14 | public static String FXML_HOME = "/fxml/Home.fxml"; 15 | public static String FXML_ITEM_TASK = "/fxml/TaskItem.fxml"; 16 | public static String ICON_CHECK_UNFILL = "/icons/icons8_checked_filled_24px.png"; 17 | public static String ICON_CHECK_FILL = "/icons/icons8_checked_filled_24px_1.png"; 18 | public static String JSON_URL = "https://jsonplaceholder.typicode.com/todos"; 19 | public static String APP_TITLE = "JFX Task Manager"; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/fxml/Home.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 45 | 46 |
47 | 48 | 49 | 50 | 51 | 52 |
53 |
54 |
55 |
56 | 57 |
58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
68 | 69 | 77 | 78 |
79 |
80 |
81 |
82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 |