import java.awt.Choice;
import java.awt.FileDialog;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.*;
@SuppressWarnings("serial")
public class DLgui extends JFrame{
// nu die ganzen variablen, die müssen jetzt nicht mehr static sein
JFrame frm = new JFrame("Windows 7 & 8.1 Downloader");
static Choice cho = new Choice();
static Choice cho1 = new Choice();
Label label = new Label("OS Auswahl:");
Label label1 = new Label("USB-Stick Auswählen:");
JButton dow = new JButton("Download");
JButton dowa = new JButton(" Download abbrechen");
JButton abb = new JButton("Abbruch");
JButton usb = new JButton("USB-Medium erstellen...");
JButton image = new JButton("Image auswählen...");
JButton start = new JButton("...& erstellen");
static JProgressBar jpb = new JProgressBar(0, 100);
String filename, site;
Object object = new Object();
static Thread zero, one, two, three, four, five, six, seven;
private DLgui(){
// hier wird dein objekt/klasse erstellt. also einfach setBounds und so weiter
frm.setBounds(50, 50, 415, 350);
frm.setLayout(null);
frm.setResizable(false);
frm.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
frm.dispose();
System.exit(0);
}});
jpb.setValue(0);
jpb.setMaximum(100);
jpb.setStringPainted(true);
cho.insert("Windows 7 Home Premium 32Bit", 0);
cho.insert("Windows 7 Home Premium N 32Bit",1);
cho.insert("Windows 7 Home Premium 64Bit",2);
cho.insert("Windows 7 Professional 32Bit",3);
cho.insert("Windows 7 Professional N 32Bit",4);
cho.insert("Windows 7 Professional 64Bit",5);
cho.insert("Windows 8.1 32Bit",6);
cho.insert("Windows 8.1 64Bit",7);
label.setFont(new Font("Arial", Font.BOLD, 12));
label.setBounds(25, 60, 100, 30);
frm.add(label);
cho.setBounds(135, 63, 250, 30);
frm.add(cho);
dow.setBounds(25, 100, 90, 30);
frm.add(dow);
dowa.setBounds(120, 100, 160, 30);
frm.add(dowa);
abb.setBounds(285, 100, 100, 30);
frm.add(abb);
usb.setBounds(25, 150, 360, 30);
frm.add(usb);
jpb.setBounds(25, 270, 360, 30);
frm.add(jpb);
image.setBounds(25, 230, 175, 30);
frm.add(image);
start.setBounds(210, 230, 175, 30);
frm.add(start);
frm.setVisible(true);
dow.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
cho.getSelectedItem();
}
});
abb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frm.dispose();
System.exit(0);
}
});
usb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
label1.setFont(new Font("Arial", Font.BOLD, 12));
label1.setBounds(25, 190, 130, 30);
frm.add(label1);
cho1.setBounds(175, 193, 210, 30);
frm.add(cho1);
}
});
image.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileDialog fd = new FileDialog(new Frame());
fd.setTitle("USB-Medium auswählen");
fd.setVisible(true);
fd.setMode(FileDialog.LOAD);
object = fd.getFile();
}
});
start.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ProcessBuilder builder = new ProcessBuilder("cmd", "/c", "diskpart", "list disk");
try {
Process p = builder.start();
}
catch (IOException e1) {
e1.printStackTrace();
}
}
});
Thread zero = new Thread(new Runnable(){
public void run(){
String site = "http://msft-dnl.digitalrivercontent.net/msvista/pub/X15-65740/X15-65740.iso";
String filename = "C:\\Users\\XC\\Desktop\\Win7_Home_Premium_32.iso";
URL url = null;
try {
url = new URL(site);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
} catch (IOException e1) {
e1.printStackTrace();
}float totalDataRead=0;
java.io.BufferedInputStream in = null;
try {
in = new java.io.BufferedInputStream(connection.getInputStream());
} catch (IOException e1) {
e1.printStackTrace();
}java.io.FileOutputStream fos = null;
try {
fos = new java.io.FileOutputStream(filename);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
byte[] data = new byte[1024];
int i=0;
try {
while((i=in.read(data,0,1024))>=0){
float filesize = (float) 2463242240.0;
totalDataRead=totalDataRead+i;
bout.write(data,0,i);
float Percent=(totalDataRead*100)/filesize;
jpb.setValue((int)Percent);
}
} catch (IOException e1) {
e1.printStackTrace();
}try {
bout.close();
} catch (IOException e1) {
e1.printStackTrace();
}try {
in.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
Thread one = new Thread(new Runnable(){
public void run(){
String site = "http://msft-dnl.digitalrivercontent.net/msvista/pub/X16-13473/X16-13473.iso";
String filename = "C:\\Windows\\Temp\\Win7_Home_Premium_32(N).iso";
URL url = null;
try {
url = new URL(site);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
} catch (IOException e1) {
e1.printStackTrace();
}float totalDataRead=0;
java.io.BufferedInputStream in = null;
try {
in = new java.io.BufferedInputStream(connection.getInputStream());
} catch (IOException e1) {
e1.printStackTrace();
}java.io.FileOutputStream fos = null;
try {
fos = new java.io.FileOutputStream(filename);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
byte[] data = new byte[1024];
int i=0;
try {
while((i=in.read(data,0,1024))>=0){
float filesize = (float) 2184001536.0;
totalDataRead=totalDataRead+i;
bout.write(data,0,i);
float Percent=(totalDataRead*100)/filesize;
jpb.setValue((int)Percent);
}
} catch (IOException e1) {
e1.printStackTrace();
}try {
bout.close();
} catch (IOException e1) {
e1.printStackTrace();
}try {
in.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
Thread two = new Thread(new Runnable(){
public void run(){
String site = "http://msft-dnl.digitalrivercontent.net/msvista/pub/X15-65741/X15-65741.iso";
String filename = "C:\\Windows\\Temp\\Win7_Home_Premium_64.iso";
URL url = null;
try {
url = new URL(site);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
} catch (IOException e1) {
e1.printStackTrace();
}float totalDataRead=0;
java.io.BufferedInputStream in = null;
try {
in = new java.io.BufferedInputStream(connection.getInputStream());
} catch (IOException e1) {
e1.printStackTrace();
}java.io.FileOutputStream fos = null;
try {
fos = new java.io.FileOutputStream(filename);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
byte[] data = new byte[1024];
int i=0;
try {
while((i=in.read(data,0,1024))>=0){
float filesize = (float) 3192264704.0;
totalDataRead=totalDataRead+i;
bout.write(data,0,i);
float Percent=(totalDataRead*100)/filesize;
jpb.setValue((int)Percent);
}
} catch (IOException e1) {
e1.printStackTrace();
}try {
bout.close();
} catch (IOException e1) {
e1.printStackTrace();
}try {
in.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
Thread three = new Thread(new Runnable(){
public void run(){
String site = "http://msft.digitalrivercontent.net/win/X17-59886.iso";
String filename = "C:\\Windows\\Temp\\Win7_Professional_32.iso";
URL url = null;
try {
url = new URL(site);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
} catch (IOException e1) {
e1.printStackTrace();
}float totalDataRead=0;
java.io.BufferedInputStream in = null;
try {
in = new java.io.BufferedInputStream(connection.getInputStream());
} catch (IOException e1) {
e1.printStackTrace();
}java.io.FileOutputStream fos = null;
try {
fos = new java.io.FileOutputStream(filename);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
byte[] data = new byte[1024];
int i=0;
try {
while((i=in.read(data,0,1024))>=0){
float filesize = (float) 2463242240.0;
totalDataRead=totalDataRead+i;
bout.write(data,0,i);
float Percent=(totalDataRead*100)/filesize;
jpb.setValue((int)Percent);
}
} catch (IOException e1) {
e1.printStackTrace();
}try {
bout.close();
} catch (IOException e1) {
e1.printStackTrace();
}try {
in.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
Thread four = new Thread(new Runnable(){
public void run(){
String site = "http://msft-dnl.digitalrivercontent.net/msvista/pub/X16-13564/X16-13564.iso";
String filename = "C:\\Windows\\Temp\\Win7_Professional(N)_32.iso";
URL url = null;
try {
url = new URL(site);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
} catch (IOException e1) {
e1.printStackTrace();
}float totalDataRead=0;
java.io.BufferedInputStream in = null;
try {
in = new java.io.BufferedInputStream(connection.getInputStream());
} catch (IOException e1) {
e1.printStackTrace();
}java.io.FileOutputStream fos = null;
try {
fos = new java.io.FileOutputStream(filename);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
byte[] data = new byte[1024];
int i=0;
try {
while((i=in.read(data,0,1024))>=0){
float filesize = (float) 2184001536.0;
totalDataRead=totalDataRead+i;
bout.write(data,0,i);
float Percent=(totalDataRead*100)/filesize;
jpb.setValue((int)Percent);
}
} catch (IOException e1) {
e1.printStackTrace();
}try {
bout.close();
} catch (IOException e1) {
e1.printStackTrace();
}try {
in.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
Thread five = new Thread(new Runnable(){
public void run(){
String site = "http://msft.digitalrivercontent.net/win/X17-59885.iso";
String filename = "C:\\Windows\\Temp\\Win7_Professional_64.iso";
URL url = null;
try {
url = new URL(site);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
} catch (IOException e1) {
e1.printStackTrace();
}float totalDataRead=0;
java.io.BufferedInputStream in = null;
try {
in = new java.io.BufferedInputStream(connection.getInputStream());
} catch (IOException e1) {
e1.printStackTrace();
}java.io.FileOutputStream fos = null;
try {
fos = new java.io.FileOutputStream(filename);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
byte[] data = new byte[1024];
int i=0;
try {
while((i=in.read(data,0,1024))>=0){
float filesize = (float) 3192264704.0;
totalDataRead=totalDataRead+i;
bout.write(data,0,i);
float Percent=(totalDataRead*100)/filesize;
jpb.setValue((int)Percent);
}
} catch (IOException e1) {
e1.printStackTrace();
}try {
bout.close();
} catch (IOException e1) {
e1.printStackTrace();
}try {
in.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
Thread six = new Thread(new Runnable(){
public void run(){
String site = "http://care.dlservice.microsoft.com/dl/download/1/B/E/1BEDF444-0504-4694-A738-4005AAD16887/9600.16384.WINBLUE_RTM.130821-1623_X86FRE_ENTERPRISE_EVAL_DE-DE-IRM_CENA_X86FREE_DE-DE_DV5.ISO";
String filename = "C:\\Windows\\Temp\\Win8.1_32.iso";
URL url = null;
try {
url = new URL(site);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
} catch (IOException e1) {
e1.printStackTrace();
}float totalDataRead=0;
java.io.BufferedInputStream in = null;
try {
in = new java.io.BufferedInputStream(connection.getInputStream());
} catch (IOException e1) {
e1.printStackTrace();
}java.io.FileOutputStream fos = null;
try {
fos = new java.io.FileOutputStream(filename);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
byte[] data = new byte[1024];
int i=0;
try {
while((i=in.read(data,0,1024))>=0){
float filesize = (float) 2463242240.0;
totalDataRead=totalDataRead+i;
bout.write(data,0,i);
float Percent=(totalDataRead*100)/filesize;
jpb.setValue((int)Percent);
}
} catch (IOException e1) {
e1.printStackTrace();
}try {
bout.close();
} catch (IOException e1) {
e1.printStackTrace();
}try {
in.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
Thread seven = new Thread(new Runnable(){
public void run(){
String site = "http://care.dlservice.microsoft.com/dl/download/1/B/E/1BEDF444-0504-4694-A738-4005AAD16887/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_ENTERPRISE_EVAL_DE-DE-IRM_CENA_X64FREE_DE-DE_DV5.ISO";
String filename = "C:\\Windows\\Temp\\Win8.1_64.iso";
URL url = null;
try {
url = new URL(site);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
} catch (IOException e1) {
e1.printStackTrace();
}float totalDataRead=0;
java.io.BufferedInputStream in = null;
try {
in = new java.io.BufferedInputStream(connection.getInputStream());
} catch (IOException e1) {
e1.printStackTrace();
}java.io.FileOutputStream fos = null;
try {
fos = new java.io.FileOutputStream(filename);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
byte[] data = new byte[1024];
int i=0;
try {
while((i=in.read(data,0,1024))>=0){
float filesize = (float) 2463242240.0;
totalDataRead=totalDataRead+i;
bout.write(data,0,i);
float Percent=(totalDataRead*100)/filesize;
jpb.setValue((int)Percent);
}
} catch (IOException e1) {
e1.printStackTrace();
}try {
bout.close();
} catch (IOException e1) {
e1.printStackTrace();
}try {
in.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
}
public static void main(String[] args){
DLgui meinFenster = new DLgui();
// meinFenster.setVisible(true);
if(cho.getSelectedIndex() == 0){
zero.start();
}
}}