简体   繁体   中英

What's the most common used layout in Swing?

I'm trying to figure out how to work with the layoutmanager in swing and honestly... I'm realy having a hard time.

Is there a most common used layout or does it realy depends on which context you have. For example I need to create the following layout :

在此处输入图片说明

Which layout should I use ?

It really depends on which context you have. That's why there are so many differnt Layouts to chose from.

Sometimes there's many ways to build a specific design, sometimes a specific Layout will make the design very easy - but learning how the different JRE-included Layouts work is time well spent if you target Swing applications.

In your current case I'd probably use BorderLayout for the Dialog, put a JLabel in CENTER with icon and (two lines of) text and add the Buttons in another JPanel in SOUTH...

我建议您在上述情况下使用边框布局https://docs.oracle.com/javase/tutorial/uiswing/layout/border.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM