... (line 20). Method setLayout is inherited into class LabelFrame indirectly from class Container. The argument to the method must be an object of a class that implements the LayoutManager interface (e.g., FlowLayout). Line 20 creates a new FlowLayout object and passes its reference as the argument to setLayout.
Creating and Attaching label1
Now that we’ve specified the window’s layout, we can begin creating and attaching GUI components to the window. Line 23 creates a JLabel object and passes “Label with text” to the constructor. The JLabel displays this text on the screen. Line 24 uses method setToolTipText (inherited by JLabel from JComponent) to specify the tool tip that’s displayed when the user positions the mouse cursor over the JLabel in the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access