Oberflächen
  Vorlesungen     Download     DBS     Sprachen     File Formats     Impressum     Datenschutz  
C#- GUI-Programme mit Quellcode
Java-Programme mit Quellcode
C#
WPF
HTML
Java FX
Java (Swing)
Winforms
Visual Studio (MFC)
ArcView
QGis
ArcView .net
IDW
Allgemein:
Startseite
Vorlesungen
Labore
Sinnvolle Programme
Lineare Regression
GUI-Entwurfsarbeit
Single-Format
Design Pattern-Termine
Observer1
Bsp2
Json-Array
Json-Dialogelemente
Webtechnologien

Menu

Menus

Beschreibung Download
Dialogfenster mit einem Menu UIBspMenu01.java
UIBspMenu01.png


import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.application.Platform;
MenuBar menuBar = new MenuBar();
Menu menuFile = new Menu("File");
menuBar.getMenus().add(menuFile);

MenuItem menuOpen = new MenuItem("Open File...");
MenuItem menuSave = new MenuItem("Save File...");
MenuItem menuClose = new MenuItem("Close");



menuOpen.setOnAction(e->openFile());
menuSave.setOnAction(e->saveFile());
menuClose.setOnAction(e->Platform.exit());

menuOpen.setAccelerator(KeyCombination.keyCombination("Ctrl+O"));
menuSave.setAccelerator(KeyCombination.keyCombination("Ctrl+S"));

menuFile.getItems().addAll(menuOpen, menuSave, new SeparatorMenuItem());
menuFile.getItems().add(menuClose);



scene.getStylesheets().add("UIBspMenu03.css");
CSS:
.menu, .menu-item {
-fx-text-fill: blue ;
-fx-font-size:22;
}

Komplettbeispiel mit einem Menu und einem Editor UIBspMenu02.java
UIBspMenu02.png
Weitere MenuItems:
- RadioMenuItems
- CheckMenuItems
UIBspMenu03.java
UIBspMenu03.png

// globale Variablen
RadioMenuItem menuFont10 = new RadioMenuItem("Font 10pg (RadioButton)");
RadioMenuItem menuFont12 = new RadioMenuItem("Font 12pg (RadioButton)");
CheckMenuItem menuFontBold = new CheckMenuItem("Fett (CheckBox)");
int fontsize=10;

// init/create
ToggleGroup mngroup = new ToggleGroup(); // javafx.scene.control.ToggleButton
menuFont10.setToggleGroup(mngroup);
menuFont12.setToggleGroup(mngroup);
Menu menuFont = new Menu("Font");
menuBar.getMenus().add(menuFont);
menuFont10.setOnAction(e->fontchange(e));
menuFont12.setOnAction(e->fontchange(e));
menuFontBold.setOnAction(e->fontchange(null));

menuFont.getItems().addAll(menuFont10, menuFont12, menuFont14, menuFont16, menuFontBold );
menuFont10.setSelected(true);
fontsize=10;
fontchange(null);

ChangeEvent:
private void fontchange(ActionEvent e) {
if (e==null) {
// Bold
}
else {
RadioMenuItem menuFont = (RadioMenuItem) e.getSource();
menuFont.setSelected(true);
if (menuFont10==menuFont) fontsize=10;
if (menuFont12==menuFont) fontsize=12;
}
if (menuFontBold.isSelected()) {
root.setStyle(" -fx-font-size: "+fontsize+"px; -fx-font-weight:bold; -fx-font-family: Tahoma;");
}
else {
root.setStyle(" -fx-font-size: "+fontsize+"px; -fx-font-family: Tahoma;");
}
}



ListView
Menu-Snippet