Add Text Fields and Radio Buttons
Learn to add input fields and radio buttons in the dialog.
Text fields allow the program user to enter text. Radio buttons allow the user to select one of several choices.
Adding input fields to the dialog
You can now start adding content to the dialog.
- Go back to
OptionsDialog.java
. - Add private
JTextField
instance variables calledrowsField
andcolsField
, initialized by calling their constructors, each with3
as the number of columns. - Add private
JRadioButton
instance variables calledmazeButton
andantiMazeButton
, initialized by calling their constructors, with the text"Maze"
and"Anti-Maze"
, respectively.
...
private int cols = 0;
private int type = 0;
___________ rowsField = _________________;
___________ colsField = _________________;
___________ mazeButton = _________________;
___________ antiMazeButton = ________________;
...
Get hands-on with 1200+ tech skills courses.