1 / 19

Recall: Timeline Class

Recall: Timeline Class. Write a program that flashes text on and off. Import the following for animation and text Create a stack pane Create the text Add the text to the pane Create handler for changing text (this causes the on and off) Set text empty Set text Create a timeline

nradcliffe
Download Presentation

Recall: Timeline Class

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Recall: Timeline Class Write a program that flashes text on and off Import the following for animation and text Create a stack pane Create the text Add the text to the pane Create handler for changing text (this causes the on and off) Set text empty Set text Create a timeline Create a KeyFrame for handler Set cycle count indefinite Starting the animation Pausing the animation Resuming the animation Setting the stage

  2. Chapter 16JavaFX UI Controls and Multimedia Previous chapters introduced several GUI components. This chapter introduces the frequently used GUI components. FUN and EASY chapter

  3. Frequently Used UI Controls NOTE: Throughout your book, the prefixes lbl, bt, chk, rb, tf, pf, ta, cbo, lv, scb, sld, and mp are used to name reference variables for Label, Button, CheckBox, RadioButton, TextField, PasswordField, TextArea, ComboBox, ListView, ScrollBar, Slider, and MediaPlayer.

  4. Labeled The Label class defines labels. A label is a display area for a short text, a node, or both. It is often used to label other controls (usually text fields). These common properties are defined in the Labeled class.

  5. Example - Label Import the following for labels Create a label for an image Set label/node position Create another label for a circle Set the label/node position Create a label for a rectangle Create a label for a shape Create a label for a pane Setting the stage

  6. ButtonBase and Button A button is a control that triggers an action event when clicked (you have already covered). JavaFX provides regular buttons, check box buttons, and radio buttons. The common features of these buttons are defined in the ButtonBase class. Button Example A CheckBox is used for the user to make a selection. Checkbox Example

  7. ButtonBase and Button A button is a control that triggers an action event when clicked (you have already covered). JavaFX provides regular buttons, check box buttons, and radio buttons. The common features of these buttons are defined in the ButtonBase class. Radio buttons, also known as option buttons, enable you to choose a single item from a group of choices. Radio button Example

  8. Button Type Example Import the following for a checkbox type button Creating a pane for checkboxes (recall the value of this) Create a checkbox with two choices Create a handler for the checkbox using Lambda Set the handler for action

  9. TextField A text field can be used to enter or display a string. A TextArea enables the user to enter multiple lines of text. TextField is a subclass of TextInputControl. TextField Example

  10. TextArea A TextArea enables the user to enter multiple lines of text.

  11. ComboBox A combo box, also known as a choice list or drop-down list, contains a list of items from which the user can choose. This example lets users view an image and a description of a country's flag by selecting the country from a combo box.

  12. ComboBox Example Import the following for a combobox Creating an array of strings of countries Create an array of ImageViews of national flags Declare an array of strings for flag descriptions (enter info later) Create a description pane Create a combobox for selecting countries Set Canada to be the first country displayed Set up pane for combobox Setup the observable list Add to the combobox Based on some action, display the selected country

  13. ListView A list view is a component that performs basically the same function as a combo box, but it enables the user to choose a single value or multiple values.

  14. ScrollBar A scroll bar is a control that enables the user to select from a range of values. The scrollbar appears in two styles: horizontal and vertical. This example uses horizontal and vertical scrollbars to control a message displayed on a panel.

  15. Example: Using Scrollbars Import the following for a scrollbar Create horizontal scroll bar Create vertical scroll bar Add text to a pane Create a pane to hold text and scroll bar Set new location for text Create listener horizontal bar change Set new location for text Create listener vertical bar change

  16. Slider Slider is similar to ScrollBar, but Slider has more properties and can appear in many forms. Example - Using a sliders to control a message displayed on a panel instead of using scroll bars.

  17. Media You can use the Media class to obtain the source of the media, the MediaPlayer class to play and control the media, and the MediaView class to display the video. MediaPlayer The MediaPlayer class playes and controls the media with properties such as autoPlay, currentCount, cycleCount, mute, volume, and totalDuration. MediaView The MediaView class is a subclass of Node that provides a view of the Media being played by a MediaPlayer. The MediaView class provides the properties for viewing the media.

  18. EXAMPLE: This example displays a video in a view. You can use the play/pause button to play or pause the video and use the rewind button to restart the video, and use the slider to control the volume of the audio. Import the following Create media Create media player Create a media view Play media Pause media Create a rewind button Create handler for rewinding Create a slider for volume Set volume Bind volume with slider Add buttons and slider to hBox Place media view in a pane

  19. Example: Using Media This example displays a video in a view. You can use the play/pause button to play or pause the video and use the rewind button to restart the video, and use the slider to control the volume of the audio. MediaDemo Run

More Related