![]() ![]() We can specifically provide the horizontal and vertical gap between the components. As we know that it arranges the components in five different regions i.e EAST, WEST, NORTH. The given source code demonstrate the use of second constructor of Border Layout. Integer values are passed to its parameter.į1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) į1.setLayout(new BorderLayout(10,10)) //second constructor It does not provide the horizontal and vertical gap between the components.ī) BorderLayout(int horizontal_gap, int vertical_gap): It is the second constructor where you can specify the horizontal and vertical gap between the components. ![]() Example of FlowLayout class: Using FlowLayout() constructor. FlowLayout(int align, int hgap, int vgap): creates a flow layout with the given alignment and the given horizontal and vertical gap. The given source code demonstrate the use of first constructor of Border Layout. FlowLayout(int align): creates a flow layout with the given alignment and a default 5 unit horizontal and vertical gap. Let’s see the source code and output now Ī SWING GUI TO DEMONSTRSTE THE BORDER LAYOUTį.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) į.setLayout(new BorderLayout()) //first constructor A flow layout arranges components in a directional flow, much like lines of text in a paragraph. while we add the components to the frame It is a default constructor which is used in frame when we do not set any layout. A) BorderLayout(): It is the first constructor which creates the layout with no gap between the components.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |