本文整理匯總了Java中javafx.scene.Group類的典型用法代碼示例。如果您正苦於以下問題:Java Group類的具體用法?Java Group怎麽用?Java Group使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Group類屬於javafx.scene包,在下文中一共展示了Group類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import javafx.scene.Group; //導入依賴的package包/類
@Override
public void start(Stage stage) {
Scene scene = new Scene(new Group());
scene.setFill(Color.ALICEBLUE);
stage.setScene(scene);
stage.show();
stage.setTitle("ChoiceBox Sample");
stage.setWidth(300);
stage.setHeight(200);
label.setFont(Font.font("Arial", 25));
label.setLayoutX(40);
final String[] greetings = new String[]{"Hello", "Hola", "Привет", "你好",
"こんにちは"};
final ChoiceBox cb = new ChoiceBox(FXCollections.observableArrayList(
"English", "Español", "Русский", "簡體中文", "日本語")
);
cb.getSelectionModel().selectedIndexProperty().addListener(
(ObservableValue<? extends Number> ov,
Number old_val, Number new_val) -> {
label.setText(greetings[new_val.intValue()]);
});
cb.setTooltip(new Tooltip("Select the language"));
cb.setValue("English");
HBox hb = new HBox();
hb.getChildren().addAll(cb, label);
hb.setSpacing(30);
hb.setAlignment(Pos.CENTER);
hb.setPadding(new Insets(10, 0, 0, 10));
((Group) scene.getRoot()).getChildren().add(hb);
}
示例2: init
import javafx.scene.Group; //導入依賴的package包/類
private void init(Stage primaryStage) {
Group root = new Group();
primaryStage.setScene(new Scene(root));
NumberAxis xAxis = new NumberAxis("Values for X-Axis", 0, 3, 1);
NumberAxis yAxis = new NumberAxis("Values for Y-Axis", 0, 3, 1);
ObservableList<XYChart.Series<Double,Double>> lineChartData = FXCollections.observableArrayList(
new LineChart.Series<Double,Double>("Series 1", FXCollections.observableArrayList(
new XYChart.Data<Double,Double>(0.0, 1.0),
new XYChart.Data<Double,Double>(1.2, 1.4),
new XYChart.Data<Double,Double>(2.2, 1.9),
new XYChart.Data<Double,Double>(2.7, 2.3),
new XYChart.Data<Double,Double>(2.9, 0.5)
)),
new LineChart.Series<Double,Double>("Series 2", FXCollections.observableArrayList(
new XYChart.Data<Double,Double>(0.0, 1.6),
new XYChart.Data<Double,Double>(0.8, 0.4),
new XYChart.Data<Double,Double>(1.4, 2.9),
new XYChart.Data<Double,Double>(2.1, 1.3),
new XYChart.Data<Double,Double>(2.6, 0.9)
))
);
LineChart chart = new LineChart(xAxis, yAxis, lineChartData);
root.getChildren().add(chart);
}
示例3: start
import javafx.scene.Group; //導入依賴的package包/類
@Override
public void start(Stage stage) {
Scene scene = new Scene(new Group());
stage.setTitle("Europian Country Population");
stage.setWidth(500);
stage.setHeight(500);
ObservableList<PieChart.Data> pieChartData =
FXCollections.observableArrayList(
new PieChart.Data("Belgium", 3),
new PieChart.Data("France", 26),
new PieChart.Data("Germany", 35),
new PieChart.Data("Netherlands", 7),
new PieChart.Data("Sweden", 4),
new PieChart.Data("United Kingdom", 25));
final PieChart pieChart = new PieChart(pieChartData);
pieChart.setTitle("Country Population");
((Group) scene.getRoot()).getChildren().add(pieChart);
stage.setScene(scene);
stage.show();
}
示例4: start
import javafx.scene.Group; //導入依賴的package包/類
@Override
public void start(Stage stage) {
Group root = new Group();
Scene scene = new Scene(root, 300, 250);
stage.setScene(scene);
stage.setTitle("Progress Controls");
for (int i = 0; i < values.length; i++) {
final Label label = labels[i] = new Label();
label.setText("progress:" + values[i]);
final ProgressBar pb = pbs[i] = new ProgressBar();
pb.setProgress(values[i]);
final ProgressIndicator pin = pins[i] = new ProgressIndicator();
pin.setProgress(values[i]);
final HBox hb = hbs[i] = new HBox();
hb.setSpacing(5);
hb.setAlignment(Pos.CENTER);
hb.getChildren().addAll(label, pb, pin);
}
final VBox vb = new VBox();
vb.setSpacing(5);
vb.getChildren().addAll(hbs);
scene.setRoot(vb);
stage.show();
}
示例5: alwaysInTop
import javafx.scene.Group; //導入依賴的package包/類
public static void alwaysInTop(Alert alert) {
try{
DialogPane root = alert.getDialogPane();
Stage dialogStage = new Stage(StageStyle.UTILITY);
for (ButtonType buttonType : root.getButtonTypes()) {
ButtonBase button = (ButtonBase) root.lookupButton(buttonType);
button.setOnAction(evt -> {
root.setUserData(buttonType);
dialogStage.close();
});
}
root.getScene().setRoot(new Group());
Scene scene = new Scene(root);
dialogStage.setScene(scene);
dialogStage.initModality(Modality.APPLICATION_MODAL);
dialogStage.setAlwaysOnTop(true);
dialogStage.setResizable(false);
dialogStage.showAndWait();
}catch(Exception e){
}
// Optional<ButtonType> result = Optional.ofNullable((ButtonType) root.getUserData());
}
示例6: generate
import javafx.scene.Group; //導入依賴的package包/類
/**
* Generates a panel image form char.
* <p>First, this function converts ch to upper case if ch is lower case.</p>
* <p>Then, this generates javafx's image from ch.And return it.</p>
* You can fix the resolution of image through {@link capslock.CharPanelGenerator#PANEL_IMAGE_SIZE}
* and {@link capslock.CharPanelGenerator#FONT_SIZE}.
* @param ch パネルの生成に使う1文字.
* @param color 背景色.
* @return 生成されたパネル.
*/
static final Image generate(char ch, Color color){
final Label label = new Label(Character.toString(Character.toUpperCase(ch)));
label.setMinSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
label.setMaxSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
label.setPrefSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
label.setFont(Font.font(FONT_SIZE));
label.setAlignment(Pos.CENTER);
label.setTextFill(Color.WHITE);
label.setBackground(new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY)));
final Scene scene = new Scene(new Group(label));
final WritableImage img = new WritableImage(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
scene.snapshot(img);
return img ;
}
示例7: makeErrorGUI
import javafx.scene.Group; //導入依賴的package包/類
/**
* Make a Error Dialog
* @return BorderPane
*/
public void makeErrorGUI() {
root = new Group();
Scene scene = new Scene(root, 360, 185, Color.WHITE);
ImagePattern pattern = new ImagePattern(new Image("icon/bk2.jpg"));
scene.setFill(pattern);
setTitle("Error");
setScene(scene);
Image appIcon = new Image("icon/ERROR.png");
getIcons().add(appIcon);
BorderPane bp = new BorderPane();
textArea = new TextArea(message);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(320);
textArea.setMaxHeight(130);
HBox hBox = new HBox();
hBox.setSpacing(5);
hBox.setPadding(new Insets(5,0,0,0));
hBox.setAlignment(Pos.BOTTOM_RIGHT);
hBox.getChildren().addAll(openLogButton,okButton);
bp.setCenter(textArea);
bp.setBottom(hBox);
root.getChildren().add(bp);
sizeToScene();
setX(owner.getX() + Math.abs(owner.getWidth() - scene.getWidth()) / 2.0);
setY(owner.getY() + Math.abs(owner.getHeight() - scene.getHeight()) / 2.0);
}
示例8: init
import javafx.scene.Group; //導入依賴的package包/類
private void init(Stage primaryStage) {
Group root = new Group();
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root, 140,140));
Rectangle rect = new Rectangle(20, 20, 100, 100);
rect.setArcHeight(20);
rect.setArcWidth(20);
rect.setFill(Color.ORANGE);
root.getChildren().add(rect);
rotateTransition = RotateTransitionBuilder.create()
.node(rect)
.duration(Duration.seconds(4))
.fromAngle(0)
.toAngle(720)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
}
示例9: configureDigits
import javafx.scene.Group; //導入依賴的package包/類
private void configureDigits() {
for (int i : numbers) {
digits[i] = new Text("0");
digits[i].setFont(FONT);
digits[i].setTextOrigin(VPos.TOP);
digits[i].setLayoutX(2.3);
digits[i].setLayoutY(-1);
Rectangle background;
if (i < 6) {
background = createBackground(Color.web("#a39f91"), Color.web("#FFFFFF"));
digits[i].setFill(Color.web("#000000"));
} else {
background = createBackground(Color.web("#bdbeb3"), Color.web("#FF0000"));
digits[i].setFill(Color.web("#FFFFFF"));
}
digitsGroup[i] = new Group(background, digits[i]);
}
}
示例10: FxMapItem
import javafx.scene.Group; //導入依賴的package包/類
public FxMapItem(FxMapModel model, MapData data) {
mapModel = model;
itemData = data;
rect = new Rect();
rectangle = new Rectangle();
label = new Label(itemData.getName());
tooltip = new Tooltip(itemData.getName());
tooltip.setFont(new Font(DEFAULT_TOOLTIP_FONT_SIZE));
mainNode = new Group(rectangle, label);
Tooltip.install(label, tooltip);
applyStyle(model.getStyle());
if (data.hasChildrenData()) {
rectangle.setEffect(new Glow());
}
propertyChangeSupport = new PropertyChangeSupport(FxMapItem.this);
propertyChangeSupport.addPropertyChangeListener(model);
initInteractivity();
}
示例11: start
import javafx.scene.Group; //導入依賴的package包/類
@Override
public void start(Stage primaryStage) {
if (primaryStage == null) {
return;
}
Group group = new Group();
Rectangle rect = new Rectangle(20,20,200,200);
FadeTransition ft = new FadeTransition(Duration.millis(5000), rect);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.play();
group.getChildren().add(rect);
Scene scene = new Scene(group, 300, 200);
primaryStage.setScene(scene);
primaryStage.show();
}
示例12: createIconContent
import javafx.scene.Group; //導入依賴的package包/類
public static Node createIconContent() {
StackPane sp = new StackPane();
VBox vbox = new VBox(3);
vbox.setAlignment(Pos.CENTER);
vbox.setPadding(new Insets(5, 5, 5, 5));
Rectangle rectangle = new Rectangle(32, 62, Color.LIGHTGREY);
rectangle.setStroke(Color.BLACK);
vbox.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
Rectangle r1 = new Rectangle(18, 14, Color.web("#1c89f4"));
Rectangle r2 = new Rectangle(18, 14, Color.web("#349b00"));
Rectangle r3 = new Rectangle(18, 20, Color.web("#349b00"));
vbox.getChildren().addAll(r1, r2, r3);
sp.getChildren().addAll(rectangle, vbox);
return new Group(sp);
}
示例13: drawBackground
import javafx.scene.Group; //導入依賴的package包/類
private static void drawBackground(Group parent, Pane parentPane) {
DoubleStream.iterate(ENTRY_HEIGHT / 2, i -> i + ENTRY_HEIGHT).limit(10)
.mapToObj(y -> {
Line line = new Line();
line.setStartX(0);
line.endXProperty().bind(parentPane.widthProperty());
// line.setEndX(MAX_WIDTH);
line.setStartY(y);
line.setEndY(y);
line.setStroke(BACKGROUD_LINES_COLOR);
line.setStrokeWidth(1.0);
return line;
})
.forEach(parent.getChildren()::add);
}
示例14: drawSelection
import javafx.scene.Group; //導入依賴的package包/類
private static void drawSelection(Group parent, Pane content) {
// Rectangle selection1 = new Rectangle();
Rectangle selection2 = new Rectangle();
Stream.of(selection2).forEach(rect -> {
rect.setMouseTransparent(true);
rect.setStroke(SELECTION_STROKE_COLOR);
rect.setStrokeWidth(SELECTION_STROKE_WIDTH);
rect.setStrokeLineCap(StrokeLineCap.ROUND);
rect.setFill(SELECTION_FILL_COLOR);
rect.yProperty().bind(JfxUtils.ZERO_PROPERTY);
rect.heightProperty().bind(content.heightProperty());
});
//
// selection1.setX(200);
// selection1.setWidth(100);
selection2.setX(500);
selection2.setWidth(500);
parent.getChildren().addAll(selection2);
}
示例15: drawBackground
import javafx.scene.Group; //導入依賴的package包/類
private static void drawBackground(Group parent, Pane content) {
DoubleStream.iterate(ENTRY_HEIGHT / 2, i -> i + ENTRY_HEIGHT).limit(10)
.mapToObj(y -> {
Line line = new Line();
line.setStartX(0);
line.endXProperty().bind(content.widthProperty());
// line.setEndX(MAX_WIDTH);
line.setStartY(y);
line.setEndY(y);
line.setStroke(BACKGROUD_LINES_COLOR);
line.setStrokeWidth(1.0);
return line;
})
.forEach(parent.getChildren()::add);
}