House Posted August 11, 2016 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
dontbuzz Posted August 18, 2016 Posted August 18, 2016 Works a treat. TYVM, exactly what i needed bruv.