首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >javafx HBox移动元素

javafx HBox移动元素
EN

Stack Overflow用户
提问于 2013-11-30 09:56:14
回答 1查看 2.3K关注 0票数 0

拿着这个

代码语言:javascript
复制
  package net.makerimages.starling.src.window;

import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import net.makerimages.starling.src.Main;

 /**
 * Created with IntelliJ IDEA.
 * User: Kodukas
 * Date: 29.11.13
 * Time: 23:53
 * To change this template use File | Settings | File Templates.
 */
public class TopBar extends HBox
{
public Button closeButton;
public Button minMaxButton;
public Label titleLabel;

public TopBar()
{
    titleLabel=new Label("Starling browser");
    closeButton=new Button("X");

    closeButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent actionEvent) {
            Platform.exit();
        }
    });
    closeButton.setStyle("-fx-opacity: 0.9;");

    minMaxButton=new Button("|  |");
    minMaxButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent actionEvent) {

            if(Main.stg.isFullScreen()==false)
            {
                 Main.stg.setFullScreen(true);
                minMaxButton.setText("||");
            }
            else if(Main.stg.isFullScreen()==true)
            {
                Main.stg.setFullScreen(false);
                minMaxButton.setText("|  |");
                Main.browser.setMaxHeight(Main.browser.getHeight()-20);
            }
        }
    });



    this.getChildren().addAll(closeButton,minMaxButton);
    this.getChildren().add(titleLabel);
    setMargin(titleLabel,new Insets(0,10,0,0));


}
}

我想要的是右边的按钮和中间的标签,尽管我尝试过的任何东西都不起作用。(这被用作borderPane中的工具栏)我尝试了所有我知道的东西。

EN

回答 1

Stack Overflow用户

发布于 2013-12-02 15:39:58

我建议使用一个GridPane并将元素添加到它们需要它们的行和列中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20298863

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档