StatusLabel = new JLabel("",JLabel. HeaderLabel = new JLabel("",JLabel.CENTER ) MainFrame = new JFrame("Java SWING Examples") SwingLayoutDemo swingLayoutDemo = new SwingLayoutDemo() This class inherits methods from the following class −Ĭreate the following Java program using any editor of your choice in say D:/ > SWING > com > tutorialspoint > gui > Returns a string representation of the state of this border layout. Sets the vertical gap between the components. Sets the horizontal gap between the components. LayoutMananger is an interface which implements the classes of the layout manager. Removes the specified component from this border layout. In Java, Layout Managers is used for arranging the components in order. Void removeLayoutComponent(Component comp) Returns the maximum dimensions for this layout given the components in the specified target container.ĭimension minimumLayoutSize(Container target)ĭetermines the minimum size of the target container using this layout manager.ĭimension preferredLayoutSize(Container target)ĭetermines the preferred size of the target container using this layout manager, based on the components in the container. Lays out the container argument using this border layout.ĭimension maximumLayoutSize(Container target) Invalidates the layout, indicating that if the layout manager has cached information it should be discarded. Returns the vertical gap between the components. Returns the horizontal gap between the components.įloat getLayoutAlignmentX(Container parent)įloat getLayoutAlignmentY(Container parent) If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name. Void addLayoutComponent(String name, Component comp) Void addLayoutComponent(Component comp, Object constraints)Īdds the specified component to the layout, using the specified constraint object. Static String WEST − The west layout constraint (left side of the container). Static String SOUTH − The south layout constraint (bottom of the container). Static String PAGE_START − The component comes before the first line of the layout's content. Static String PAGE_END − The component comes after the last line of the layout's content. Static String NORTH − The north layout constraint (top of the container). Static String LINE_START − The component goes at the beginning of the line direction for the layout. Static String LINE_END − The component goes at the end of the line direction for the layout. Note the program accepts an integer number (number of buttons) as command-line argument. Here is some code to show what is possible. Static String EAST − The east layout constraint (right side of the container). For example, if a row accommodates 8 columns or buttons - 12 buttons are placed in two rows. Static String CENTER − The center layout constraint (middle of the container). Static String BEFORE_LINE_BEGINS − Synonym for LINE_START. Static String BEFORE_FIRST_LINE − Synonym for PAGE_START. Static String AFTER_LINE_ENDS − Synonym for LINE_END. Static String AFTER_LAST_LINE − Synonym for PAGE_END. Class Declarationįollowing is the declaration for class −įollowing are the fields for class − Each region can contain only one component and each component in each region is identified by the corresponding constant NORTH, SOUTH, EAST, WEST, and CENTER. We can also say, arranging the components in sequence.The class BorderLayout arranges the components to fit in the five regions: east, west, north, south, and center. In Java JFrame, need to set the layout to add the components.įlow Layout is used to put the components from left to right and then next line in the JFrame. In java programming, we can also use flow layout in JFrame to create a Graphical user interface (GUI) using JFrame class. « Previous Next » Java Program for JFrame Flow Layout(GUI)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |