When I click on the button, the text is not displayed in the JTextField .
And even simple System.out.prntln(".."); not displayed in the console.

The code for the button was generated independently:

 jButton1.setText("нажимай"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); 

The processing method itself:

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { for (Person h : people) { jLabel3.setText(String.valueOf(h.toString())); System.out.println("Clicked:"); System.out.println(h.toString()); } } 
  • So maybe just a collection (or an array) of people empty? - Regent
  • Yes. it was just that in the driver class without swing everything worked and now it’s really necessary - Alex
  • If there are 0 elements in a person , it is not surprising that nothing is displayed on the screen and no text is set in jLabel3 .. And in any case it is very strange to set the text for all elements of the collection in turn. With the same success, you can simply set the text from the last element. And the construction of String.valueOf(h.toString()) redundant: if h cannot be null , then it suffices to use only h.toString() . Otherwise, only String.valueOf(h) . - Regent
  • Thanks, I will consider everything! - Alex

0