House Posted August 11, 2016 Share Posted August 11, 2016 HScrollingLogger Code: public class HScrollingLogger { private static int messagesDisplayed = 5; private static String[] messages = new String[messagesDisplayed]; private final static DateFormat dateFormat = new SimpleDateFormat("HH:mm a"); private static int i = 0; private final static Color backgroundColor = new Color(50, 205, 50); private final static Color textColor = new Color(0, 0, 0); private final static Font FONT = new Font("Arial", 0, 11); public static void add(String s) { messages[i] = (s + " | " + (dateFormat.format(new Date()))); i = (i + 1) % messagesDisplayed; } public static void paintLog(int x, int y, Graphics g) { FontMetrics metrics = g.getFontMetrics(FONT); int height = metrics.getHeight(); int descent = metrics.getDescent() - 5; int index = i; for (int messageIndex = 0; messageIndex < messagesDisplayed; messageIndex++) { index = index == 0 ? messagesDisplayed - 1 : index - 1; String s = messages[index]; if (s == null) { break; } g.setColor(backgroundColor); g.fillRect(x - metrics.stringWidth(s) - 10, y + descent - height, metrics.stringWidth(s) + 10, height); g.setColor(textColor); g.setFont(FONT); g.drawString(s, x - metrics.stringWidth(s) - 5, y - 5); y -= 15; } } } Usage: HScrollingLogger.add("Started Script."); HScrollingLogger.add("Test message 1."); HScrollingLogger.add("Test message 2."); HScrollingLogger.add("Test message 3."); HScrollingLogger.add("Test message 4."); ... @ Override public void onPaint(Graphics2D g) { HScrollingLogger.paintLog(516, 340, g); } What it looks like ingame: 8 Quote Link to comment Share on other sites More sharing options...
Team Cape Posted August 11, 2016 Share Posted August 11, 2016 probably going to use this soon, very nice Quote Link to comment Share on other sites More sharing options...
dontbuzz Posted August 18, 2016 Share Posted August 18, 2016 Works a treat. TYVM, exactly what i needed bruv. Quote Link to comment Share on other sites More sharing options...