How do I implement a matrix of JTextFields?
Hello! I'm doing a demo of Dijkstra's Algorithm and I need an adjacency matrix as input. As a result, I need to implement a matrix of JTextFields that depends on radio buttons. For example, when I click 3 vertices, a 3x3 matrix of JTextFields should appear and so on. Does anyone know how I can do this? Thanks!
[327 byte] By [
elainedc] at [2007-9-26 5:44:15]

I'm not sure I completely understand what you want to do, but here you are anyway.
Why not setup a blank JPanel and then whenever a button is clicked, get the number of JTextFields required from that (say, 2x2).
Then create four textfields, set the JPanel's layout to java.awt.GridLayout and add the textfields to the JPanel.
are you working on minimum weight spanning trees? that is what I remember dijkstras algorithm to be.
you can do this serveral ways. you can create the text fields dynamically as needed or set them up right away based off of the number of verticies. then you just have to figure out a method to display the appropriate number of text fields.
an easy way is to give each radio button the same action listener and then the listener could count the number of clicks. then you can diplsay the right number of text fields. but there are quit a few ways to accomplish this.