empathy Posted November 23, 2015 Share Posted November 23, 2015 (edited) I made this for fun and I really don't plan on using it. I'm gonna release it. Feel free to use it or don't. I don't care Also the code isn't that clean. What it does: https://gyazo.com/442cf002eb683ed0343f6f62f79e2d15 Code (Note* the first item search may lag a tiny bit due to loading the text document from online. An easy fix is to load the text document locally): package org.empathy.combat.equipment.gui; import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; public class Gui extends JFrame { private JPanel contentPane; private JTextField textField; private int itemId; String path = "http://cdn.rsbuddy.com/items/" + itemId + ".png"; JLabel lblNewLabel; BufferedImage image; private JLabel lblTypeAnItem; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Gui frame = new Gui(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public Gui() { //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 340, 382); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); textField = new JTextField(); textField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { checkText(); } }); textField.setBounds(118, 49, 86, 20); contentPane.add(textField); textField.setColumns(10); try { image = ImageIO.read(new URL(path)); lblNewLabel = new JLabel(); lblNewLabel.setBounds(118, 92, 86, 73); contentPane.add(lblNewLabel); lblTypeAnItem = new JLabel("Type an item name and hit Enter"); lblTypeAnItem.setBounds(80, 28, 208, 14); contentPane.add(lblTypeAnItem); } catch (IOException e) { e.printStackTrace(); } } public void checkText() { if (textField.getText() != null) { try { URL url = new URL("https://gist.githubusercontent.com/anonymous/a1aa9894c1acc0c1c201/raw/b8bd35ed57a9cedfb1dc2379212ac79faa979136/IDs.txt"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String line; while ((line = in.readLine()) != null) { if (line.toLowerCase().contains(textField.getText().toLowerCase())) { String[] x = line.toLowerCase().split(textField.getText().toLowerCase() + " - "); int i = Integer.parseInt(x[1]); image = ImageIO.read(new URL("http://cdn.rsbuddy.com/items/" + i + ".png")); lblNewLabel.setIcon(new ImageIcon(image)); break; } } } catch (IOException e) { e.printStackTrace(); } } } } Edited November 23, 2015 by empathy 4 Quote Link to comment Share on other sites More sharing options...
MalikDz Posted November 24, 2015 Share Posted November 24, 2015 Nice m8 Quote Link to comment Share on other sites More sharing options...