Create JTextField dynamically in a loop

后端 未结 2 716
迷失自我
迷失自我 2021-01-22 23:11

I am beginner on Java GUI. I am writing a program that calculates the inverse of the given matrix. To do this, first i have to scan matrix. I decided to scan matrix by this way:

2条回答
  •  爱一瞬间的悲伤
    2021-01-23 00:05

    What is the concrete problem? What is class of the object? It seems a problem with the layout of the container component.

    I'd recommend you to add the matrix text fields into a dedicated JPanel with a GridLayout.

    Example:

        // ...
        matrixPanel.setLayout(new GridLayout(rowCnt, rowCnt)); // matrixPanel is the dedicated JPanel
        for(i=0;i

    More information about GridPanel in http://docs.oracle.com/javase/tutorial/uiswing/layout/grid.html

提交回复
热议问题