Java Code Examples for javafx.scene.layout.StackPane

The following examples show how to use javafx.scene.layout.StackPane. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: bisq   Source File: ProposalListItem.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public Label getMyVoteIcon() {
    Label myVoteIcon;
    if (vote != null) {
        if ((vote).isAccepted()) {
            myVoteIcon = getIcon(AwesomeIcon.THUMBS_UP, "dao-accepted-icon");
        } else {
            myVoteIcon = getIcon(AwesomeIcon.THUMBS_DOWN, "dao-rejected-icon");
        }
        if (!isMyBallotIncluded) {
            Label notIncluded = FormBuilder.getIcon(AwesomeIcon.BAN_CIRCLE);
            return new Label("", new HBox(10, new StackPane(myVoteIcon, notIncluded),
                    getIcon(AwesomeIcon.MINUS, "dao-ignored-icon")));
        }
    } else {
        myVoteIcon = getIcon(AwesomeIcon.MINUS, "dao-ignored-icon");
        if (!isMyBallotIncluded) {
            myVoteIcon.setPadding(new Insets(0, 0, 0, 25));
            return myVoteIcon;
        }
    }
    return myVoteIcon;
}
 
Example 2
private void createCameraView(){
    cameraView = new CameraView(subScene);
    cameraView.setFitWidth(400);
    cameraView.setFitHeight(300);
    cameraView.setFirstPersonNavigationEabled(true);
    cameraView.setFocusTraversable(true);
    cameraView.getCamera().setTranslateZ(-2500);
    cameraView.getCamera().setTranslateX(500);
    
    StackPane.setAlignment(cameraView, Pos.BOTTOM_RIGHT);
    StackPane.setMargin(cameraView, new Insets(10));
    
    rootPane.getChildren().add(cameraView);
    
    cameraView.startViewing();
}
 
Example 3
Source Project: helloiot   Source File: MainManagerClient.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void construct(StackPane root, Parameters params) {
    this.root = root;
    
    boolean status = Boolean.parseBoolean(HelloPlatform.getInstance().getProperty("window.status", "false"));
    if (status) {
        try {                
            showApplication();      
        } catch (HelloIoTException ex) {
            MessageUtils.showException(MessageUtils.getRoot(root), resources.getString("exception.topicinfotitle"), ex, ev -> {
                showLogin();
            });
        }
    } else {
        showLogin();
    }
}
 
Example 4
Source Project: Jupiter   Source File: AboutDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new about dialog.
 *
 * @param root root stack pane.
 */
public AboutDialog(StackPane root) {
  super();
  AnchorPane anchor = new AnchorPane();
  anchor.setMaxHeight(274);
  anchor.setMaxWidth(500);
  anchor.setMinHeight(274);
  anchor.setMaxWidth(500);
  ImageView about = Icons.about();
  Label version = new Label(Globals.VERSION);
  Label license = new Label(Globals.LICENSE);
  version.getStyleClass().add("about");
  license.getStyleClass().add("about");
  anchor.setTopAnchor(about, 0.0);
  anchor.setBottomAnchor(about, 0.0);
  anchor.setLeftAnchor(about, 0.0);
  anchor.setRightAnchor(about, 0.0);
  anchor.setTopAnchor(version, 5.0);
  anchor.setRightAnchor(version, 10.0);
  anchor.setBottomAnchor(license, 5.0);
  anchor.setLeftAnchor(license, 10.0);
  anchor.getChildren().addAll(about, version, license);
  setDialogContainer(root);
  setContent((Region) anchor);
  setTransitionType(JFXDialog.DialogTransition.TOP);
}
 
Example 5
Source Project: jfxutils   Source File: JFXChartUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Convenience method for simple and default setup of zooming on an {@link XYChart} via a
 * {@link ChartZoomManager}. Wraps the chart in the components required to implement zooming. The
 * current implementation wraps the chart in a StackPane, which has the chart and a blue
 * translucent rectangle as children. Returns the top level of the created components.
 * <p>
 * If the chart already has a parent, that parent must be a {@link Pane}, and the chart is
 * replaced with the wrapping region, and the return value could be ignored. If the chart does
 * not have a parent, the same wrapping node is returned, which will need to be added to some
 * parent.
 * <p>
 * The chart's axes must both be a type of ValueAxis.
 * <p>
 * The wrapping logic does not seem to be perfect, in fact there is a special case to handle
 * {@link BorderPane}s. If it's not found to be reliable, then create the wrapping components
 * yourself (such as in the FXML), or setup zooming before adding it to a parent.
 *
 * @param mouseFilter EventHandler that consumes events that should not trigger a zoom action
 *
 * @return The top-level Region
 */
