Planet JFX

Dynamic Menu and Alert Box

118pages on
this wiki
Add New Page
Add New Page Talk0

This example creates a form with a menubar. Items of the menu are added and deleted dynamically in runtime by "Add" and "Remove" buttons. If menu item is selected alert box with its name is shown.

import javafx.ui.*;
import java.lang.System;

//alert data model declaration
class AlertModel {
	attribute AlertText:String;
	attribute ShowAlert:boolean;
var am = AlertModel {
	AlertText: "Text"
	ShowAlert: false

//menu data model
class MenuSource {
    attribute items:MenuItem*;
    attribute malert:AlertModel;

 bottom: add_button }
    visible: true

Also on Fandom

Random Wiki