Hi,
ich bin ziemlich neu in Java und brauche mal etwas hilfe.
Denn ich hab mir ein Script geschrieben,das ein GUI öffnet und auf Button druck Mozilla Firefoy öffnen soll.
Nur schaff ich es nicht den Button mit dem Commando zu verlinken.
Dann gibts immer diese nette meldung.
Fals es ein wenig kirre aussieht sry ist mein erster "großer" Script.
Vielleicht kann mir wer sagen was daran so falsch ist und wie ich es hinkrich das das geht ^^
DrNed
PS:Wenn das das falsche Thema ist bitte ich das zu entschuldigen.
ich bin ziemlich neu in Java und brauche mal etwas hilfe.
Denn ich hab mir ein Script geschrieben,das ein GUI öffnet und auf Button druck Mozilla Firefoy öffnen soll.
Nur schaff ich es nicht den Button mit dem Commando zu verlinken.
Dann gibts immer diese nette meldung.
Java:
Compiliere C:\Java\TWO.java mit Java-Compiler
TWO.java:86:79: unreported exception java.io.IOException; must be caught or declared to be thrown
new ProcessBuilder( "rundll32", "url.dll,FileProtocolHandler", url ).start();
^
1 error
Java:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.ActionListener;
import java.io.IOException;
/**
*
* Beschreibung
*
* @version 1.0 vom 24.02.2011
* @author
*/
public class TWO extends JFrame {
// Anfang Attribute
private JLabel jLabel1 = new JLabel();
private JButton jButton1 = new JButton();
private JButton jButton11 = new JButton();
private JLabel jLabel2 = new JLabel();
private JLabel jLabel21 = new JLabel();
private JLabel jLabel3 = new JLabel();
// Ende Attribute
public TWO(String title) {
// Frame-Initialisierung
super(title);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
int frameWidth = 300;
int frameHeight = 300;
setSize(frameWidth, frameHeight);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (d.width - getSize().width) / 2;
int y = (d.height - getSize().height) / 2;
setLocation(x, y);
Container cp = getContentPane();
cp.setLayout(null);
// Anfang Komponenten
jLabel1.setBounds(8, 9, 274, 16);
jLabel1.setText("Wilkommen im Launcher.");
jLabel1.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel1);
jButton1.setBounds(8, 35, 97, 34);
jButton1.setText("Internet");
jButton1.setMargin(new Insets(2, 2, 2, 2));
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1_ActionPerformed(evt);
}
});
cp.add(jButton1);
jButton11.setBounds(8, 83, 97, 34);
jButton11.setText("Minecraft");
jButton11.setMargin(new Insets(2, 2, 2, 2));
jButton11.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton11_ActionPerformed(evt);
}
});
cp.add(jButton11);
jLabel2.setBounds(120, 48, 136, 16);
jLabel2.setText("Startet Mozilla Firefox");
jLabel2.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel2);
jLabel21.setBounds(122, 96, 105, 16);
jLabel21.setText("Startet Minecraft");
jLabel21.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel21);
jLabel3.setBounds(8, 248, 108, 16);
jLabel3.setText("written by DrNed");
jLabel3.setFont(new Font("MS Sans Serif", Font.PLAIN, 9));
cp.add(jLabel3);
// Ende Komponenten
setResizable(false);
setVisible(true);
}
// Anfang Methoden
public void jButton1_ActionPerformed(ActionEvent evt) {
// TODO hier Quelltext einfügen
String url = "http://www.javatutor.de";
new ProcessBuilder( "rundll32", "url.dll,FileProtocolHandler", url ).start();
}
public void jButton11_ActionPerformed(ActionEvent evt) {
// TODO hier Quelltext einfügen
String firefox = "C:\\Programme\\Server\\Minecraft_Server.exe";
}
// Ende Methoden
public static void main(String[] args) {
new TWO("Launcher v1.0");
}
public class LaunchBrowser
{
public void start( String[] args ) throws java.io.IOException
{
String url = "http://www.javatutor.de";
new ProcessBuilder( "rundll32", "url.dll,FileProtocolHandler", url ).start();
}
}
}
Fals es ein wenig kirre aussieht sry ist mein erster "großer" Script.
Vielleicht kann mir wer sagen was daran so falsch ist und wie ich es hinkrich das das geht ^^
DrNed
PS:Wenn das das falsche Thema ist bitte ich das zu entschuldigen.