In the application, sometimes you need to display the text of the large segment. Such as help information in the game, as well as RPG games. For this large amount of text, we will naturally think of using the form of the advanced interface to display, the advantage is simple and convenient, we don't have to worry about the drain version of the text, Form will give you everything. However, sometimes we cannot use the advanced interface, such as the game regulations must use the low-level interface, and then the RPG class is also necessary to use the low interface to display the white. Use the low-level interface to display large segment text, the key is that you have to give it a plate. The most direct question is: Can a line you can show a few words? Many people do this: Through the real machine (must be used in real machine, there will be differences in the simulator, there will be differences) The measurement is a few words, such as 7. Then divide the text of the paragraph into 7 rows, becoming a string array, such as: final string [] strgamehelp = {"An unknown year", "the era, the demon and people", "all exist in the world ",", ",", " "Beginner."}; With such a string array, we can draw it from: for (int i = 0; i So I wrote a function: final int characternumber = 6; public vector getSubsection (String str) {Vector vector = new vector (); int i = 0; while (! Str.equals (") {if (str.length> 6) {Vector.AddeElement (Str.Substring (0, characterNumber)); str = str.substring (characterNumber);} else {vector.addelement (str); str = "";}} return vector;} The information is changed: Final String strgamehelp = "In the year" "era, the demon" "exists in the world, and" "is basically the opposite" "state, But there is a possibility that " " is " " in addition to " ", because " " people have basically " " accepted the facts of " " demon in the world. "; Finally, Painting: Vector Vector = GetSbsection STRGAMEHELP); for (int i = 0; i How to do. Back to the advanced interface? Don't think about it. You open the API manual to check, I hope to find out what to come. Yes, your eyes are bright, and the StringWidth function provided by the Font class is printed, which can return the length of the string to display on the screen. With this function, you can improve the getSubsection function. STRSource is the text of the line to be broken. Font is the font used when drawing text. Width is the maximum width of each line, and the last strsplit is used for word, ie English words The interval symbols, functions rely on this parameter to distinguish words. public Vector getSubsection (String strSource, Font font, int width, String strSplit) {Vector vector = new Vector (); String temp = strSource; int i, j; int LastLength = 1; int step = 0; try {while (! Temp.Equals (")) {i = Temp.indexOf (" / n "); if (i> 0) {IF (Font.StringWidth (Temp.Substring (0, I-1))> = width) { I = -1;}} = = == - 1) {IF (LastLength> Temp.Length ()) {i = Temp.length ();} else {i = lastlength; step = font.stringwidth (Temp. Substring (0, i))> width? -1: 1; IF (i IF (Temp.Substring (0, 1) .Equals ("/ n")) {TEMP = Temp.Substring (1);}}}} catch (exception e) {system.out.println ("getSubSection:" e);} return vector;} Change the call to the place: font font = font.getfont (font.face_system, font.style_plain, font.size_small); g.setfont (font); Vector Vector = getSubsection (strgamehelp, font , getWidth () - 10, ",.?!"); this, for English, we can also display correctly. Finally, you can sit down, drink a glass of water (coffee is grabbing), listen to Music, enjoy: 1, good versatility, automatically adapt to different screen sizes, all languages and texts. 2, the workload is small, you don't have to go hard, don't have to come back to add a word. Want to adjust the width? Change a parameter. However, the final way to tell you, don't pay attention to it, you must pay attention to the font used in the call function and the actual font to be consistent, otherwise I will be wrong (I often commit such a mistake :))