public static Region setupZooming( XYChart<?, ?> chart,
                                   EventHandler<? super MouseEvent> mouseFilter ) {
	StackPane chartPane = new StackPane();

	if ( chart.getParent() != null )
		JFXUtil.replaceComponent( chart, chartPane );

	Rectangle selectRect = new Rectangle( 0, 0, 0, 0 );
	selectRect.setFill( Color.DODGERBLUE );
	selectRect.setMouseTransparent( true );
	selectRect.setOpacity( 0.3 );
	selectRect.setStroke( Color.rgb( 0, 0x29, 0x66 ) );
	selectRect.setStrokeType( StrokeType.INSIDE );
	selectRect.setStrokeWidth( 3.0 );
	StackPane.setAlignment( selectRect, Pos.TOP_LEFT );

	chartPane.getChildren().addAll( chart, selectRect );

	ChartZoomManager zoomManager = new ChartZoomManager( chartPane, selectRect, chart );
	zoomManager.setMouseFilter( mouseFilter );
	zoomManager.start();
	return chartPane;
}
 
Example 6
Source Project: FlyingAgent   Source File: ScanAllController.java    License: Apache License 2.0 6 votes vote down vote up
public void updateLocation(jade.util.leap.List locations) {
    this.locationsJade = locations;
    Iterator ite = locationsJade.iterator();

    listLocation.getItems().clear();
    while (ite.hasNext()) {
        StackPane stackPane = new StackPane();

        Label lbl = new Label(ite.next().toString());
        ImageView pcIcon = new ImageView(new Image("/resources/images/pc.png"));
        stackPane.getChildren().addAll(lbl, pcIcon);
        stackPane.setAlignment(lbl, Pos.CENTER_LEFT);
        stackPane.setAlignment(pcIcon, Pos.CENTER_RIGHT);
        listLocation.getItems().add(stackPane);
    }
}
 
