1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| JFrame frame= new JFrame();
frame.setSize(400,300);
frame.setTitle("hello");
JPanel pane= new JPanel(new GridBagLayout());
XMLParser nl= new XMLParser() ;
NodeList list1;
List<String>lista = new ArrayList<>();
list1= nl.RecupererParam();
for (int i = 0; i < list1.getLength(); i++) {
lista.add (list1.item(i).getTextContent());
}
int number=8;
int count=0;
GridBagConstraints gbc = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(2,4,2,4), 0, 0);
Iterator<String> it = lista.iterator();
while(it.hasNext()){
JLabel label = new JLabel(it.next());
// une étiquette pour le champ
gbc.gridx = 0;
gbc.weightx = 0;
gbc.fill = GridBagConstraints.NONE;
pane.add(label, gbc);
JTextField textField = new JTextField("Param");
// le champ
//textField.setPreferredSize( new Dimension( 500, 24 ) );
ImageIcon imgg= new ImageIcon("images/help1.png");
JButton btn = new JButton(imgg);
btn.setBorderPainted(false);
btn.setFocusPainted(false);
btn.setContentAreaFilled(false);
JPanel panel = new JPanel(new BorderLayout());
panel.add(textField);
panel.add(btn,BorderLayout.EAST);
gbc.gridx = 1;
gbc.weightx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
pane.add(panel, gbc);
/* JLabel label = new JLabel(lista.get(0));
JLabel label1= new JLabel(lista.get(1));
pane.add(label,BorderLayout.CENTER);
pane.add(label1,BorderLayout.AFTER_LAST_LINE);*/
frame.add(pane);
frame.setVisible(true);
frame.pack();
}
} |
Partager