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. I'm not a Java Pro, but I will try to explain it best I I can do. class Similarly, class Here are the creators of the class class In this manufacturer, the layout and threshold are first set. Then a loop is run, which instructs new objects of the Hope you understood it! In a comment, you have said that whenever you remove everything from the 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;}} }
sections of the public category expanded by JPNL
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
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 .
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]); }}
cell class (which is basically
JTextField s). And these cells are added to
sections (
JPNL class child).
Edit:
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
Post a Comment