Example 7
Source Project: Intro-to-Java-Programming   Source File: Exercise_15_06.java    License: MIT License 6 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	StackPane pane = new StackPane();
	Text text1 = new Text("Java is fun");
	Text text2 = new Text("Java is powerful");
	pane.getChildren().addAll(text1);

	pane.setOnMouseClicked(e -> {
		if (pane.getChildren().contains(text1)) {
			pane.getChildren().add(text2);
			pane.getChildren().remove(text1);
		}
		else {
			pane.getChildren().add(text1);
			pane.getChildren().remove(text2);
		}
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 150, 50);
	primaryStage.setTitle("Exercise_15_06"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 8
@Override
public void start(Stage primaryStage) {
    CodeArea codeArea = new CodeArea();

    IntFunction<Node> numberFactory = LineNumberFactory.get(codeArea);
    IntFunction<Node> arrowFactory = new ArrowFactory(codeArea.currentParagraphProperty());
    IntFunction<Node> graphicFactory = line -> {
        HBox hbox = new HBox(
                numberFactory.apply(line),
                arrowFactory.apply(line));
        hbox.setAlignment(Pos.CENTER_LEFT);
        return hbox;
    };
    codeArea.setParagraphGraphicFactory(graphicFactory);
    codeArea.replaceText("The green arrow will only be on the line where the caret appears.\n\nTry it.");
    codeArea.moveTo(0, 0);

    primaryStage.setScene(new Scene(new StackPane(codeArea), 600, 400));
    primaryStage.show();
}
 
Example 9
Source Project: ECG-Viewer   Source File: ChartViewerSkin.java    License: GNU General Public License v2.0 6 votes vote down vote up
/** 
 * Creates the node representing this control.
 * 
 * @return The node.
 */
private BorderPane createNode(ChartViewer control) {
    BorderPane borderPane = new BorderPane();
    borderPane.setPrefSize(800, 500);
    StackPane sp = new StackPane();
    sp.setMinSize(10, 10);
    sp.setPrefSize(600, 400);
    this.canvas = new ChartCanvas(getSkinnable().getChart());
    this.canvas.setTooltipEnabled(control.isTooltipEnabled());
    this.canvas.addChartMouseListener(control);
    this.canvas.widthProperty().bind(sp.widthProperty());
    this.canvas.heightProperty().bind(sp.heightProperty());
 
    this.canvas.addMouseHandler(new ZoomHandlerFX("zoom", control));
    sp.getChildren().add(this.canvas);
    
    borderPane.setCenter(sp);
    return borderPane;
}
 
Example 10
Source Project: mars-sim   Source File: FXInSwing.java    License: GNU General Public License v3.0 6 votes vote down vote up
public FXInSwing(){
    panel = new JFXPanel();
    Platform.runLater(new Runnable(){
        @Override
        public void run() {
            stack = new StackPane();
            scene = new Scene(stack,300,300);
            hello = new Text("Hello");

            scene.setFill(Color.BLACK);
            hello.setFill(Color.WHEAT);
            hello.setEffect(new Reflection());

            panel.setScene(scene);
            stack.getChildren().add(hello);

            wait = false;
        }
    });
    this.getContentPane().add(panel);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setSize(300, 300);
    this.setVisible(true);
}
 
Example 11
Source Project: medusademo   Source File: Test.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(gauge);
    pane.setPadding(new Insets(10));
    pane.setBackground(new Background(new BackgroundFill(Color.rgb(50, 50, 50), CornerRadii.EMPTY, Insets.EMPTY)));

    Scene scene = new Scene(pane);

    stage.setTitle("Test");
    stage.setScene(scene);
    stage.show();

    // Calculate number of nodes
    calcNoOfNodes(pane);
    System.out.println(noOfNodes + " Nodes in SceneGraph");

}
 
Example 12
Source Project: JFX8CustomControls   Source File: Demo.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    Led control = new Led();
    control.setPrefWidth(200);
    control.setPrefHeight(200);

    StackPane pane = new StackPane();
    pane.getChildren().setAll(control);

    Scene scene = new Scene(pane);

    stage.setTitle("JavaFX Led Region");
    stage.setScene(scene);
    stage.show();

    control.setBlinking(true);
    
    calcNoOfNodes(scene.getRoot());
    System.out.println(noOfNodes + " Nodes in SceneGraph");
}
 
Example 13
Source Project: ChatRoom-JavaFX   Source File: EmojiDisplayer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 创建emoji图片节点
 *
 * @param emoji
 *            emoji
 * @param size
 *            图片显示大小
 * @param pad
 *            图片间距
 * @param isCursor
 *            是否需要图片光标及鼠标处理事件
 * @return
 */
public static Node createEmojiNode(Emoji emoji, int size, int pad) {
	// 将表情放到stackpane中
	StackPane stackPane = new StackPane();
	stackPane.setMaxSize(size, size);
	stackPane.setPrefSize(size, size);
	stackPane.setMinSize(size, size);
	stackPane.setPadding(new Insets(pad));
	ImageView imageView = new ImageView();
	imageView.setFitWidth(size);
	imageView.setFitHeight(size);
	imageView.setImage(ImageCache.getInstance().getImage(getEmojiImagePath(emoji.getHex())));
	stackPane.getChildren().add(imageView);

	return stackPane;
}
 
Example 14
Source Project: marathonv5   Source File: FlowPaneSample.java    License: Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();
    FlowPane fp = new FlowPane();
    fp.setAlignment(Pos.CENTER);

    Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    fp.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle[] littleRecs = new Rectangle[4];
    Rectangle[] bigRecs = new Rectangle[4];
    for (int i = 0; i < 4; i++) {
        littleRecs[i] = new Rectangle(14, 14, Color.web("#1c89f4"));
        bigRecs[i] = new Rectangle(16, 12, Color.web("#349b00"));
        fp.getChildren().addAll(littleRecs[i], bigRecs[i]);
        FlowPane.setMargin(littleRecs[i], new Insets(2, 2, 2, 2));
    }
    sp.getChildren().addAll(rectangle, fp);
    return new Group(sp);
}
 
