Tunnelsnake
-
Posts
22 -
Joined
-
Last visited
-
Feedback
100%
Posts posted by Tunnelsnake
-
-
What do you need? : 11-63 hunter
Going first or middleman? : First
What's your Skype/Discord ID? : tunnelsnake0 -
12 hours ago, liverare said:
Example of how to use:
Image img; SystemAlert sa; try { img = ImageIO.read(YourScript.class.getResourceAsStream("/unnamed.png")); sa = new SystemAlert(400, 100, img, "Task Completed!", "You've successfully chopped 5000 yew logs.", new Date()); sa.setVisible(true); } catch (Exception e) { logger.error(e); }
Note:
- Load images locally, not externally.
- You can chose between passing either a java.awt.Image or javax.swing.ImageIcon for the 3rd parameter. If you chose the first, the image will be resized proportionally to the alert box, whereas the other one will allow you to have complete control over the image size.
- The alert can be dismissed by clicking on it.
- The default fonts and colours can be found in the configureComponents function (lines 126-129).
Source code:
package com.liverare.api.swing; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Image; import java.awt.Insets; import java.awt.Toolkit; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import javax.swing.ImageIcon; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; /** * System alert mimic * * @author LiveRare * */ public class SystemAlert extends JDialog { private static final long serialVersionUID = 1L; private static final Dimension SCREEN_SIZE = Toolkit.getDefaultToolkit().getScreenSize(); public static final DateFormat DATE_FORMAT = new SimpleDateFormat("E, dd MMM yyyy - HH:mm:ss"); private JLabel iconLabel; private JLabel titleLabel; private JTextArea contentTextArea; private JLabel timestampLabel; private JPanel containerPanel; /** * Main constructor * * @param width * - Alert width * @param height * - Alert height */ public SystemAlert(int width, int height) { super(); super.setSize(width, height); super.setAlwaysOnTop(true); super.setUndecorated(true); configureBoundary(); configureComponents(); addComponents(); addCloseListener(); } /** * * @param width * - Alert width * @param height * - Alert height * @param icon * - Alert icon * @param title * - Alert title * @param message * - Alert message * @param timestamp * - Alert time-stamp * @see {@link SystemAlert#SystemAlert(int, int)} * @see {@link SystemAlert#setAlert(ImageIcon, String, String, Date)} */ public SystemAlert(int width, int height, ImageIcon icon, String title, String message, Date timestamp) { this(width, height); setAlert(icon, title, message, timestamp); } /** * * @param width * - Alert width * @param height * - Alert height * @param image * - Alert icon * @param title * - Alert title * @param message * - Alert message * @param timestamp * - Alert time-stamp * @see {@link SystemAlert#SystemAlert(int, int)} * @see {@link SystemAlert#setAlert(Image, String, String, Date)} */ public SystemAlert(int width, int height, Image image, String title, String message, Date timestamp) { this(width, height); setAlert(image, title, message, timestamp); } /** * Configures the components for the alert. */ private void configureComponents() { iconLabel = new JLabel(); titleLabel = new JLabel("Title"); contentTextArea = new JTextArea("Content", 2, 50); contentTextArea.setEditable(false); contentTextArea.setWrapStyleWord(true); contentTextArea.setLineWrap(true); contentTextArea.setFocusable(false); timestampLabel = new JLabel("Thu, 16 July 2015 - 21:24:11", JLabel.RIGHT); containerPanel = new JPanel(new GridBagLayout()); setFont(new Font("Calibri", Font.PLAIN, 12)); setForeground(Color.decode("#fdfdfd")); setBackground(Color.decode("#262626")); setSelectedTextColor(Color.decode("#fd2112")); } /** * Sets the location for the alert. */ private void configureBoundary() { int x = 0; int y = 0; Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration()); x += SCREEN_SIZE.width; x -= getWidth(); y += SCREEN_SIZE.height; y -= getHeight(); y -= screenInsets.bottom; setLocation(x, y); } /** * Adds components to the alert. */ private void addComponents() { containerPanel.add(iconLabel, new GridBagConstraints(0, 0, 1, 3, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(5, 15, 5, 15), 0, 0)); containerPanel.add(titleLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0)); containerPanel.add(contentTextArea, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); containerPanel.add(timestampLabel, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); add(containerPanel, BorderLayout.CENTER); } /** * Adds a mouse listener that will trigger when either the alert, or child * components of the alert, are clicked. */ private void addCloseListener() { addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { dispose(); } }); } @Override public synchronized void addMouseListener(MouseListener l) { super.addMouseListener(l); if (iconLabel != null) { iconLabel.addMouseListener(l); } if (titleLabel != null) { titleLabel.addMouseListener(l); } if (contentTextArea != null) { contentTextArea.addMouseListener(l); } if (timestampLabel != null) { timestampLabel.addMouseListener(l); } if (containerPanel != null) { containerPanel.addMouseListener(l); } } @Override public void setFont(Font f) { super.setFont(f); if (titleLabel != null) { titleLabel.setFont(f.deriveFont(Font.BOLD, 19)); } if (contentTextArea != null) { contentTextArea.setFont(f.deriveFont(Font.PLAIN, 13)); } if (timestampLabel != null) { timestampLabel.setFont(f.deriveFont(Font.ITALIC, 11)); } } @Override public void setForeground(Color c) { super.setForeground(c); if (titleLabel != null) { titleLabel.setForeground(c); } if (contentTextArea != null) { contentTextArea.setForeground(c); } if (timestampLabel != null) { timestampLabel.setForeground(c); } } @Override public void setBackground(Color bgColor) { super.setBackground(bgColor); if (contentTextArea != null) { contentTextArea.setBackground(bgColor); contentTextArea.setSelectionColor(bgColor); } if (containerPanel != null) { containerPanel.setBackground(bgColor); } } public void setSelectedTextColor(Color c) { contentTextArea.setSelectedTextColor(c); } /** * Set alert contents * * @param icon * - Alert icon * @param title * - Alert title * @param message * - Alert message * @param timestamp * - Alert time stamp */ public void setAlert(ImageIcon icon, String title, String message, Date timestamp) { iconLabel.setIcon(icon); titleLabel.setText(title); contentTextArea.setText(message); timestampLabel.setText(DATE_FORMAT.format(timestamp)); } /** * Set alert contents * * Note: will attempt to proportionally scale the image provided * * @param image * - Alert icon image * @param title * - Alert title * @param message * - Alert message * @param timestamp * - Alert time stamp */ public void setAlert(Image image, String title, String message, Date timestamp) { double height = getHeight(); double imgWidth = image.getWidth(this); double newImgWidth = 0; double newImgHeight = 0; newImgHeight = (int) (height / 2); newImgWidth = (Math.min(newImgHeight, imgWidth) / Math.max(newImgHeight, imgWidth)); newImgWidth *= imgWidth; ImageIcon icon = new ImageIcon(image.getScaledInstance((int) newImgWidth, (int) newImgHeight, Image.SCALE_DEFAULT)); setAlert(icon, title, message, timestamp); } }
Thank you very much worked like a charm
-
12 hours ago, liverare said:
I made my own a very long time ago, back before they patched the farming exploit (being able to see plant growth and disease from anywhere in-game):
I salvaged my old code to produce this:
Is this something you're after? Because it works with OSBot. You can always change the colours and fonts to suit your design. If you wanted to add audio as well, that's also in my old code, but audio will need a little more tinkering to get working.
This is exactly what i am looking for
- 1
-
I get this error when trying to use that code
-
9 hours ago, Gamete said:
Of course there is
how can i do it??
-
Is there any way to get system notifications when a certain task is performed?
-
Could i get a trial thank you
- 1
-
27 minutes ago, Eliot said:
I'll do 60 mage for free (botted), your supplies.
looking for hand done
-
how much for 60 range and 60 range hand done on a fresh account
please post prices
-
What do you need? : 1-60 Mage, 1-60 Range,
Payment method? :07gp or paypal
Going first or middleman? :first
What is your Skype? :tunnelsnake0
Do you agree to the TOS? :Yes
-
i am looking for some aged tutorial accounts if u have any pm me on skype tunnelsnake0
-
dont need anymore
-
@Rxdking Will be doing the account.
- 1
-
28 minutes ago, Aaron said:
How much you expecting to pay each
for 4m??
-
I am looking for 250 total level accounts. I dont care on what skills have been trained and must be hand trained if u have any please message me back or on skype tunnelsnake0
-
I am still looking for accounts
-
completed
-
Where anyone able to claim any names in yesterdays release?
-
Do you agree to my TOS*? : Yes
Do you agree to 30m deposit? : Yes
What is your Skype name? : tunnelsnake0
Do you have any experience with a service/previous employers? : Yes
What form of service are you willing to provide? (such as minigames; firecapes; power levelling, quests)? : Powerleveling/Questing/Minigames
Stealth Passive Goldfarmer
in Money Making
Posted
Can I please test this thank you.