Das Teil soll ein ausgewähltes Bild anzeigen. Nachdem ich die Datei ausgewählt habe passiert nix weiter. Wo ist mein Fehler?
Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import javax.imageio.*;
public class AppletASP extends JApplet implements ActionListener
{
JButton button1 = new JButton();
boolean successful=true;
JOptionPane jop = new JOptionPane();
private File picture;
String pfad;
public void init()
{
button1.setLabel("lala");
this.getContentPane().add(button1, BorderLayout.NORTH);
button1.setBounds(120,200,98,30);
button1.addActionListener(this);
}
public void paintImage( Graphics g ) {
Image image = Toolkit.getDefaultToolkit().getImage( pfad );
g.drawImage(image,0,0,this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource().equals(button1))
{
JFileChooser fileDialog = new JFileChooser();
int xx = fileDialog.showSaveDialog(this);
fileDialog.show();
switch(xx) {
case JFileChooser.APPROVE_OPTION:
picture = fileDialog.getSelectedFile();
//ImageIcon icon = new ImageIcon(picture.getAbsolutePath());
pfad = picture.getAbsolutePath();
}
}
}
}