Advertise Here

Author Topic: Wana Update Whole GUI  (Read 5191 times)

0 Members and 1 Guest are viewing this topic.

Offline zilchuary

  • SMF For Free Newbie
  • *
  • Posts: 16
    • View Profile

  • Total Badges: 10
    Badges: (View All)
    Topic Starter Combination Level 2 Level 1 10 Posts
Wana Update Whole GUI
« on: January 04, 2008, 01:28:46 pm »
Code: [Select]
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import javax.swing.JButton
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

public class Updater implements ActionListener
{
public JFrame updateFrame;
public JPanel updatePanel;
public JButton updateButton;
public JProgressBar updateProgress;

public Updater()
{
updateFrame = new JFrame("Updater");
updatePanel = new JPanel(new BorderLayout());

updateButton = new JButton("Update");
updateButton.setActionCommand("Update");
updateButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
updateButton.addActionListener(this);
updateButton.setPreferredSize(new Dimension(150, 50));

updateProgress = new JProgressBar();
updateProgress.setStringPainted(true);
updateProgress.setString("Click update to update");
updateProgress.setPreferredSize(new Dimension(150, 50));
updateProgress.setMaximum(100);
updateProgress.setValue(0);

updatePanel.add(updateButton, BorderLayout.CENTER);
updatePanel.add(updateProgress, BorderLayout.SOUTH);

updateFrame.add(updatePanel);
updateFrame.pack();
updateFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
updateFrame.setVisible(true);
}

public static void main(String[] arg)
{
new Updater();
}

public void deleteFile(File aFile)
{
if(aFile.exists())
{
updateProgress.setString("Deleting jar");
aFile.delete();
}
}

public void actionPerformed(ActionEvent evt)
{
String c = evt.getActionCommand();
if(c.equals("Update"))
{
File jar = new File("runescape.jar");
deleteFile(jar);
try
{
updateProgress.setString("Connecting");
URLConnection jarUC;
jarUC = new URL("http://sl5.runescape.com/runescape.jar").openConnection();
DataInputStream down = new DataInputStream(jarUC.getInputStream());
updateProgress.setString("Creating data stream");
PrintStream out = new PrintStream(jar);
int length = jarUC.getContentLength();
updateProgress.setString("Downloading jar");
while(jar.length() < length)
{
out.write(down.read());
updateProgress.setValue((int)(jar.length()/length*100));
}
updateProgress.setString("Runescpe jar downloaded");
updateButton.setEnabled(false);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}

}

For the Java Gurus on this forums
they will all now whats this does

... for other people who dont understand
.. it actually says it Update GUI
Thats all it does


There
« Last Edit: January 04, 2008, 01:37:14 pm by zilchuary »

Offline LaundryLady

  • Helpers
  • *
  • Posts: 3253
  • Internet Challenged
    • View Profile

  • Total Badges: 26
    Badges: (View All)
    Seventh year Anniversary Sixth year Anniversary Search Poll Voter Level 5
Re: Wana Update Whole GUI
« Reply #1 on: January 04, 2008, 01:34:05 pm »
I don't see the support portion of this post.  What is this supposed to do?


And I Play:  Mafia-Mandemz

Offline zilchuary

  • SMF For Free Newbie
  • *
  • Posts: 16
    • View Profile

  • Total Badges: 10
    Badges: (View All)
    Topic Starter Combination Level 2 Level 1 10 Posts
Re: Wana Update Whole GUI
« Reply #2 on: January 04, 2008, 01:35:24 pm »
Updates the GUI

Offline LaundryLady

  • Helpers
  • *
  • Posts: 3253
  • Internet Challenged
    • View Profile

  • Total Badges: 26
    Badges: (View All)
    Seventh year Anniversary Sixth year Anniversary Search Poll Voter Level 5
Re: Wana Update Whole GUI
« Reply #3 on: January 04, 2008, 01:36:11 pm »
and why would I want to update the graphical user interface?


And I Play:  Mafia-Mandemz

Offline zilchuary

  • SMF For Free Newbie
  • *
  • Posts: 16
    • View Profile

  • Total Badges: 10
    Badges: (View All)
    Topic Starter Combination Level 2 Level 1 10 Posts
Re: Wana Update Whole GUI
« Reply #4 on: January 04, 2008, 01:38:45 pm »
Some People Need it For Some Servers/Games Ect
actually i have been asked alot for this

 

Related Topics

  Subject / Started by Replies Last post
Admin Update

Started by Prasad007 Suggestions

1 Replies
3205 Views
Last post October 28, 2005, 06:46:51 pm
by sop
7 Replies
2191 Views
Last post October 08, 2006, 02:53:44 am
by Laugh-nd-kid
1 Replies
1398 Views
Last post May 31, 2008, 10:28:59 pm
by SMF For Free
5 Replies
2064 Views
Last post June 29, 2008, 01:00:39 pm
by ray
1 Replies
1248 Views
Last post April 29, 2010, 12:37:58 am
by simply sibyl