/*
* Copyright (c) 2012, 2014, Oracle and/or its affiliates.
* All rights reserved. Use is subject to license terms.
*
* This file is available and licensed under the following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the distribution.
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.fengsheng.demo.menusample;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import javafx.application.Application;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.Effect;
import javafx.scene.effect.Glow;
import javafx.scene.effect.SepiaTone;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.*;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;
public class MenuSample extends Application {
final PageData[] pages = new PageData[] {
new PageData("Apple",
"The apple is the pomaceous fruit of the apple tree, species Malus "
+ "domestica in the rose family (Rosaceae). It is one of the most "
+ "widely cultivated tree fruits, and the most widely known of "
+ "the many members of genus Malus that are used by humans. "
+ "The tree originated in Western Asia, where its wild ancestor, "
+ "the Alma, is still found today.",
"Malus domestica"),
new PageData("Hawthorn",
"The hawthorn is a large genus of shrubs and trees in the rose family,"
+ "Rosaceae, native to temperate regions of the Northern Hemisphere "
+ "in Europe, Asia and North America. The name hawthorn was "
+ "originally applied to the species native to northern Europe, "
+ "especially the Common Hawthorn C. monogyna, and the unmodified "
+ "name is often so used in Britain and Ireland.",
"Crataegus monogyna"),
new PageData("Ivy",
"The ivy is a flowering plant in the grape family (Vitaceae) native to "
+ " eastern Asia in Japan, Korea, and northern and eastern China. "
+ "It is a deciduous woody vine growing to 30 m tall or more given "
+ "suitable support, attaching itself by means of numerous small "
+ "branched tendrils tipped with sticky disks.",
"Parthenocissus tricuspidata"),
new PageData("Quince",
"The quince is the sole member of the genus Cydonia and is native to "
+ "warm-temperate southwest Asia in the Caucasus region. The "
+ "immature fruit is green with dense grey-white pubescence, most "
+ "of which rubs off before maturity in late autumn when the fruit "
+ "changes color to yellow with hard, strongly perfumed flesh.",
"Cydonia oblonga")
};
final String[] viewOptions = new String[] {
"Title",
"Binomial name",
"Picture",
"Description"
};
final Entry<String, Effect>[] effects = new Entry[] {
new SimpleEntry<>("Sepia Tone", new SepiaTone()),
new SimpleEntry<>("Glow", new Glow()),
new SimpleEntry<>("Shadow", new DropShadow())
};
final ImageView pic = new ImageView();
final Label name = new Label();
final Label binName = new Label();
final Label description = new Label();
private int currentIndex = -1;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
stage.setTitle("Menu Sample");
Scene scene = new Scene(new VBox(), 400, 350);
scene.setFill(Color.OLDLACE);
name.setFont(new Font("Verdana Bold", 22));
binName.setFont(new Font("Arial Italic", 10));
pic.setFitHeight(150);
pic.setPreserveRatio(true);
description.setWrapText(true);
description.setTextAlignment(TextAlignment.JUSTIFY);
shuffle();
MenuBar menuBar = new MenuBar();
// --- Graphical elements
final VBox vbox = new VBox();
vbox.setAlignment(Pos.CENTER);
vbox.setSpacing(10);
vbox.setPadding(new Insets(0, 10, 0, 10));
vbox.getChildren().addAll(name, binName, pic, description);
// --- Menu File
Menu menuFile = new Menu("File");
MenuItem add = new MenuItem("Shuffle",
new ImageView(new Image("com/fengsheng/demo/menusample/new.png")));
add.setOnAction((ActionEvent t) -> {
shuffle();
vbox.setVisible(true);
});
MenuItem clear = new MenuItem("Clear");
clear.setAccelerator(KeyCombination.keyCombination("Ctrl+X"));
clear.setOnAction((ActionEvent t) -> {
vbox.setVisible(false);
});
MenuItem exit = new MenuItem("Exit");
exit.setOnAction((ActionEvent t) -> {
System.exit(0);
});
menuFile.getItems().addAll(add, clear, new SeparatorMenuItem(), exit);
// --- Menu Edit
Menu menuEdit = new Menu("Edit");
Menu menuEffect = new Menu("Picture Effect");
final ToggleGroup groupEffect = new ToggleGroup();
for (Entry<String, Effect> effect : effects) {
RadioMenuItem itemEffect = new RadioMenuItem(effect.getKey());
itemEffect.setUserData(effect.getValue());
itemEffect.setToggleGroup(groupEffect);
menuEffect.getItems().add(itemEffect);
}
final MenuItem noEffects = new MenuItem("No Effects");
noEffects.setDisable(true);
noEffects.setOnAction((ActionEvent t) -> {
pic.setEffect(null);
groupEffect.getSelectedToggle().setSelected(false);
noEffects.setDisable(true);
});
groupEffect.selectedToggleProperty().addListener(
(ObservableValue<? extends Toggle> ov, Toggle old_toggle,
Toggle new_toggle) -> {
if (groupEffect.getSelectedToggle() != null) {
Effect effect =
(Effect) groupEffect.getSelectedToggle().getUserD
没有合适的资源?快使用搜索试试~ 我知道了~
JavaFx应用实例
共389个文件
java:129个
class:100个
png:75个
需积分: 13 22 下载量 170 浏览量
2016-06-24
09:13:18
上传
评论
收藏 3.66MB RAR 举报
温馨提示
JavaFx 应用小实例
资源推荐
资源详情
资源评论
收起资源包目录
JavaFx应用实例 (389个子文件)
MenuSample.class 14KB
MenuSample.class 11KB
SchStudent.class 8KB
TreeTableViewSample.class 7KB
ButtonSample.class 6KB
TreeTableViewSample.class 5KB
SchStudent.class 5KB
TitledPaneSample.class 5KB
CheckboxSample.class 5KB
TreeViewSample.class 5KB
ToggleButtonSample.class 5KB
TooltipSample.class 5KB
ButtonSample.class 4KB
TreeViewSample.class 4KB
TitledPaneSample.class 4KB
TreeViewSample$TextFieldTreeCellImpl.class 4KB
CheckboxSample.class 4KB
MyApplication.class 4KB
OnSumbitAuditFailureStepTwo.class 4KB
OnSumbitAuditFailureStepThree.class 4KB
SumbitAuditFailureStepOne.class 4KB
OnInsertStudentK2StuScore.class 4KB
OnClassIsPay.class 4KB
SchClass.class 4KB
OnInsertStudentK1StuScore.class 4KB
TooltipSample.class 4KB
OnStudentIsPay.class 4KB
Person.class 4KB
ToggleButtonSample.class 4KB
TreeViewSample$TextFieldTreeCellImpl.class 3KB
OnSumbitAuditFailureStepTwo.class 3KB
OnSumbitAuditFailureStepThree.class 3KB
SumbitAuditFailureStepOne.class 3KB
OnInsertStudentK2StuScore.class 3KB
OnClassIsPay.class 3KB
MyApplication.class 3KB
SchStudentDao.class 3KB
OnInsertStudentK1StuScore.class 3KB
OnStudentIsPay.class 3KB
MainController.class 2KB
SchClass.class 2KB
Person.class 2KB
SchStudentDao.class 2KB
SchStuKemuDao.class 2KB
ModalDialog.class 2KB
TreeTableViewSample$Employee.class 2KB
Formatter.class 2KB
DbUtil.class 2KB
LoginController.class 2KB
DoMain.class 2KB
ModalDialog.class 2KB
SchStuKemuDao.class 2KB
MainController.class 2KB
TreeTableViewSample$Employee.class 1KB
Main.class 1KB
SchClassDao.class 1KB
DbUtil.class 1KB
JSONFormatter.class 1KB
XMLFormatter.class 1KB
SchStuCourseDao.class 1KB
MenuSample$PageData.class 1KB
Book.class 1KB
TreeViewSample$Employee.class 1KB
Formatter.class 1KB
LoginController.class 1KB
DoMain.class 1KB
ModalDialog$1.class 1KB
Main.class 1KB
MenuSample$PageData.class 1008B
XMLBuilder.class 1006B
SchClassDao.class 983B
JSONFormatter.class 973B
XMLFormatter.class 967B
TreeViewSample$Employee.class 965B
SchStuCourseDao.class 951B
Formatter.class 936B
ModalDialog$2.class 869B
Book.class 811B
ModalDialog$1.class 782B
ServerOne.class 715B
XMLBuilder.class 701B
ModalDialog$2.class 636B
Check.class 614B
Formatter.class 580B
StudentIsPayController.class 567B
ServerThree.class 533B
ServerTwo.class 527B
ServerOne.class 493B
ServerFirst.class 421B
Check.class 360B
ServerThree.class 315B
ServerTwo.class 313B
Utils.class 278B
StudentIsPayController.class 275B
TreeTableViewSample$1.class 235B
TreeViewSample$1.class 215B
ServerFirst.class 210B
PlayerCount.class 207B
PlayerCount.class 167B
Utils.class 139B
共 389 条
- 1
- 2
- 3
- 4
资源评论
阿牛_O
- 粉丝: 22
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于python实现的基于PyQt5和爬虫的小说阅读系统.zip
- 机械设计整经机上纱自动化sw20非常好的设计图纸100%好用.zip
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功