Java simulates the layout of the QQ Friends panel (BoxLayout problem)

Source: Internet
Author: User

.........  JLabel ll=NewJLabel (Dlg.getnametext () + ":" +Dlg.getiptext (), Ii[index], jlabel.left); TMP=NewJPanel ();//Add a label to this panelTmp.setlayout (NewFlowLayout (Flowlayout.center)); Tmp.setbackground (NewColor (255, 0, 255)); /** BoxLayout layout is a pain in the egg, a panel x is the boxlayout layout, if the panel adds a panel y then y will fill the x panel ! If you add a panel z, then y, Z will be covered with the X panel! But you can set the scale of the Y,Z panel *! If x is adding a button or label, you cannot control its size ....                         No words anymore! * * below I practice adding a label to the panel TMP and then adding TMP to the QQP panel!                         This will allow you to control the size of the label! * To add a new panel, set the preferredsize! of the previous panel                         Ensure that each label is in a moderate distance!                         * That is to guarantee all the added panel height of the sum = = Qqp.getheight (); * */                        intCNT = Qqp.getcomponentcount ();//show the number of QQ friends!                         if(CNT >= 1) qqp.getcomponent (CNT-1). Setpreferredsize (NewDimension (250, 60));//60 indicates the height of the default label                        inth = qqp.getheight ()-cnt*60; if(H < 0) h=60;//if all the height of the high and the height of the QQP panel, then directly the default height, the remaining display is given to the vertical scroll bar! Tmp.setpreferredsize (NewDimension (250, h));                        Tmp.add (LL);                        Qqp.add (TMP);         Qqp.add (TMP); .....//See below! 

Java simulates the layout of the QQ Friends panel (BoxLayout problem)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.