JavaFX代写:COMP2140 Running Headline News


Problem Description

In this project, you will complete an application which simulates the running of news messages on a display. A visually relevant example would be a news headline display which can be seen in Canberra City at the crossing of Northbourne Avenue and Alinga Street. Another example is an extension for the Safari browser, which displays running news in the top bar. We will use a simple model in which a news item, described as a Json-string, is read from a file, a fictitious timestamp is generated and included together with the news item into a buffer of the class Feeder. The Feeder object represents a news aggregator, and its buffer serves a supplier of news messages which arrived at the time given by the timestamp. We possess all the messages and the time of their “arrival” in advance, but pretend that messages arrive at an asynchronous moments of time, and ordered in the message queue by the time of their “arrival”. (Think of this as if Dr. Who has gone into the future, collected all news messages, stored them in the order of their occurrence, and brought this record back.) When you compile and run the original program, it will display the following window with news items sliding one by one, from right to left.

The original program does not have necessary features which are expected from a program with graphical user interface (GUI). For starters, it takes the name of the data file (which contains messages as json-strings) as a command-line argument instead of providing a menu to open this file with a file chooser dialog. Also, the application provides only rudimentary control over the application behaviour: by using keys P and R (and also cmd-Q), the user can pause the running headlines, resume their motion, and quit the application. You will modify and extend the program to improve the user interface, and provide new features of control.


  • Add a menu with following groups and items:
    • Open, Close, Quit (Close can be an optional feature, since other menu items will provide the relevant control)
    • Pause, Resume, Faster, Slower, Next, Previous
  • Add a row of controls (most suitably implemented with javafx.scene.control.CheckBox class), each allowing to include news items which have a relevant topic. Topic is an inner enum class which defines the type of the Message class fields; another field, of the type Status, will be used to prioritise the news item order of display. Together – Topic, Status and timestamp – represent news message metadata.
  • Implement priority ordering based on the Message.Status value and the timestamp of a message in the queue. A suitable container type for the Feeder’s buffer is java.util.PriorityQueue, which requires a comparator object (or a functional interface), to determine in which order the elements are extracted from the container, and hence the order in which they will processed. Messages should be ordered according to their status, from EMERGENCY (highest priority) to SPECIAL_INTEREST (lowest priority).
  • Add visual effects:
    • colourise topics (mark each topic with a different colour)
    • add a separator between successive messages (in the running news display in Civic, they are separated by the ABC logo; you can use emoji symbols, for example, – they are Unicode characters, and Java is Unicode friendly)
    • if the next message has a status of EMERGENCY, make the currently playing message fade away halfway through
    • add styling to UI using css-styles
  • If you wish, you may use a declarative approach to build a UI layout, which defines the user interface through a FXML-file, but this is not required. If you do use FXML, don’t forget to submit the fxml-file together with the standard source code. Doing the layout the declarative way will not earn your any bonus.

Advice on how to approach the project

This short video provides an illustration of how your completed application may look like:

The code which you will be writing can be placed in the existing classes, or (at least some of the new code) in newly added classes. The design is not a key consideration here, but it makes sense to pay attention to how newly emerging program will be organised. One special note – the class Controller can be either kept or removed; as of now, it does not play any role, it was auto-generated by the IDE as a part of the template JavaFX project. Controller can be used if you pursue the creation of layout and control elements using the FXML-based approach (we will discuss it briefly in the lectures), but all the required tasks can be accomplished following the “old-fashioned” approach of creating appropriate statements inside the ordinary Java source files. If you follow the latter, Controller can be removed altogether.