Hallo,
ich habe mal wieder drei Probleme, wovon zwei etwas mit der GUI und der dazugehörigen ProgressBar zu tun haben und eines indirekt.
Also zu 1: Die Progressbar gibt komische Werte zurück, wie z.B. -44000 und zum Schluss dann 100.
zu 2: Die Progressbar wird nur angezeigt wenn ich die darauffolgende GUI entferne/deaktivere, da sich sonst schon die nächste GUI rendert, bevor man die DownloadGUI überhaupt sehen kann... Zudem mit entfernter nächsten GUI verbleibt man so lange bei Gui 1 bis die Progressbar bei 100% angekommen ist, erst dann kommt man weiter zu Gui 2 (DownloadGUI).
zu 3: Die zu downloadene Datei wird nicht gespeichert.
Hier der dazugehörige Log und Code:
InstallationHandler.java
DownloadGui.java
Ich hoffe ihr könnt mir dabei helfen.
JavaGamer
ich habe mal wieder drei Probleme, wovon zwei etwas mit der GUI und der dazugehörigen ProgressBar zu tun haben und eines indirekt.
Also zu 1: Die Progressbar gibt komische Werte zurück, wie z.B. -44000 und zum Schluss dann 100.
zu 2: Die Progressbar wird nur angezeigt wenn ich die darauffolgende GUI entferne/deaktivere, da sich sonst schon die nächste GUI rendert, bevor man die DownloadGUI überhaupt sehen kann... Zudem mit entfernter nächsten GUI verbleibt man so lange bei Gui 1 bis die Progressbar bei 100% angekommen ist, erst dann kommt man weiter zu Gui 2 (DownloadGUI).
zu 3: Die zu downloadene Datei wird nicht gespeichert.
Hier der dazugehörige Log und Code:
Code:
[INFO] Initialize Installer
[DEBUG] temp-String: http://download1891.mediafire.com/eokga8n019hg/ry715imp6810kd6/Primeval+Forest+%28MC+1.6.4%29.zip
[DEBUG] Clientlist: http://download1891.mediafire.com/eokga8n019hg/ry715imp6810kd6/Primeval+Forest+%28MC+1.6.4%29.zip
[DEBUG] C:\Users\Benutzer\AppData\Roaming\.minecraft\mods
[DEBUG] /eokga8n019hg/ry715imp6810kd6/Primeval+Forest+%28MC+1.6.4%29.zip
[DEBUG] Primeval+Forest+%28MC+1.6.4%29.zip
[DEBUG] Primeval Forest (MC 1.6.4).zip
[DEBUG] The Value (-11600) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10100) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10500) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-9700) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10100) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-9700) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-4900) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-11400) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-11500) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-6000) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-11000) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-3400) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-7700) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-11600) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-3900) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-11400) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10800) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-9500) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10100) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10800) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-3200) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-11700) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-11200) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-6200) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-3200) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10500) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10500) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-11400) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-11400) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10500) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-3200) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-9500) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10500) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10100) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10800) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-11400) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-8700) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-8300) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-5800) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-11800) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10800) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-10100) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-9700) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-4100) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (-4400) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (100) for the progress bar 'Dateifortschritt' was successfully set.
[DEBUG] The Value (1) for the progress bar 'Gesamtfortschritt' was successfully set.
InstallationHandler.java
Java:
/**
* @param downloadList The list of all download links
* @param destination The destination file to save the files in.
*
* @throws MalformedURLException wrong URL
*
* @since 1.0
*/
public static void downloadFiles(final ArrayList<String> downloadList, final File destination)
{
DownloadGui.setProgressMinMax(DownloadGui.getAllBar(), 0, downloadList.size());
DownloadGui.setProgressMinMax(DownloadGui.getCurrentBar(), 0, 100);
for(int i = 0; i < downloadList.size(); i++)
{
try
{
downloadFile(new URL(downloadList.get(i).toString()), destination);
}
catch (MalformedURLException e)
{
Logger.log2(Level.FATAL, e, downloadList.get(i).toString(), "InstallationHandler - MalformedURLException");
}
if(DownloadGui.getCurrentBar().getValue() == DownloadGui.getCurrentBar().getMaximum())
DownloadGui.setProgress(DownloadGui.getAllBar(), i + 1);
}
//if(DownloadGui.getAllBar().getValue() == DownloadGui.getAllBar().getMaximum())
//new FinishedGui();
}
/**
* Downloads the file from the given url and saves the file in the file-destination.
*
* @param websiteFile The URL from that the file should be downloaded.
* @param destination The destination file to save the file in.
*
* @since 1.0
*/
private static void downloadFile(URL websiteFile, File destination)
{
BufferedInputStream in = null;
FileOutputStream fout = null;
BufferedOutputStream bout = null;
URLConnection connection = null;
int minValue = 0;
int maxValue = 0;
try
{
connection = (URLConnection) websiteFile.openConnection();
maxValue = connection.getContentLength();
Logger.log(Level.DEBUG, StartUpGui.targetDir.getAbsolutePath());
Logger.log(Level.DEBUG, websiteFile.getFile());
String fileName = FileNameUtils.getName(websiteFile);
System.out.println(fileName);
in = new BufferedInputStream(connection.getInputStream());
fout = new FileOutputStream(StartUpGui.targetDir + fileName);
bout = new BufferedOutputStream(fout, 1024);
DownloadGui.setLabel(fileName);
forge = new File(fileName);
final byte data[] = new byte[1024];
int cout;
while((cout = in.read(data, 0, 1024)) != -1)
{
fout.write(data, 0, cout);
minValue = in.read();
DownloadGui.setProgress(DownloadGui.getCurrentBar(), (minValue * 100 ) / maxValue);
}
in.close();
fout.close();
bout.close();
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
DownloadGui.java
Java:
public DownloadGui()
{
this.panel.removeAll();
setup();
add(this.panel);
this.panel.validate();
this.panel.repaint();
new InstallationHandler();
}
Ich hoffe ihr könnt mir dabei helfen.
JavaGamer