Example 15
Source Project: OEE-Designer   Source File: DashboardController.java    License: MIT License 6 votes vote down vote up
private void onSelectPlannedDowntimePareto() throws Exception {
	List<ParetoItem> items = EquipmentLossManager.getParetoData(equipmentLoss, TimeLoss.PLANNED_DOWNTIME);

	Number divisor = equipmentLoss.getLoss(TimeLoss.PLANNED_DOWNTIME).getSeconds();

	StackPane spPlannedDowntimePareto = new StackPane();

	AnchorPane.setBottomAnchor(spPlannedDowntimePareto, 0.0);
	AnchorPane.setLeftAnchor(spPlannedDowntimePareto, 0.0);
	AnchorPane.setRightAnchor(spPlannedDowntimePareto, 0.0);
	AnchorPane.setTopAnchor(spPlannedDowntimePareto, 0.0);

	apPlannedDowntimePareto.getChildren().clear();
	apPlannedDowntimePareto.getChildren().add(0, spPlannedDowntimePareto);

	ParetoChartController controller = new ParetoChartController();
	controller.createParetoChart(DesignerLocalizer.instance().getLangString("planned.downtime.pareto"),
			spPlannedDowntimePareto, items, divisor, DesignerLocalizer.instance().getLangString("time.by.reason"));
}
 
Example 16
Source Project: Enzo   Source File: Demo.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    HBox lcd = new HBox();
    lcd.setPadding(new Insets(15, 15, 15, 15));
    lcd.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
    lcd.setSpacing(10);
    lcd.setAlignment(Pos.CENTER);
    lcd.setFillHeight(false);
    HBox.setMargin(seg3, new Insets(0, 20, 0, 0));
    lcd.getChildren().addAll(seg0, seg1, seg2, seg3);
    /*
    for (int i = 0 ; i < 256 ; i++) {
        System.out.println(i + "   :   " + Character.toString((char) i));
    }
    */
    StackPane pane = new StackPane();
    pane.getChildren().setAll(lcd);

    Scene scene = new Scene(pane, Color.BLACK);

    stage.setTitle("SevenSegment DemoGauge");
    stage.setScene(scene);
    stage.show();

    timer.start();
}
 
Example 17
Source Project: samples   Source File: HelloFX.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void start(Stage stage) {
    String javaVersion = System.getProperty("java.version");
    String javafxVersion = System.getProperty("javafx.version");
    Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
    Scene scene = new Scene(new StackPane(l), 640, 480);
    stage.setScene(scene);
    stage.show();
}
 
Example 18
Source Project: mars-sim   Source File: WaitIndicatorDemo.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void start(Stage stage) {
 // public WaitIndicatorDemo(Stage stage) {	
  	this.stage = stage;
  	//stage = new Stage();
  	indicator = new CircularProgressIndicator();
      StackPane pane = new StackPane(indicator);
      
//stackPane.setScaleX(1.2);
//stackPane.setScaleY(1.2);

      pane.setBackground(Background.EMPTY);
      pane.setStyle(
   		   //"-fx-border-style: none; "
   		   //"-fx-background-color: #231d12; "
      			"-fx-background-color: transparent; "
      			+ 
      			"-fx-background-radius: 1px;"
   		   );
      
      Scene scene = new Scene(pane, 128, 128, true);

scene.setFill(Color.TRANSPARENT);

stage.requestFocus();
      stage.initStyle(StageStyle.TRANSPARENT);
      stage.setTitle("Circular Progress Indicator");
      stage.setScene(scene);
      stage.toFront();
      stage.show();
      
      indicator.setProgress(ProgressIndicator.INDETERMINATE_PROGRESS);
  }
 
Example 19
Source Project: medusademo   Source File: FunLevelGaugeDemo.java    License: Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(gauge);
    pane.setPadding(new Insets(10));

    Scene scene = new Scene(pane);

    stage.setTitle("Medusa FunLevelGauge");
    stage.setScene(scene);
    stage.show();

    timer.start();
}
 
