精华内容
下载资源
问答
  • JavaFX 布局 GridPane

    2020-05-24 21:43:15
    GridPane

    GridPane

    展开全文
  • Java中的GridPane

    千次阅读 2019-10-24 20:41:29
    GridPane的简单使用 GridPane的介绍 GridPane类是以网格(矩阵)形式布局结点,这个结点被放在特定的行和列的索引中。 需要导入的包 import javafx.scene.layout.*; 源代码 /*GridPane*/ package testDbms; import ...

    GridPane的简单使用

    GridPane的介绍

    GridPane类是以网格(矩阵)形式布局结点,这个结点被放在特定的行和列的索引中。

    需要导入的包

    import javafx.scene.layout.*;
    

    源代码

    /*GridPane*/
    package testDbms;
    import javafx.application.Application;
    import javafx.scene.*;
    import javafx.scene.layout.*;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Circle;
    import javafx.scene.text.*;
    import javafx.scene.control.*;
    import javafx.stage.*;
    import javafx.geometry.*;
    import javafx.scene.image.*;
    public class Javatest extends Application{
    	//重写start方法
    	public void start(Stage primarystage) {
    		/*创建一个Gridpane并设置其属性*/
    		GridPane pane = new GridPane();
    		pane.setAlignment(Pos.BASELINE_CENTER);//对齐
    		pane.setPadding(new Insets(12,13,14,15));//设置上右下左的pixels
    		//pane.setGridLinesVisible(true);
    		pane.setHgap(10);
    		pane.setVgap(10);
    		
    		/*将节点放入pane中*/
    		pane.add(new Label("First name:"), 0, 0);
    		pane.add(new TextField(), 1,0);
    		Label mi = new Label("MI:");
    		pane.add(mi, 0,1);
    		GridPane.setHalignment(mi, HPos.RIGHT);//控件在单元格的对齐方式
    		pane.add(new TextField(), 1,1);
    		pane.add(new Label("Last name:"), 0,2);
    		pane.add(new TextField(), 1,2);
    		Button add=new Button("Add name");
    		pane.add(add, 1,3);
    		GridPane.setHalignment(add, HPos.RIGHT);
    	    /*创建一个scene将pane放入stage中*/
           Scene scene = new Scene(pane);
           primarystage.setTitle("show FlowPane");
           primarystage.setScene(scene);
           primarystage.show();
    	    
    	}
    	public static void main(String[] args) {
    		Application.launch(args);
    	}
    }
    

    调试结果:

    在这里插入图片描述

    参考资料:

    [1]梁勇.(2017.6).java语言程序设计(基础篇).机械工业出版社.978-7-111-57169-8.

    展开全文
  • JavaFX:GridPane概述

    2020-09-14 05:05:23
    GridPane class creates a JavaFX layout pane which places controls based on a column and row position. The grid contained in this layout is not predefined. It creates columns and rows as each c...

    The

    GridPane class creates a 
    JavaFX layout pane which places controls based on a column and row position. The grid contained in this layout is not predefined. It creates columns and rows as each control is added. This allows the grid to be completely flexible in its des JavaFX布局窗格,该窗格根据列和行的位置放置控件。 此布局中包含的网格未预定义。 在添加每个控件时,它会创建列和行。 这使得网格在其设计中完全灵活

    Nodes can be placed in each cell of the grid and can span multiple cells either vertically or horizontally. By default the rows and columns will be sized to fit their content - that is the widest child node defines the column width and the tallest child node the row height. 

    节点可以放置在网格的每个单元中,并且可以垂直或水平地跨越多个单元。 默认情况下,行和列的大小将适合其内容-即最宽的子节点定义列的宽度,而最高的子节点定义行的高度。

    进口声明 ( Import Statement )

    import javafx.scene.layout.GridPane;
    
    

    建设者 ( Constructors )

    The

    GridPane class has one constructor which does not accept any argume
    
    
    GridPane playerGrid = new GridPane();
    
    

    有用的方法 ( Useful Methods )

    Child nodes are added to the

    子节点被添加到

    GridPane using the add method specifying the node to be added with the column and row in
    
    
     //Place the Text control in column 1, row 8
    Text rank4 = new Text("4");
    playerGrid.add(rank4, 0,7);

    Note: The column and row index starts at 0. So the first cell positioned at column 1, row 1 has an index of 0, 0.

    注意:列和行的索引从0开始。因此,位于第1列,第1行的第一个单元格的索引为0、0。

    Child nodes can also span multiple columns or rows. This can be specified in the

    子节点也可以跨越多个列或行。 可以在

    add method by adding the number of columns and rows to span to the end of the arguments pas
    
    
    //Here the Text control is spanning 4 columns and 1 row
    Text title = new Text("Top Scorers in English Premier League");
    playerGrid.add(title, 0,0,4,1);

    Child nodes contained within the

    包含在

    GridPane can have their alignment along the horizontal or vertical axis by using the 
    setHalignment and 
    setValignment meth
    
    
     GridPane.setHalignment(goals4, HPos.CENTER);
    
    

    Note: The

    注意:

    VPos enum contains four constant values to define the vertical position: 
    BASELINE, 
    BOTTOM, 
    CENTER and 
    TOP. The 
    HPos enum only contains three values for the horizontal position: 
    CENTER, 
    LEFT and 
    RIGHT
    

    The padding of child nodes can also be set by using the

    Insets
    object defining the padd

    The spacing between the columns and rows can be defined by using the

    setHgap
    and
     playerGrid.setHgap(10);
    playerGrid.setVgap(10);

    The

     playerGrid.setGridLinesVisible(true);
    

    Usage Tips

    If two nodes are set to be displayed in the same cell then they will overlap in the JavaFX scene. 

    Columns and rows can be set to a preferred width and height through the use of

    ColumnConstraints
    . These are separate classes that can be used to control the size. Once defined they are added to the
    getRowConstraints().addAll
    and
    GridPane
    objects can be styled using JavaFX CSS. All the CSS properties defined under

    To see the

    GridPane
    layout in action have a look at the GridPane Example Program. It shows how to place
    RIGHT
    

    The padding of child nodes can also be set by using the

    Insets
    object defining the padd

    The spacing between the columns and rows can be defined by using the

    setHgap
    and
     playerGrid.setHgap(10);
    playerGrid.setVgap(10);

    The

     playerGrid.setGridLinesVisible(true);
    

    Usage Tips

    If two nodes are set to be displayed in the same cell then they will overlap in the JavaFX scene. 

    Columns and rows can be set to a preferred width and height through the use of

    ColumnConstraints
    . These are separate classes that can be used to control the size. Once defined they are added to the
    getRowConstraints().addAll
    and
    GridPane
    objects can be styled using JavaFX CSS. All the CSS properties defined under

    To see the

    GridPane
    layout in action have a look at the GridPane Example Program . It shows how to place

    翻译自: https://www.thoughtco.com/gridpane-overview-2033946

    展开全文
  • JavaFX 网格布局 GridPane

    2021-01-10 11:36:26
    import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control....import javafx.scene.layout.GridPane; import javafx.stage.Stage; public class Main extends Application {.
    package fx.com;
    
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.image.Image;
    import javafx.scene.layout.GridPane;
    import javafx.stage.Stage;
    public class Main extends Application {
        public static void main(String[] args) {
            Application.launch(Main.class,args);
        }
    
        @Override
        public void start(Stage primaryStage) throws Exception {
            //网格布局
            GridPane gridPane = new GridPane();
            gridPane.setStyle(
                    "-fx-background-color: #EE6AA7;" + // 颜色
                            "-fx-padding: 10;" + //内边距
                            "-fx-vgap: 10;" + //垂直边距
                            "-fx-hgap: 10;" + //水平边距
    //                        "-fx-alignment: bottom-right;" + //位置
    //                        "-fx-orientation: vertical ;" + //排列方向 	[ horizontal | vertical ]
                            "");
            gridPane.add(new Button("button1"),0,0);
            gridPane.add(new Button("button2"),1,0);
            gridPane.add(new Button("button3"),2,0);
            gridPane.add(new Button("button4"),3,0);
            gridPane.add(new Button("button5"),0,1);
            gridPane.add(new Button("button6"),1,1);
            gridPane.add(new Button("button7"),2,1);
            gridPane.add(new Button("button8"),3,1);
    
            
    
            Scene scene = new Scene(gridPane);
            primaryStage.setScene(scene);
            primaryStage.setWidth(800);
            primaryStage.setHeight(800);
            primaryStage.setTitle("网格布局");
            primaryStage.getIcons().add(new Image("http://www.haotuo.net.cn/Resources/cq/qunlogo.png"));
            primaryStage.show();
    
        }
    }
    

     

    展开全文
  • JavaFX 2.0布局窗格– GridPane

    千次阅读 2020-05-07 00:25:39
    毫无疑问, GridPane是JavaFX 2.0中功能最强大,最灵活的布局窗格。 它在由行和列组成的灵活网格中布置其子项,与Swing的GridBagLayout或HTML的表格模型非常相似。 这种方法使该窗格非常适合于任何形式的表单(例如...
  • package sample; import javafx.application.Application;...import javafx.scene.layout.GridPane; import javafx.stage.Stage; public class Main extends Application { public static void ma...
  • javafx布局之gridpane

    万次阅读 2014-07-28 21:30:06
    刚刚测试了gridpane这个布局管理器,因为它和xaml的grid布局控件很相似,
  • Ext gridPane

    2011-08-25 21:29:19
    最基本的表格,Ext中的表格最基本的功能就是按列排序,按列筛选,定制列等。当然还有一些特有的功能可以对每行数据进行收缩,也可以点击右上角小三角收缩整个表格控件。 还可以很方便的进行分页操作:
  • JavaFX2.0网格布局窗格GridPane.docx 官方翻译文档
  • 三张图片如图放置,使用GridPane面板(图片像素均为500*250) import java.awt.GridLayout; import javax.swing.GroupLayout; import javafx.application.Application; import javafx.geometry.Insets; import ...
  • 1.GridPane:它是一种 layout,布局方式类似表格,它非常的灵活,可以任意设置任何Node到任何GridCell,甚至可以自由设置GridSPan,方便一个cell跨越多行或者多列 重要属性: (1)gridLineVisible:如果设置为...
  • 1:GridPane-网格布局 为了演示这个布局 我们模拟做一个登录的窗口 如下效果 点击"清除"Button可以清除用户名和密码;点击"登录"Button会进行判断,登录成功就会跳转到另外一个页面,代码在下面 package ...
  • javaFX GridPane

    千次阅读 2016-08-10 16:04:32
    GridPane grid=new GridPane() ; //与边缘的距离 grid .setPadding (new Insets( 10 , 10 , 10 , 10 )) ; //行列间的距离 grid .setVgap ( 10 ) ; grid .setHgap ( 10 ) ; Label nameLabel = new Label...
  • JavaFX 布局——GridPane

    千次阅读 2018-12-25 22:58:42
    GridPane grid = new GridPane(); grid.setPadding(new Insets(8, 8, 8, 8)); RowConstraints rowinfo3 = new RowConstraints(); rowinfo3.setPercentHeight(50); ColumnConstraints colInfo2 = new ...
  • 史上最直观的JavaFx布局讲解(超多图)前言1、BorderPane2、HBox3、VBox4、StackPane5、GridPane6、FlowPane7、SplitPane8、Accordion9、TabPane10、AnchorPane后记 前言 代码是给机器看的,不是给人看的,可是代码...
  • javaFX的GridPane实现自适应

    千次阅读 2018-12-29 21:05:23
    GridPane pane= new GridPane(); pane.setHgap(10); pane.setVgap(10); for(int i=0;i;i++) for (int j=0;j;j++){ Label label=new Label("UNCLE"); GridPane.setHgrow(label,Priority.ALWAYS); GridPane....
  • (翻译)JavaFX2.0网格布局窗格GridPane

    千次阅读 2011-11-30 16:35:44
    public class GridPane extends Pane   GridPane将其孩子结点灵活地放置在行列网格中。若设置了边框和边缘(border and/or padding),它的内容只能在这些间隙内部。 孩子结点可以放置在任意位置并且可以跨行列...
  • Ext gridpane的问题

    2010-11-27 10:19:35
    gridpanel中可以设置首列为复选框,我现在有一个需求就是,进到页面后有些是默认选中的,这个我已经可以实现,并且也可以实现分页后的选中状态的保存, 但是我现在想要的效果是 选中后的复选框是不可编辑的,也就是...
  • 小程序示例官方源代码 背景 ( Background ) This JavaFX example code shows how to use the GridPane layout. The JavaFX scene is made up of GridPane containing a number of Text controls. The ...
  • 1.extjs中创建应用用到的方法 MVC文件结构    Ext.application() 实际上是(类)Ext.app.Application  例子  Ext.application({  name: 'MyApp',  launch: function() {  ...
  • GridPane.setColumnSpan(textTimeleft, GridPane.REMAINING); 129 GridPane.setHgrow(textTimeleft, Priority.ALWAYS); 130 grid.add(textSet, 0, 2 ); 131 132 Scene scene = new Scene(grid); 133 ...
  • 就上具体操作的图了 HBox横的一个一个摆 3、VBox HBox竖的一个一个摆 4、StackPane StackPane后来居上,新放的东西会覆盖原来的东西 5、GridPane GridPane一格一格的放,可以设置行和列 6、FlowPane FlowPane会一行...
  • GridPane gridPane=new GridPane(); //Nodes Button button=new Button("OK"); TextField textUsername=new TextField(); textUsername.setPromptText("Please Enter your Username..."); PasswordField ...
  • ListView fx:id="listview" prefWidth="742.0" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS"> <GridPane.margin> <Insets top="35" /> </GridPane.margin> </ListV

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 966
精华内容 386
关键字:

gridpane