JavaSwing graphical interface programming (Lecture)

JavaSwing (Chapter II) JLabel label

 

We finished the last chapter to how to achieve the basic form of window Swing, I believe we all understand the basics, this chapter will teach you how to achieve JLabel label.

JLabel role is to show to write content to the user.

Let's use JLabel labels show content

 

First good first frame structure

 

 

Then in the window to realize (remember the need to guide package)

 

 

Window generating vessel

 

 

JLabel objects defined by l, which "" where you can write text

JLabel l = new JLabel("");

Into the container in his c.add (l);

 

 

Then look at the results:

 

 This time the text has appeared in the window

 

You can also change the font style and font to size

 

 

Look at the results:

 

 

Let us put color changed a bit (here I set the red)

l.setForeground(Color.red);

 

 

 

Continue to see how it works:

 

 Then we will find the font color has changed

Small partners like playing games, you can do after completing a game Oh!

If there is no reference, you can refer to my previous games did little Oh!

 

Well, this chapter will be over! thank you all!

QQ:3207950853

QQ-mail: [email protected]

Learning exchange group: 710 023 821

Guess you like

Origin www.cnblogs.com/yjhjys/p/12655302.html