Example 20
Source Project: JFoenix   Source File: CheckBoxDemo.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {

    FlowPane main = new FlowPane();
    main.setVgap(20);
    main.setHgap(20);

    CheckBox cb = new CheckBox("CheckBox");
    JFXCheckBox jfxCheckBox = new JFXCheckBox("JFX CheckBox");
    JFXCheckBox customJFXCheckBox = new JFXCheckBox("Custom JFX CheckBox");
    customJFXCheckBox.getStyleClass().add("custom-jfx-check-box");

    main.getChildren().add(cb);
    main.getChildren().add(jfxCheckBox);
    main.getChildren().add(customJFXCheckBox);

    StackPane pane = new StackPane();
    pane.getChildren().add(main);
    StackPane.setMargin(main, new Insets(100));
    pane.setStyle("-fx-background-color:WHITE");

    final Scene scene = new Scene(pane, 600, 200);
    scene.getStylesheets().add(CheckBoxDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    stage.setTitle("JFX CheckBox Demo ");
    stage.setScene(scene);
    stage.setResizable(false);
    stage.show();

}
 
Example 21
Source Project: marathonv5   Source File: TaskSample.java    License: Apache License 2.0 5 votes vote down vote up
public TaskSample() {
    TableView<DailySales> tableView = new TableView<DailySales>();
    Region veil = new Region();
    veil.setStyle("-fx-background-color: rgba(0, 0, 0, 0.4)");
    ProgressIndicator p = new ProgressIndicator();
    p.setMaxSize(150, 150);
    //Define table columns
    TableColumn idCol = new TableColumn();
    idCol.setText("ID");
    idCol.setCellValueFactory(new PropertyValueFactory("dailySalesId"));
    tableView.getColumns().add(idCol);
    TableColumn qtyCol = new TableColumn();
    qtyCol.setText("Qty");
    qtyCol.setCellValueFactory(new PropertyValueFactory("quantity"));
    tableView.getColumns().add(qtyCol);
    TableColumn dateCol = new TableColumn();
    dateCol.setText("Date");
    dateCol.setCellValueFactory(new PropertyValueFactory("date"));
    dateCol.setMinWidth(240);
    tableView.getColumns().add(dateCol);
    StackPane stack = new StackPane();
    stack.getChildren().addAll(tableView, veil, p);

    // Use binding to be notified whenever the data source chagnes
    Task<ObservableList<DailySales>> task = new GetDailySalesTask();
    p.progressProperty().bind(task.progressProperty());
    veil.visibleProperty().bind(task.runningProperty());
    p.visibleProperty().bind(task.runningProperty());
    tableView.itemsProperty().bind(task.valueProperty());

    getChildren().add(stack);
    new Thread(task).start();
}
 
Example 22
Source Project: ApkToolPlus   Source File: ActivityManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 启动一个Activity
 *
 * @param url   界面布局文件url
 * @param pos   界面位置
 */
public static void startActivity(URL url, Pos pos){
    try {
        Parent view = FXMLLoader.load(url);
        StackPane.setAlignment(view, pos);
        getRootView().getChildren().add(view);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 23
Source Project: Enzo   Source File: Demo.java    License: Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane();
    pane.getChildren().setAll(control);

    Scene scene = new Scene(pane, Color.DARKGRAY);

    stage.setScene(scene);
    stage.show();

    timer.start();
}
 
Example 24
Source Project: helloiot   Source File: TopicsTemplate.java    License: GNU General Public License v3.0 5 votes vote down vote up
public TopicsTemplate() {
    
    ResourceBundle resources = ResourceBundle.getBundle("com/adr/helloiot/fxml/clientlogin"); 
    text = resources.getString("title.templates");
    
    list = new ListView<>();
    list.setDisable(true);
    list.getStyleClass().add("unitlistview");
    list.setCellFactory(l -> new TemplatesListCell());
    list.setOnMouseClicked(e -> {
        if (e.getClickCount() == 2 && actionok != null) {
            actionok.accept(new ActionEvent());
        }
    });
    Node loading = Dialogs.createSmallLoadingNode();          
    container = new StackPane(list, loading);
    container.setPadding(new Insets(15));
    
    
    // Load list of templates         
    CompletableAsync.handle(
        loadTemplatesList(),
        templateslist -> {
            container.getChildren().remove(loading);                
            list.setDisable(false);
            list.setItems(FXCollections.observableList(Arrays.asList(templateslist)));
            list.getSelectionModel().selectFirst();
        },
        ex -> {
            container.getChildren().remove(loading);
            MessageUtils.showException(MessageUtils.getRoot(container), resources.getString("title.templates"),  resources.getString("exception.cannotloadtemplateslist"), ex);             
        });        
    
}
 
Example 25
@Override
public void start(Stage stage) throws Exception {
    StackPane sp = new StackPane();
    sp.getChildren().add(createDemoNode());
    Scene scene = new Scene(sp, 768, 512);
    stage.setScene(scene);
    stage.setTitle("Orson Charts: CategoryMarkerFXDemo1.java");
    stage.show();
}
 
Example 26
Source Project: Quelea   Source File: DisplayCanvas.java    License: GNU General Public License v3.0 5 votes vote down vote up
public final ImageView getNewImageView() {
    ImageView ret = new ImageView(Utils.getImageFromColour(Color.BLACK));
    ret.setFitHeight(getHeight());
    ret.setFitWidth(getWidth());
    StackPane.setAlignment(ret, Pos.CENTER);
    return ret;
}
 
Example 27
Source Project: milkman   Source File: TinySpinner.java    License: MIT License 5 votes vote down vote up
public TinySpinner() {
	this.getStyleClass().add("spinner");
	this.getChildren().add(spinner("tiny-spinner", -40));
	
	cancellation = button("tiny-cancellation", icon(FontAwesomeIcon.TIMES, "1.5em"));
	StackPane.setAlignment(cancellation, Pos.CENTER);
	this.getChildren().add(cancellation);
}
 
Example 28
Source Project: triplea   Source File: TripleACheckBoxSkin.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void layoutRect() {
  StackPane.setAlignment(rect, Pos.BOTTOM_LEFT);
  rect.getStyleClass().setAll("box");
  rect.widthProperty()
      .bind(
          Bindings.multiply(Bindings.min(pane.widthProperty(), pane.heightProperty()), 2.0 / 3));
  rect.heightProperty()
      .bind(
          Bindings.multiply(Bindings.min(pane.widthProperty(), pane.heightProperty()), 2.0 / 3));
  pane.getChildren().add(rect);
}
 
Example 29
Source Project: WorkbenchFX   Source File: TabSkin.java    License: Apache License 2.0 5 votes vote down vote up
private void initializeParts() {
  closeIconShape = new StackPane();
  closeIconShape.getStyleClass().add("shape");
  closeBtn = new Button("", closeIconShape);
  closeBtn.getStyleClass().addAll("icon", "close-icon");

  nameLbl = new Label();
  nameLbl.getStyleClass().add("tab-name-lbl");

  controlBox = new HBox();
  controlBox.getStyleClass().add("tab-box");
}
 
Example 30
Source Project: trex-stateless-gui   Source File: PacketHex.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Show dialog
 *
 * @param selectedText
 * @return
 */
private String showDialog(String selectedText) {
    Dialog dialog = new Dialog();
    dialog.setTitle("Edit Hex");
    dialog.setResizable(false);
    TextField text1 = new TextField();
    text1.addEventFilter(KeyEvent.KEY_TYPED, hex_Validation(2));
    text1.setText(selectedText);
    StackPane dialogPane = new StackPane();
    dialogPane.setPrefSize(150, 50);
    dialogPane.getChildren().add(text1);
    dialog.getDialogPane().setContent(dialogPane);
    ButtonType buttonTypeOk = new ButtonType("Save", ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().add(buttonTypeOk);
    dialog.setResultConverter(new Callback<ButtonType, String>() {
        @Override
        public String call(ButtonType b) {
            
            if (b == buttonTypeOk) {
                switch (text1.getText().length()) {
                    case 0:
                        return null;
                    case 1:
                        return "0".concat(text1.getText());
                    default:
                        return text1.getText();
                }
            }
            return null;
        }
    });
    
    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        return result.get();
    }
    return null;
}