java - Is there a point to this line of code? -


Until I came to someone's code on dreamincode, I had difficulty creating a sudoku grid using the readers But they did not really interpret it and I was thinking that any person here can explain me the class room. Thinking about this because the class is empty, even though the grid still works, so I'm confused. Thank you. Import java.awt. *; Import javax.swing *; Import javax.swing.border. *; Public Square Square JPNL (Public Final Ink CELL_COUNT = 9; Public Cells] Cells = New Cells [CELL_COUNT]; Public Square () {this.setLayout (New Grid Layout (3,3)); This.setBorder (New LineBorder Color (black, 2)); for (int i = 0; i & lt; CELL_COUNT; i ++) {cell [i] = new cell (); this.add (cells [i]);}} public Class cell JTextField {Private int number; public cell () {} public zero set number (int number) {this.number = number; this.setText ("1");} public int getNumber () {return number;}} }

I'm not a Java Pro, but I will try to explain it best I I can do.

  sections of the public category expanded by JPNL   

class sections extension JPanel , Which means that it is the child of zpnil class and behaves as one, therefore, as you add stuff to JPanel , you can directly sections < / Code> Accessories in the class (Label, textfield, etc.).

  public class cell extends JTextField   

Similarly, class cell extension JTextField Which means that behaving like objects in this class can be used on a textfield setText () and can be added to JPNEL .

Here are the creators of the class class

  public class (this.setLayout (new grid layout (3,3)); This.setBorder (new lineboard (Color Black, 2)); For (int i = 0; i & lt; cELL_COUNT; i ++) {cell [i] = new cell (); This.add (cells [i]); }}   

In this manufacturer, the layout and threshold are first set. Then a loop is run, which instructs new objects of the cell class (which is basically JTextField s). And these cells are added to sections ( JPNL class child).

Hope you understood it!


Edit:

In a comment, you have said that whenever you remove everything from the cell class, it still works This is because the class increases JTextField and it receives all the properties of its original class, just try to remove Expand JTextField it will not work.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -