In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the layout managers of containers in java". In daily operations, I believe that many people have doubts about the layout managers of containers in java. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what are the layout managers of containers in java?" Next, please follow the editor to study!
Layout manager for java containers (top and middle containers)
Java can accurately locate the components in pixels, but there will be some differences in its display in different systems, so the display effect is different. Therefore, java provides a layout manager, which makes the graphical interface written have good platform independence.
Note: all layout managers are used for containers, including top-level containers and intermediate containers.
First, the layout manager belongs to the class package package layout manager name description Java.awtFlowLayout (flow layout) components according to the order of joining according to the set alignment from left to right, one line full to the next line to continue to arrange Java.awtBorderLayout (boundary layout) container is divided into east, west, south, north, middle five areas, each area can only place one component. The space of the Java.awtGridLayout (grid layout) container is divided into grid areas of M × N columns, and only one component can be placed in each area. Java.awtCardLayout (Card layout) is like a stack of cards, each card corresponds to a component, but only one card can be displayed at a time. An upgraded version of Java.awtGridBagLayout (grid package layout) GridLayout for preventing multiple components in one space, components are still placed in rows and columns, but each component can occupy multiple grid Java.swingBoxLayout (box layout) allows you to prevent multiple controls Java.swingSprigLayout (spring layout) vertically or horizontally in the container without using layout manager. Place the control according to the size and location information provided by the control itself. 2. the default layout manager container of the container
Default layout top-level container JFrameBorderLayout (boundary layout) top-level container JDialogBorderLayout (boundary layout) top-level container JAppletFlowLayout (streaming layout) intermediate container JPanelFlowLayout (streaming layout) java four commonly used containers summary 1, why use containers (collection class)?
1. Requirements: at some point, we need to create any number of objects at any time and anywhere.
two。 The defect of the data 1, has a fixed size, but in the actual use, it is difficult to estimate how many objects we need. Array defect 2, unable to support more complex data structures.
The advantage of containers in 3.Java is that they can be resized automatically. In actual programming, you can put any number of objects into the container without worrying about how big the container should be.
4. Different containers have their own special properties.
II. Brief introduction and difference of four containers in Java
List: saves a set of data in a specific order.
Set: collection; duplicate data is not allowed.
Queue: queue: inserts data on one end and pops up on the other.
Map: associated data, dictionary. Stores a set of (Key-Value) values.
Difference:
List: can store repeating arrays, based on arrays or linked lists.
Set: duplicate elements cannot be stored, based on Map implementation.
Map: key-value pair storage, stored keys can not be repeated, based on the hash table or red-black implementation.
III. The container system of Java
In general, it can be divided into two categories:
One is Collection: a sequence of independent elements, and the other is Map: objects with a pair of key-value pairs.
Collection interface includes List interface, Queue interface and Set interface. The List interface includes ArrayList class and LinkedList implementation class. The Queue interface includes the Deque interface and the PriorityQueue implementation class. Set interface includes HashSet implementation class and SortedSet interface.
The Map interface includes HashMap implementation class and TreeHashMap implementation class. The HashMap implementation class includes LinkedHashMap subclass.
At this point, the study on "what are the layout managers of containers in java" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 221
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.