![]() ![]() This can be done using the setLayout Method of Frame. So for the purposes of these demonstration programs you may find it useful change the Layout Manager to FlowLayout. Para ello, Java dispone de varios tipos de layout manager, a saber: FlowLayout BorderLayout CardLayout GridLayout GridBagLayout BoxLayout OverlayLayout. Also if you do not specify a region each new component defaults to the centre of the Frame and if you add more than one component without a region, each new component gets added on top of the old one. 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. It divides the Frame area up into five regions, North, South, East, West and Centre. FlowLayout(int align): creates a flow layout with the given alignment and a default 5 unit horizontal and vertical gap. It is similar to a vertical version of java. This is slightly awkward as the BorderLayout is not the most useful of Managers. GridLayout then create another panel for the labels the uses a GridLayout.BorderLayout. The default layout for a frame is the BorderLayout Thus if you create a Frame and do not specifically assign a Layout Manager it will automatically use the BorderLayout. The FlowLayout and BorderLayout are the default Layout Managers for the Frame and Applet class respectively. These give you enough control over component layout for most demonstration programs. For the purposes of this course I will concentrate on three of the Layout managers shipped by Sun, these are
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |