M
miris2
Gast
Hallo.
Ich habe ein Problem mit Java NetBeans IDE 3.6. Ich möchte ein Applet erzeugen das im Internert Explorer funktioniert. Mein Applet tut nur im Java Viewer und im Browser nicht.
Das ist der Java Code:
Das der HTML Code:
Das ist die Fehlermeldeungen die in der Java-Konsole erscheinen:
Weiss jemand was die Fehlerquelle sein kann? Danke im Vorraus!
Ich habe ein Problem mit Java NetBeans IDE 3.6. Ich möchte ein Applet erzeugen das im Internert Explorer funktioniert. Mein Applet tut nur im Java Viewer und im Browser nicht.
Das ist der Java Code:
Code:
/* Now you will be able to perform actions when a button is clicked
to get and place text in/out a textfield and to get the state of checkboxes.
This example will only let the button do actions.
*/
import java.awt.*;
import java.applet.*;
// import an extra class for the ActionListener
import java.awt.event.*;
// Tells the applet you will be using the ActionListener methods.
public class ActionExample extends Applet implements ActionListener
{
Button okButton;
Button wrongButton;
TextField nameField;
CheckboxGroup radioGroup;
Checkbox radio1;
Checkbox radio2;
Checkbox radio3;
public void init()
{
// Now we will use the FlowLayout
setLayout(new FlowLayout());
okButton = new Button("Action!");
wrongButton = new Button("Don't click!");
nameField = new TextField("Type here Something",35);
radioGroup = new CheckboxGroup();
radio1 = new Checkbox("Red", radioGroup,false);
radio2 = new Checkbox("Blue", radioGroup,true);
radio3 = new Checkbox("Green", radioGroup,false);
add(okButton);
add(wrongButton);
add(nameField);
add(radio1);
add(radio2);
add(radio3);
// Attach actions to the components
okButton.addActionListener(this);
wrongButton.addActionListener(this);
}
// Here we will show the results of our actions
public void paint(Graphics g)
{
// If the radio1 box is selected then radio1.getState() will
// return true and this will execute
if (radio1.getState()) g.setColor(Color.red);
// If it was not red we'll try if it is blue
else if (radio2.getState()) g.setColor(Color.blue);
// Since always one radiobutton must be selected it must be green
else g.setColor(Color.green);
// Now that the color is set you can get the text out the TextField
// like this
g.drawString(nameField.getText(),20,100);
}
// When the button is clicked this method will get automatically called
// This is where you specify all actions.
public void actionPerformed(ActionEvent evt)
{
// Here we will ask what component called this method
if (evt.getSource() == okButton)
// So it was the okButton, then let's perform his actions
// Let the applet perform Paint again.
// That will cause the aplet to get the text out of the textField
// again and show it.
repaint();
// Actions of the wrongButton
else if (evt.getSource() == wrongButton)
{
// Change the text on the button for fun
wrongButton.setLabel("Not here!");
// Changes the text in the TextField
nameField.setText("That was the wrong button!");
// Lets the applet show that message.
repaint();
}
}
}
// That gives you an idea of how to implement actions.
// Note that clicking the radiobuttons only shows it's effect when the
// applet is repainted. That is because no ActionListener is added
// to the radio buttons. You can do that in the same way as the buttons.
// Next example is about MouseListener, a way to let the user interact with mouse-clicks.
// Go to MouseClickExample.java
Das der HTML Code:
Code:
<HTML>
<HEAD>
<TITLE>Applet HTML Page</TITLE>
</HEAD>
<BODY>
<H3><HR WIDTH="100%">Applet HTML Page<HR WIDTH="100%"></H3>
<APPLET code="ActionExample.class" width=350 height=200></APPLET>
</P>
<HR WIDTH="100%"><FONT SIZE=-1>[I]Generated by NetBeans IDE[/I]</FONT>
</BODY>
</HTML>
Das ist die Fehlermeldeungen die in der Java-Konsole erscheinen:
- java.lang.IllegalArgumentException
at sun.net.www.ParseUtil.decode(Unknown Source)
at sun.net.www.protocol.file.Handler.openConnection(Unknown Source)
at java.net.URL.openConnection(Unknown Source)
at sun.applet.AppletPanel.getAccessControlContext(Unknown Source)
at sun.applet.AppletPanel.getClassLoader(Unknown Source)
at sun.applet.AppletPanel.createAppletThread(Unknown Source)
at sun.applet.AppletPanel.init(Unknown Source)
at sun.plugin.AppletViewer.appletInit(Unknown Source)
at sun.plugin.viewer.LifeCycleManager.initAppletPanel(Unknown Source)
at sun.plugin.viewer.IExplorerPluginObject$Initer.run(Unknown Source)
Weiss jemand was die Fehlerquelle sein kann? Danke im Vorraus!