Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //TEXT
- public void drawText(Graphics g, String textFile) {
- int y = 110;
- String text = "", firstLine = "";
- FileReader fr;
- try {
- fr = new FileReader(textFile);
- BufferedReader reader = new BufferedReader(fr);
- firstLine = reader.readLine();
- reader.close();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- try {
- text = new String(Files.readAllBytes(Paths.get(textFile)), "MS932");
- } catch (IOException e) {
- e.printStackTrace();
- }
- g.setColor(Color.WHITE);
- g.drawString(g.getFontMetrics().stringWidth(text) + " - " + g.getFontMetrics().stringWidth(firstLine), 32, 160);
- y += textScroll;
- g.setColor(Color.LIGHT_GRAY);
- for (String line : text.split("\n"))
- g.drawString(line, getWidth() / 2 - g.getFontMetrics(gameFont).stringWidth(firstLine) / 2, y += g.getFontMetrics().getHeight());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement