Then set the frame to be visible so that frame and panel are displayed Panel

Then set the frame to be visible so that frame and

This preview shows page 17 - 41 out of 76 pages.

Then set the frame to be visible so that frame and panel are displayed. Panel
Image of page 17

Subscribe to view the full document.

Creating and Setting up Panel 18 Method / Constructor Purpose JPanel() Create a panel void add(Component) To add specified component to the panel. void setLayoutManager(LayoutManager) To set layout manager to the panel for positioning the component void setSize(int, int) To set the size of the window.
Image of page 18
Example Code : Creating Panel 19
Image of page 19

Subscribe to view the full document.

Layout Manager 20 Layout manager determine the size and position of components within a container The layout manager is responsible for deciding the layout policy and size of each of its container. Java Layout Managers : FlowLayout, BorderLayout, GridLayout , CardLayout, GridBagLayout.
Image of page 20
FlowLayout 21 Default layout for Panel class Components are added from left to right Default alignment is centered Uses component preferred size
Image of page 21

Subscribe to view the full document.

Creating and Setting up FlowLayout 22 Method / Constructor Purpose FlowLayout() To construct new flow layout for the frame
Image of page 22
Example Code : FlowLayout 23 After program or user resizes
Image of page 23

Subscribe to view the full document.