On the construction methods of labels and jlabel classes

The label has a jlabel class definition, and its parent class is jcommonet class.

Labels can display a line of read-only text, an image, or text with an image. It can not produce any type of events, and can only simply display pictures and text, but you can use the properties of the label to specify the alignment of the text on the label. Jlabel class provides a variety of construction methods, and can create a variety of labels, such as labels that display only text, labels that only icons, or labels that contain text and icons. The common construction methods of jlabel class are as follows: public jlabel(): create a jlabel object without icon and text. Public jlabel(): create a jlabel object with an icon public jlabel(): create a jlabel object with an icon and set the horizontal alignment of the icon. Public jlabel(): create a jlabel object with text and set the horizontal alignment of the text. Public jlabel(): create a jlabel object with text and icon, and set the horizontal alignment of label content.

In jlabel, several methods may be commonly used, such as sethorizontalalignment (int alignment) and setverticalalignment (int alignment), which respectively set the horizontal or vertical position of components (text or icon) in the label, while sethorizontaltextposition (int textposition) and setverticaltextposition (int textposition) can set the relative position of text relative to icon, In addition, seticontextgap (int icontextgap) can set the spacing between the text in the label and icon, and settext (string test) and seticon (icon) can set the text and icon in the label respectively.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>