The method of displaying the current time in Java pictures is original

Graphics2d class provides the drawstring () method, which can realize the text drawing of graphics context, so as to realize the function of displaying text on pictures. Let's take a look at its specific usage

The syntax is as follows:

or

STR: text string to draw;

x: Draw the horizontal starting position of the string;

Y draws the vertical starting position of the string.

The only difference between the two methods is the type of X and Y parameters used.

Example 1: draw a rectangular graph, display text in the middle of the rectangular graph, and the content of the text is the current time.

The code is as follows:

summary

This paper introduces the method of displaying the current time in the picture. How to display the current date in the picture? Do you have a clear idea in mind?

Thank you for your support!

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
分享
二维码
< <上一篇
下一篇>>