javafx组合框下拉菜单从屏幕边缘出来 [英] javafx combobox dropdown go out from the edges of the screen

查看:2543
本文介绍了javafx组合框下拉菜单从屏幕边缘出来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有最后一个版本的java(8_40)和javaFX。



我有一个包含10个项目的复选框。
我编译并运行程序。
如果我将程序窗口移动到监视器屏幕的底部,下拉列表从监视器屏幕中出来。



相反,如果我尝试使用场景生成器2.0做相同的布局,点击预览,下拉菜单会自动移动



为什么不正确显示场景生成器,而不是编译和运行?



问题是一样的,如果我通过代码做图形是如果我使用文件fxml。



我把一个小程序的例子下面给我此错误:



组件CustomControl.java

  public class CustomControl extends VBox {

public CustomControl(){
ComboBox< String> asd = new ComboBox< String>();

ObservableList< String> data = FXCollections.observableArrayList();
asd.setItems(数据);

data.add(1);
data.add(2);
data.add(3);
data.add(4);
data.add(5);
data.add(6);
data.add(7);
data.add(8);
data.add(9);
data.add(10);

getChildren()。add(asd);
}
}

Main.java / p>

  public class CustomControlExample extends Application {
public static void main(String [] args){
launch args);
}
String address =;

@Override public void start(Stage Stage){
stage.setTitle(ComboBoxSample);
场景scene = new Scene(new CustomControl());

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

EDIT p>

屏幕截图左边的弹出窗口移出屏幕边框(eclipse)
而右边的弹出窗口会自动移动(场景



解决方案

查看此图片:





这很容易解决,只是改变可见行数。 / p>

I have the last version of java(8_40) and javaFX.

I have a checkbox with 10 items. I compile and run the program. If i move the program window to the bottom of the monitor screen, the dropdown list go out from the monitor screen. It is impossible to click the items out the screen.

Instead, if I try to do the same layout with scenes builder 2.0, click on preview, the dropdown is moved automatically up for not exit the screen.

Why with scenes builder is properly displayed, instead with "compile and run" not?

The problem is the same that if I do graphics via code is that if I use the files fxml.

I put below a small program example that gives me this error:

Component CustomControl.java

public class CustomControl extends VBox {

    public CustomControl() {
        ComboBox<String> asd = new ComboBox<String>();

        ObservableList<String> data = FXCollections.observableArrayList();       
        asd.setItems(data);

        data.add("1");
        data.add("2");
        data.add("3");
        data.add("4");
        data.add("5");
        data.add("6");
        data.add("7");
        data.add("8");
        data.add("9");
        data.add("10");

        getChildren().add(asd);
    }
}

Main.java

public class CustomControlExample extends Application {
    public static void main(String[] args) {
        launch(args);
    }       
    String address = " ";

    @Override public void start(Stage stage) {
        stage.setTitle("ComboBoxSample");
        Scene scene = new Scene(new CustomControl());        

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

EDIT:

Screen-shot on the left the pop-up go out of the screen border (eclipse) While, on the right the pop-up is automatically moved (Scene builder)

解决方案

See this image:

It is easy to solve, just change the visible row count.

这篇关于javafx组合框下拉菜单从屏幕边缘出来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