本文整理汇总了Java中com.jfoenix.controls.JFXButton.addEventHandler方法的典型用法代码示例。如果您正苦于以下问题:Java JFXButton.addEventHandler方法的具体用法?Java JFXButton.addEventHandler怎么用?Java JFXButton.addEventHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jfoenix.controls.JFXButton
的用法示例。
在下文中一共展示了JFXButton.addEventHandler方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDialouge
import com.jfoenix.controls.JFXButton; //导入方法依赖的package包/类
public static void setDialouge(JFXButton applyButton , String heading , String text , Node ob) {
JFXButton button = applyButton;
content.setHeading(new Text(heading));
content.setBody(new Text(text));
JFXDialog dialoge = new JFXDialog(pane, content, JFXDialog.DialogTransition.CENTER);
button.addEventHandler(MouseEvent.MOUSE_CLICKED, (e6) -> {
dialoge.close();
});
content.setActions(ob, button);
// To show overlay dialougge box
dialoge.show();
}
示例2: show
import com.jfoenix.controls.JFXButton; //导入方法依赖的package包/类
public void show() {
JFXDialogLayout content = new JFXDialogLayout();
content.setHeading(new Text(headingText));
content.setBody(new Text(bodyText));
StackPane stackPane = new StackPane();
stackPane.autosize();
JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true);
JFXButton okayBtn = new JFXButton(okayText);
okayBtn.addEventHandler(ActionEvent.ACTION, (e)-> {
dialog.close();
});
okayBtn.addEventHandler(ActionEvent.ACTION, okayAction);
okayBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
okayBtn.setPrefHeight(32);
okayBtn.setStyle(dialogBtnStyle);
JFXButton cancelBtn = new JFXButton(cancelText);
cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> {
dialog.close();
});
cancelBtn.addEventHandler(ActionEvent.ACTION, cancelAction);
cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED);
cancelBtn.setPrefHeight(32);
cancelBtn.setStyle(dialogBtnStyle);
content.setActions(cancelBtn, okayBtn);
content.setPrefSize(dialogWidth, dialogHeight);
pane.getChildren().add(stackPane);
AnchorPane.setTopAnchor(stackPane, (pane.getHeight()-content.getPrefHeight())/2);
AnchorPane.setLeftAnchor(stackPane, (pane.getWidth()-content.getPrefWidth())/2);
dialog.show();
}
示例3: start
import com.jfoenix.controls.JFXButton; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
BorderPane root = new BorderPane();
JFXTabPane tabPane = new JFXTabPane();
Tab tab1 = new Tab();
tab1.setText("Graph Tab");
Tab tab2 = new Tab();
tab2.setText("Empty Tab");
BorderPane gPane = new BorderPane();
CategoryAxis x = new CategoryAxis();
x.setLabel("Visited Sites");
NumberAxis y = new NumberAxis();
y.setLabel("Hits");
lineChart = new LineChart<>(x, y);
set2 = new XYChart.Series<>();
set2.getData().add(new XYChart.Data("Ramzan",62));
// set2.getData().add(new XYChart.Data("Hussan",421));
// set2.getData().add(new XYChart.Data("Shoaib",92));
// set2.getData().add(new XYChart.Data("Sudo",42));
lineChart.setTitle("History Statistics");
lineChart.getData().add(set2);
JFXButton button = new JFXButton("add");
button.addEventHandler(MouseEvent.MOUSE_CLICKED, e ->{
set2.getData().remove(0);
set2.getData().add(new XYChart.Data("chhala",45));
});
gPane.setCenter(lineChart);
gPane.setLeft(button);
tab1.setContent(gPane);
tabPane.getTabs().addAll(tab1,tab2);
root.setCenter(tabPane);
Scene scene = new Scene(root,800,600);
stage.setScene(scene);
stage.show();
final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
Random rand = new Random();
System.out.println(set2.getData().size());
java.util.Date date = new java.util.Date();
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
set2.getData().add(new XYChart.Data(timeFormat.format(date),rand.nextInt(20)));
}
}, 0, 1, TimeUnit.SECONDS);
}
示例4: addDrawerVBox
import com.jfoenix.controls.JFXButton; //导入方法依赖的package包/类
/**
* Generates VBox with a drawer menu in it.
* @return generated VBox
*/
//TODO Once files gonna be generated, remove hard-coded stuff.
public VBox addDrawerVBox() {
leftDrawer.setDefaultDrawerSize(300);
leftDrawer.setOverLayVisible(false);
leftDrawer.setSidePane(drawerPane);
leftDrawer.setPrefSize(0,0);
JFXButton profileButton = new JFXButton("View Profile");
JFXButton button1 = new JFXButton("View Auctions");
JFXButton button2 = new JFXButton("View Favourites");
JFXButton searchButton = new JFXButton("Search profiles");
VBox vBox = new VBox();
vBox.setStyle("-fx-background-color: #E91E63; -fx-padding: -10;");
vBox.setPadding(new Insets(15, 12, 15, 0));
vBox.setSpacing(10);
button1.setMaxWidth(10000);
searchButton.setMaxWidth(10000);
button1.addEventHandler(MOUSE_CLICKED, e -> {
GUIController
.getPrimaryStage()
.setScene(new Scene(new ArtworkContainer(dc,curProfile,loggedInProfile)
.getPane(), getPane()
.getWidth(), getPane()
.getHeight())
);
});
button2.setMaxWidth(10000);
button2.addEventHandler(MOUSE_CLICKED, e -> {
GUIController
.getPrimaryStage()
.setScene(new Scene(new FavouriteProfileScene(dc,loggedInProfile,loggedInProfile)
.getPane(), getPane()
.getWidth(), getPane()
.getHeight())
);
});
profileButton.addEventHandler(MOUSE_CLICKED, e -> {
GUIController
.getPrimaryStage()
.setScene(new Scene(new ProfileScene(dc,loggedInProfile,loggedInProfile)
.getPane(), getPane()
.getWidth(), getPane()
.getHeight())
);
});
searchButton.addEventHandler(MOUSE_CLICKED, e -> {
GUIController
.getPrimaryStage()
.setScene(new Scene(new SearchScene(dc,curProfile,loggedInProfile)
.getPane(), getPane()
.getWidth(), getPane()
.getHeight()));
});
vBox.setMargin(profileButton, new Insets(25, 25, 1, 25));
vBox.setMargin(button1, new Insets(1, 25, 1, 25));
vBox.setMargin(button2, new Insets(1, 25, 25, 25));
vBox.setMargin(searchButton,new Insets(1,25,25,25));
button2.setMaxWidth(10000);
profileButton.setMaxWidth(10000);
vBox
.getChildren()
.addAll(profileButton,button1, button2, searchButton
);
return vBox;
}
示例5: start
import com.jfoenix.controls.JFXButton; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
Rotate rotate = new Rotate();
JFXButton button = new JFXButton("Rotation");
button.getTransforms().add(rotate);
button.addEventHandler(MouseEvent.MOUSE_CLICKED, e ->{
angle += 10;
rotate.setAngle(angle);
rotate.setPivotX(button.getWidth()/2);
rotate.setPivotY(button.getHeight()/2);
});
FlowPane root = new FlowPane();
root.setAlignment(Pos.CENTER);
root.setPadding(new Insets(25,25,25, angle));
root.getChildren().add(button);
Scene scene = new Scene(root,300,250);
primaryStage.setTitle("Button Animation");
primaryStage.setScene(scene);
primaryStage.show();
}
示例6: start
import com.jfoenix.controls.JFXButton; //导入方法依赖的package包/类
@Override
public void start(Stage stage) {
FlowPane content = new FlowPane();
JFXButton leftButton = new JFXButton(LEFT);
JFXButton topButton = new JFXButton(TOP);
JFXButton rightButton = new JFXButton(RIGHT);
JFXButton bottomButton = new JFXButton(BOTTOM);
content.getChildren().addAll(leftButton, topButton, rightButton, bottomButton);
content.setMaxSize(200, 200);
JFXDrawer leftDrawer = new JFXDrawer();
StackPane leftDrawerPane = new StackPane();
leftDrawerPane.getStyleClass().add("red-400");
leftDrawerPane.getChildren().add(new JFXButton("Left Content"));
leftDrawer.setSidePane(leftDrawerPane);
leftDrawer.setDefaultDrawerSize(150);
leftDrawer.setResizeContent(true);
leftDrawer.setOverLayVisible(false);
leftDrawer.setResizableOnDrag(true);
JFXDrawer bottomDrawer = new JFXDrawer();
StackPane bottomDrawerPane = new StackPane();
bottomDrawerPane.getStyleClass().add("deep-purple-400");
bottomDrawerPane.getChildren().add(new JFXButton("Bottom Content"));
bottomDrawer.setDefaultDrawerSize(150);
bottomDrawer.setDirection(DrawerDirection.BOTTOM);
bottomDrawer.setSidePane(bottomDrawerPane);
bottomDrawer.setResizeContent(true);
bottomDrawer.setOverLayVisible(false);
bottomDrawer.setResizableOnDrag(true);
JFXDrawer rightDrawer = new JFXDrawer();
StackPane rightDrawerPane = new StackPane();
rightDrawerPane.getStyleClass().add("blue-400");
rightDrawerPane.getChildren().add(new JFXButton("Right Content"));
rightDrawer.setDirection(DrawerDirection.RIGHT);
rightDrawer.setDefaultDrawerSize(150);
rightDrawer.setSidePane(rightDrawerPane);
rightDrawer.setOverLayVisible(false);
rightDrawer.setResizableOnDrag(true);
JFXDrawer topDrawer = new JFXDrawer();
StackPane topDrawerPane = new StackPane();
topDrawerPane.getStyleClass().add("green-400");
topDrawerPane.getChildren().add(new JFXButton("Top Content"));
topDrawer.setDirection(DrawerDirection.TOP);
topDrawer.setDefaultDrawerSize(150);
topDrawer.setSidePane(topDrawerPane);
topDrawer.setOverLayVisible(false);
topDrawer.setResizableOnDrag(true);
JFXDrawersStack drawersStack = new JFXDrawersStack();
drawersStack.setContent(content);
leftDrawer.setId(LEFT);
rightDrawer.setId(RIGHT);
bottomDrawer.setId(BOTTOM);
topDrawer.setId(TOP);
leftButton.addEventHandler(MOUSE_PRESSED, e -> drawersStack.toggle(leftDrawer));
bottomButton.addEventHandler(MOUSE_PRESSED, e -> drawersStack.toggle(bottomDrawer));
rightButton.addEventHandler(MOUSE_PRESSED, e -> drawersStack.toggle(rightDrawer));
topButton.addEventHandler(MOUSE_PRESSED, e -> drawersStack.toggle(topDrawer));
final Scene scene = new Scene(drawersStack, 800, 800);
final ObservableList<String> stylesheets = scene.getStylesheets();
stylesheets.addAll(DrawerDemo.class.getResource("/css/jfoenix-components.css").toExternalForm(),
DrawerDemo.class.getResource("/css/jfoenix-design.css").toExternalForm());
stage.setTitle("JFX Drawer Demo");
stage.setScene(scene);
stage.setResizable(true);
stage.show();
}
示例7: JFXButtonSkin
import com.jfoenix.controls.JFXButton; //导入方法依赖的package包/类
public JFXButtonSkin(JFXButton button) {
super(button);
buttonRippler = new JFXRippler(getSkinnable()) {
@Override
protected Node getMask() {
StackPane mask = new StackPane();
mask.shapeProperty().bind(getSkinnable().shapeProperty());
JFXNodeUtils.updateBackground(getSkinnable().getBackground(), mask);
mask.resize(getWidth() - snappedRightInset() - snappedLeftInset(),
getHeight() - snappedBottomInset() - snappedTopInset());
return mask;
}
@Override
protected void positionControl(Node control) {
// do nothing as the controls is not inside the ripple
}
};
// add listeners to the button and bind properties
button.addEventHandler(MouseEvent.MOUSE_PRESSED, e -> playClickAnimation(1));
// button.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> playClickAnimation(-1));
button.addEventFilter(MouseEvent.MOUSE_PRESSED, e-> mousePressed = true);
button.addEventFilter(MouseEvent.MOUSE_RELEASED, e-> mousePressed = false);
button.addEventFilter(MouseEvent.MOUSE_DRAGGED, e-> mousePressed = false);
button.ripplerFillProperty().addListener((o, oldVal, newVal) -> buttonRippler.setRipplerFill(newVal));
button.armedProperty().addListener((o, oldVal, newVal) -> {
if (newVal) {
if (!mousePressed) {
releaseManualRippler = buttonRippler.createManualRipple();
playClickAnimation(1);
}
} else {
if (releaseManualRippler != null) {
releaseManualRippler.run();
releaseManualRippler = null;
}
playClickAnimation(-1);
}
});
// show focused state
button.focusedProperty().addListener((o, oldVal, newVal) -> {
if(!button.disableVisualFocusProperty().get()){
if (newVal){
if (!getSkinnable().isPressed()){
buttonRippler.setOverlayVisible(true);
}
} else{
buttonRippler.setOverlayVisible(false);
}
}
});
button.buttonTypeProperty().addListener((o, oldVal, newVal) -> updateButtonType(newVal));
/*
* disable action when clicking on the button shadow
*/
button.setPickOnBounds(false);
updateButtonType(button.getButtonType());
updateChildren();
}
示例8: start
import com.jfoenix.controls.JFXButton; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
FlowPane content = new FlowPane();
JFXButton leftButton = new JFXButton("LEFT");
JFXButton topButton = new JFXButton("TOP");
JFXButton rightButton = new JFXButton("RIGHT");
JFXButton bottomButton = new JFXButton("BOTTOM");
content.getChildren().addAll(leftButton, topButton, rightButton, bottomButton);
content.setMaxSize(200, 200);
JFXDrawer leftDrawer = new JFXDrawer();
StackPane leftDrawerPane = new StackPane();
leftDrawerPane.getStyleClass().add("red-400");
leftDrawerPane.getChildren().add(new JFXButton("Left Content"));
leftDrawer.setSidePane(leftDrawerPane);
leftDrawer.setDefaultDrawerSize(150);
// leftDrawer.setContent(content);
leftDrawer.setOverLayVisible(false);
leftDrawer.setResizableOnDrag(true);
JFXDrawer bottomDrawer = new JFXDrawer();
StackPane bottomDrawerPane = new StackPane();
bottomDrawerPane.getStyleClass().add("deep-purple-400");
bottomDrawerPane.getChildren().add(new JFXButton("Bottom Content"));
bottomDrawer.setDefaultDrawerSize(150);
bottomDrawer.setDirection(DrawerDirection.BOTTOM);
bottomDrawer.setSidePane(bottomDrawerPane);
// bottomDrawer.setContent(leftDrawer);
bottomDrawer.setOverLayVisible(false);
bottomDrawer.setResizableOnDrag(true);
JFXDrawer rightDrawer = new JFXDrawer();
StackPane rightDrawerPane = new StackPane();
rightDrawerPane.getStyleClass().add("blue-400");
rightDrawerPane.getChildren().add(new JFXButton("Right Content"));
rightDrawer.setDirection(DrawerDirection.RIGHT);
rightDrawer.setDefaultDrawerSize(150);
rightDrawer.setSidePane(rightDrawerPane);
// rightDrawer.setContent(bottomDrawer);
rightDrawer.setOverLayVisible(false);
rightDrawer.setResizableOnDrag(true);
JFXDrawer topDrawer = new JFXDrawer();
StackPane topDrawerPane = new StackPane();
topDrawerPane.getStyleClass().add("green-400");
topDrawerPane.getChildren().add(new JFXButton("Top Content"));
topDrawer.setDirection(DrawerDirection.TOP);
topDrawer.setDefaultDrawerSize(150);
topDrawer.setSidePane(topDrawerPane);
// topDrawer.setContent(rightDrawer);
topDrawer.setOverLayVisible(false);
topDrawer.setResizableOnDrag(true);
JFXDrawersStack drawersStack = new JFXDrawersStack();
drawersStack.setContent(content);
leftDrawer.setId("LEFT");
rightDrawer.setId("RIGHT");
bottomDrawer.setId("BOT");
topDrawer.setId("TOP");
leftButton.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
drawersStack.toggle(leftDrawer);
});
bottomButton.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
drawersStack.toggle(bottomDrawer);
});
rightButton.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
drawersStack.toggle(rightDrawer);
});
topButton.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
drawersStack.toggle(topDrawer);
});
final Scene scene = new Scene(drawersStack, 800, 800);
// scene.getStylesheets().add(DrawerDemo.class.getResource("/resources/css/jfoenix-components.css").toExternalForm());
// scene.getStylesheets().add(DrawerDemo.class.getResource("/resources/css/jfoenix-design.css").toExternalForm());
primaryStage.setTitle("JFX Drawer Demo");
primaryStage.setScene(scene);
primaryStage.setResizable(true);
primaryStage.show();
}