Creating arrays of swing components or specifically JTextFields and giving each of them different properties in java
问题 So I'm trying to create a large number of JTextField s and use them as nodes in a binary tree program I'm trying to make. Is there a way to create an array of JTextFields, something like: JTextField nodes[]=new JTextField[30]; If so, how do I define or give every one of them different properties or the property I want them to have? Thanks! 回答1: JTextField[] fields = new JTextField[30]; for(int i = 0; i<fields.length; i++){ fields = new JTextField(); } //then you can access them and modify