Create a Grid Layout and Light Toggling Buttons
Learn to add light buttons to grid layout.
We'll cover the following
Grid layout
A grid layout arranges components into a grid in which all components are the same size.
Adding LightButtons
to Framed
- In
framed.java
, Add a private static final integer instance variable calledGRIDSIZE
, set to3
. - Add a private
LightButton
two-dimensional array instance variable calledlightButton
, withGRIDSIZE
rows andGRIDSIZE
columns.
...
public class Framed extends JFrame {
private static final long serialVersionUID = 1L;
____________________ GRIDSIZE = _____;
____________________[][] lightButton = ____________________;
...
Get hands-on with 1200+ tech skills courses.