Add the Panels to the Relative Panels
Add a panel for the dice row and a score panel to the main panel, add a round and score panel to the Score Panel and add a points panel to the dice row panel.
What is box layout and combined layouts?
A box layout arranges components into a single row or column. By combining panels with different box layout options, you can arrange components in complex ways.
A box layout may stretch some components to fill the width or height of the panel.
Adding main panels and buttons to the window
Greedy must keep track of points, scores, and rounds. Create instance variables for these values so they may be used by different methods.
- Add private integer instance variables called
points
,newPoints
,score
, andround
. Initialize all values to0
exceptround
. Initializeround
to1
. - Add private
JLabel
instance variables calledpointsLabel
,scoreLabel
, androundLabel
. Initialize each by calling JLabel’s constructor. Each of these labels should have an initial text of “0”, exceptroundLabel
, which should have an initial text of “1”.
...
private static final long serialVersionUID = 1L;
_______________ points = ____;
_______________ newPoints = ____;
_______________ score = ____;
_______________ round = ____;
_______________ pointsLabel = _______________;
_______________ scoreLabel = _______________;
_______________ roundLabel = _______________;
...
Get hands-on with 1200+ tech skills courses.