Jump to content


  • Content count

  • Joined

  • Last visited

  1. [quote name='Steve'][CODE]myFrame.setVisible(true);[/CODE] you should put that last(add the components before showing it).[/QUOTE] Thanks for your feedback.
  2. Firstly, we need to create a JFrame [GUI] Make a new class called GUI (Don't forget to package all of the classes together). Now, import the following: [code] import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.WindowConstants; [/code] Now to make a JFrame you firstly need to declare it. If you're a newb, just copy & paste this: [code] JFrame myFrame = new JFrame("Title of your JFrame Here"); [/code] Now, you need to set the screen size. E.G [code] myFrame.setSize(850,700); [/code] Now, we need to create a exit on close, so you can close the program with the default [x] E.G [code] myFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); [/code] To set the properties so you can see the GUI Insert: [code] myFrame.setVisible(true); [/code] Button ------ Declare JPanel [code] JPanel panel = new JPanel() [/code] Add a Panel [code] myFrame.add(panel); [/code] Declare your button & it's inputname e.g [code] JButton button = new JButton ("Button Inputname here"); [/code] add the button to your panel: [code] panel.add(button); [/code] Now you have to make the onclick to your action listener class: E.G [code] button.addActionListener(new Action()); [/code] ActionListener --------------- Create a new class called: Action Now, Paste the following into this class if you're not using eclipse. [code] import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class Action implements ActionListener { [MENTION=15855]Over[/MENTION]ride public void actionPerformed(ActionEvent arg0) { System.out.println("Button has been pressed!"); } } [/code] Done, basically add whatever code you want in the void actionperformed, & the button will call the actionlistener thus performing the task. This is my first tutorial & I'm in a hurry, please let me know what you think.
  3. Basically, it's been compiled with a higher version of Java that you have, so you need JDK7+
  4. [quote name='Pk1337pk']> Uses PHP for 4 years > Uses HTML for 9 months. Nice lie pro, but you will need to know HTML before you can do anything with PHP.[/QUOTE] Hahaha, that completely made me laugh, xHTML is a completely different language to HTML, idiot.
  5. I'm a experienced coder, add my msn: [email][email protected][/email] & I'm a experienced web developer, I will not work with kids though.
  6. Hey, I'm in development with my current runescape private server, called EPS-World. I am a extremely experienced web developer and I'm looking for a partner. My specialities -------------- PHP [4 Years] Javascript [9 Months] xHTML [9 Months] C sharp [4 Years] C++ [About 6 months] C# [Well over 5 years] -------------- I'm I can do various parts of Java, with Eclipse IDE. I'm not looking for skids, only people for are seriously talented. My MSN: [email][email protected][/email] I am also currently running the server on a 6GB of ram CentOS Linux Server on a 2GBPS none capped server.
  7. It's all signed, and everything. The cache downloader works, everything does. But for some reason I'm only getting this error on the webclient "Requesting title screen", then a connection error, and my connection, cache, sprites are all fine! [img]http://i.minus.com/jbiME4kwbhmEsL.png[/img]
  8. [quote name='Skyro'][CODE]public static String findCacheDir() { String cachePath = System.getProperty("user.home") + "/.SkyRune_cache_32/"; File cacheDirectory = new File(cachePath); if (cacheDirectory.exists()) return cachePath; else { System.out.println("Creating Cache directory..."); cacheDirectory.mkdir(); System.out.println("Cache diretory created: " + cachePath); return cachePath; } }[/CODE] Can anyone tell me why my client is getting 'Error - Requesting Title Screen'. That's my find cache directory.[/QUOTE] I had this issue, you have to basically use a different code, that will work with your sign link user.home doesn't work, and never will, because basically you're calling it apon e.g say if my username was hi C:\hi\home\cachehere and it's downloading to C:\ So you have to change it to c:\ Hope, I helped!
  9. Here's the cachedownloader class: [code] import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.FileWriter; import java.io.BufferedWriter; import java.io.BufferedOutputStream; import java.io.BufferedInputStream; import java.io.FileOutputStream; import java.io.FileInputStream; import java.io.InputStream; import java.net.URLConnection; import java.net.URL; import java.util.zip.ZipFile; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.Enumeration; import sign.signlink; public class CacheDownloader { private client client; private final int BUFFER = 1024; private final int VERSION = 1; // Version of cache private String cacheLink = "http://eps-world.org/EPSCACHE.zip"; // Link to cache private String fileToExtract = getCacheDir() + getArchivedName(); public CacheDownloader(client client) { this.client = client; } private void drawLoadingText(String text) { client.drawLoadingText(20, text); //System.out.println(text); } private void drawLoadingText(int amount, String text) { client.drawLoadingText(amount, text); //System.out.println(text); } private String getCacheDir() { return signlink.findcachedir(); } private String getCacheLink() { return cacheLink; } private int getCacheVersion() { return VERSION; } public CacheDownloader downloadCache() { try { File location = new File(getCacheDir()); File version = new File(getCacheDir() + "/cacheVersion" + getCacheVersion() + ".dat"); if(!location.exists()) { //drawLoadingText("Loading new Updates...."); downloadFile(getCacheLink(), getArchivedName()); unZip(); //System.out.println("UNZIP"); BufferedWriter versionFile = new BufferedWriter(new FileWriter(getCacheDir() + "/cacheVersion" + getCacheVersion() + ".dat")); versionFile.close(); deleteZIP(getArchivedName()); } else { if(!version.exists()) { //drawLoadingText("~ First Time Installation, Only Once! ~"); downloadFile(getCacheLink(), getArchivedName()); unZip(); //System.out.println("UNZIP"); BufferedWriter versionFile = new BufferedWriter(new FileWriter(getCacheDir() + "/cacheVersion" + getCacheVersion() + ".dat")); versionFile.close(); deleteZIP(getArchivedName()); } else { return null; } } } catch(Exception e) { } return null; } private void downloadFile(String adress, String localFileName) { OutputStream out = null; URLConnection conn; InputStream in = null; try { URL url = new URL(adress); out = new BufferedOutputStream( new FileOutputStream(getCacheDir() + "/" +localFileName)); conn = url.openConnection(); in = conn.getInputStream(); byte[] data = new byte[BUFFER]; int numRead; long numWritten = 0; int length = conn.getContentLength(); while((numRead = in.read(data)) != -1) { out.write(data, 0, numRead); numWritten += numRead; int percentage = (int)(((double)numWritten / (double)length) * 100D); drawLoadingText(percentage, "Downloading Cache " + percentage + "%.."); } System.out.println(localFileName + "\t" + numWritten); drawLoadingText("Unpacking.."); } catch (Exception exception) { exception.printStackTrace(); } finally { try { if (in != null) { in.close(); } if (out != null) { out.close(); } } catch (IOException ioe) { } } } private String getArchivedName() { int lastSlashIndex = getCacheLink().lastIndexOf('/'); if (lastSlashIndex >= 0 && lastSlashIndex < getCacheLink().length() -1) { return getCacheLink().substring(lastSlashIndex + 1); } else { //System.err.println("error retreiving archivaed name."); } return ""; } private void unZip() { try { InputStream in = new BufferedInputStream(new FileInputStream(fileToExtract)); ZipInputStream zin = new ZipInputStream(in); ZipEntry e; while((e=zin.getNextEntry()) != null) { if(e.isDirectory()) { (new File(getCacheDir() + e.getName())).mkdir(); } else { if (e.getName().equals(fileToExtract)) { unzip(zin, fileToExtract); break; } unzip(zin, getCacheDir() + e.getName()); } //System.out.println("unzipping2 " + e.getName()); } zin.close(); } catch(Exception e) { e.printStackTrace(); } } private void deleteZIP(String fileName){ // A File object to represent the filename File f = new File(getCacheDir() + fileName); // Make sure the file or directory exists and isn't write protected if (!f.exists()) throw new IllegalArgumentException( "Delete: no such file or directory: " + fileName); if (!f.canWrite()) throw new IllegalArgumentException("Delete: write protected: " + fileName); // If it is a directory, make sure it is empty if (f.isDirectory()) { String[] files = f.list(); if (files.length > 0) throw new IllegalArgumentException( "Delete: directory not empty: " + fileName); } // Attempt to delete it boolean success = f.delete(); if (!success) throw new IllegalArgumentException("Delete: deletion failed"); } private void unzip(ZipInputStream zin, String s) throws IOException { FileOutputStream out = new FileOutputStream(s); //System.out.println("unzipping " + s); byte [] b = new byte[BUFFER]; int len = 0; while ((len = zin.read(b)) != -1) { out.write(b,0,len); } out.close(); } } [/code]
  10. [quote name='Compulsion']Post your cachedownloader class, and I'll be glad to help.[/QUOTE] Please add my msn: [email][email protected][/email]
  11. Hey, I followed a tutorial & it didn't work. I'm getting a plain white screen on run with no errors, isn't it men't to show it downloading the cache? I'm using Enhanced PI client btw. For more information add my msn: [email][email protected][/email] Thanks.
  12. Why isn't this working exactly? This is client sided? (Entitydef.java) if(i == 13370) { stream.currentOffset = streamIndices[630]; entityDef.aByte68 = 3; entityDef.readValues(stream); // Collect original NPC data entityDef.actions = new String[5]; entityDef.actions[1] = "Attack"; int changedColors = 1; // Number of model colors changed on the NPC entityDef.originalModelColors = new int[changedColors]; entityDef.modifiedModelColors = new int[changedColors]; entityDef.originalModelColors[0] = 40; // Original model color entityDef.modifiedModelColors[0] = 34; // Changed model color entityDef.models = new int[9]; entityDef.models[0] = 6570;//Npc's Cape entityDef.models[1] = 3751;//Npc's Head entityDef.models[2] = 11724;//Npc's Plate entityDef.models[3] = 11726;//Npc's Legs entityDef.models[4] = 11694;//Npc's Weapon entityDef.models[5] = 7462;//Npc's Gloves entityDef.models[6] = 11732;//Npc's Boots entityDef.models[7] = 17461;//Npc's Darkness(Shadow) entityDef.models[8] = 20147;//Npc's Arms(You Dont Have To Edit) entityDef.standAnim = 6001;// Npc's Stand Emote entityDef.name = "Arthur"; entityDef.combatLevel = 138;//Combat Level entityDef.description = "A legendary warrior!".getBytes(); }