Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Scrolling text bar for the onpaint

Featured Replies

I was bored, so I made this, hope some can enjoy it. It just gives you the option to have any text in a box appearing and disappearing while scrolling along.  Feel free to optimize or edit and use it.

gr2ur8E.gifGt0M83u.gif

1. Copy this class to your project

Spoiler
package org.wackylib.paint;

import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;

public class ScrollingTextBar {
    private String text = "place holder";
    private int textXPosition;
    private int borderXPosition;
    private int yPosition;
    private int width;
    private int height;
    private int scrollSpeed;
    private Color textColor = Color.WHITE;
    private Color borderColor = Color.BLACK;
    private boolean drawBorder;

    public ScrollingTextBar(String text, int xPosition, int yPosition, int width, int height, int scrollSpeed) {
        this.text = text;
        this.borderXPosition = xPosition;
        this.textXPosition = xPosition + width; //Starts text from the right side of the border
        this.yPosition = yPosition;
        this.width = width;
        this.height = height;
        this.scrollSpeed = scrollSpeed;
    }

    public ScrollingTextBar(int xPosition, int yPosition, int width, int height, int scrollSpeed) {
        this.borderXPosition = xPosition;
        this.textXPosition = xPosition + width; //Starts text from the right side of the border
        this.yPosition = yPosition;
        this.width = width;
        this.height = height;
        this.scrollSpeed = scrollSpeed;
    }

    public void update() {
        textXPosition -= scrollSpeed;
        if (textXPosition + getTextWidth() < borderXPosition) {
            textXPosition = borderXPosition + width;
        }
    }

    public void draw(Graphics g) {
        if (drawBorder) {
            //Draw border if the flag is true
            g.setColor(borderColor);
            g.drawRect(borderXPosition, yPosition, width, height);
        }

        //Set clipping to the area of the border, this makes the text seem appearing and disappearing.
        Graphics2D g2d = (Graphics2D) g.create();
        g2d.setClip(new Rectangle(borderXPosition, yPosition, width, height));

        //Draw text within the clipping region
        g2d.setColor(textColor);
        FontMetrics fm = g2d.getFontMetrics();
        int textYPosition = yPosition + ((height - fm.getHeight()) / 2) + fm.getAscent();
        g2d.drawString(text, textXPosition, textYPosition);

        //Dispose the graphics context to avoid memory leaks
        g2d.dispose();
    }

    private int getTextWidth() {
        Graphics g = new java.awt.image.BufferedImage(1, 1, java.awt.image.BufferedImage.TYPE_INT_ARGB).getGraphics();
        FontMetrics fm = g.getFontMetrics();
        return fm.stringWidth(text);
    }

    public void setTextColor(Color textColor) {
        this.textColor = textColor;
    }

    public void setBorderColor(Color borderColor) {
        this.borderColor = borderColor;
    }

    public void setText(String text) {
        this.text = text;
    }

    public void setDrawBorder(boolean drawBorder) {
        this.drawBorder = drawBorder;
    }
}


2. Get an instance by importing it.
3. In the onstart decide how you want to make it look, use the 4 setters to customize: text color, border color, set your custom text string, draw border yes or no.

Spoiler
scrollingTextBar = new ScrollingTextBar(365, 440, 130, 20, 1); //
scrollingTextBar.setTextColor(Color.green);
scrollingTextBar.setBorderColor(Color.black);
scrollingTextBar.setDrawBorder(false);
scrollingTextBar.setText("your text here");

Optional: 
set the text with the constructor instead of the setter ^^
 

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.