Hi,
folgender Code läuft einwandfrei in Eclipse, aber im Firefox wie IE krieg ich bloß eine leere, graue Fläche und unten steht jeweils "Applet StromkreisApplet started".
StromkreisApplet.java:
stromkreis.html:
Verwende ich evtl. irgendwelche Swing-Elemente, die in einem JApplet nicht vorkommen dürfen?
Gruß Michi
folgender Code läuft einwandfrei in Eclipse, aber im Firefox wie IE krieg ich bloß eine leere, graue Fläche und unten steht jeweils "Applet StromkreisApplet started".
StromkreisApplet.java:
Code:
import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class StromkreisApplet extends JApplet implements ActionListener
{
Image MyImage;
Canvas Grafik;
JButton StromstaerkeButton,
SpannungButton;
public void actionPerformed ( ActionEvent e )
{
if ( e.getSource () == StromstaerkeButton)
{
}
}
public void init()
{
try
{
setSize ( new Dimension ( 600, 600));
Container contentPane = getContentPane();
//contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS));
JPanel panel = new JPanel();
//__________________________________________________________
JPanel EingabePanel1 = new JPanel();
EingabePanel1.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
Label StromstaerkeLabel = new Label ( "Stromstärke I:" );
EingabePanel1.add ( StromstaerkeLabel );
TextField StromstaerkeEingabe = new TextField ( 3 );
EingabePanel1.add ( StromstaerkeEingabe );
StromstaerkeButton = new JButton ("setze Stromstärke");
EingabePanel1.add ( StromstaerkeButton );
//__________________________________________________________
JPanel EingabePanel2 = new JPanel();
EingabePanel2.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
Label SpannungLabel = new Label ( "Spannung U:" );
EingabePanel2.add ( SpannungLabel );
TextField SpannungEingabe = new TextField ( 3 );
EingabePanel2.add ( SpannungEingabe );
SpannungButton = new JButton ("setze Spannung");
EingabePanel2.add ( SpannungButton );
//__________________________________________________________
JPanel EingabePanel = new JPanel();
EingabePanel.setLayout ( new BoxLayout ( EingabePanel,
BoxLayout.Y_AXIS ) );
EingabePanel.add(EingabePanel1);
EingabePanel.add(EingabePanel2);
JSplitPane splitPane = new JSplitPane(
JSplitPane.VERTICAL_SPLIT,
new JLabel ( new ImageIcon ( "leitergrafik.JPG" ) ),
EingabePanel );
splitPane.setOneTouchExpandable(true);
panel.add(splitPane);
contentPane.add (panel);
this.setVisible ( true );
}
catch ( Exception e )
{
System.out.println ( e );
}
}
}
stromkreis.html:
Code:
<HTML>
<BODY>
<APPLET CODE=StromkreisApplet.class archive="stromkreis.jar" WIDTH=800 HEIGHT=800>
</APPLET>
</BODY>
</HTML>
Verwende ich evtl. irgendwelche Swing-Elemente, die in einem JApplet nicht vorkommen dürfen?
Gruß Michi