Newsgroup: it.comp.java
Titolo: Visualizzazione immagine jpg in applet

Come mai se nella mia applet cerco di visualizzare un'immagine questa non mi
appare?
Il log della java console è il seguente.....sembra che l'applet non riesca
ad accedere all'immagine eppure eseguendolo non in linea il tutto
funziona!!!
Grazie
Exception occurred during event dispatching:
java.security.AccessControlException: access denied (java.io.FilePermission
web.jpg read)
 at java.security.AccessControlContext.checkPermission(Unknown Source)
 at java.security.AccessController.checkPermission(Unknown Source)
 at java.lang.SecurityManager.checkPermission(Unknown Source)
 at java.lang.SecurityManager.checkRead(Unknown Source)
 at sun.awt.SunToolkit.getImageFromHash(Unknown Source)
 at sun.awt.SunToolkit.getImage(Unknown Source)
 at javax.swing.ImageIcon.<init>(Unknown Source)
 at javax.swing.ImageIcon.<init>(Unknown Source)
 at Passw.paint(Passw.java:47)
 at javax.swing.JApplet.update(Unknown Source)
 at sun.awt.RepaintArea.update(Unknown Source)
 at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
 at java.awt.Component.dispatchEventImpl(Unknown Source)
 at java.awt.Container.dispatchEventImpl(Unknown Source)
 at java.awt.Component.dispatchEvent(Unknown Source)
 at java.awt.EventQueue.dispatchEvent(Unknown Source)
 at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
 at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
 at java.awt.EventDispatchThread.run(Unknown Source)

Prova a mettere i sorgenti, solo cosě possiamo darti un aiuto concreto.
Ciao

E' la mia prima applet e spero non faccia tanto schifo. Quando parte chiede
una password che č "prova" (per ora inserita nel programma). Se la password
č giusta dovrebbe apparire l'immagine (ma appare solo non in linea!)
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.awt.Graphics;
public class Passw extends JApplet implements ActionListener {
  public Timer timer;
  private ImageIcon bit2;
  boolean ok,ok2;
 // MenuBar menuBar1 = new MenuBar();
  Panel panel1 = new Panel();
  Panel panel2 = new Panel();
  Label label1 = new Label();
  Label label2 = new Label();
  BorderLayout borderLayout1 = new BorderLayout();
  JPasswordField jPassword = new JPasswordField();
  JPanel jPanel1 = new JPanel();
  JButton jButton1 = new JButton();
  BorderLayout borderLayout2 = new BorderLayout();
  public void actionPerformed(ActionEvent e)
  {
  repaint();
  }
  public void init()
  {
  ok = false;
  ok2 = false;
  timer = new Timer(5000, this);
  timer.start();
  }
  public void paint(Graphics g)
  {
  if (ok2==true)
  {
  bit2 = new ImageIcon("web.jpg");
  bit2.paintIcon(this,g,getWidth()/2-90,80);
  }
  }
  public Passw() {
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  private void jbInit() throws Exception {
    panel1.setBackground(Color.blue);
    panel1.setFont(new java.awt.Font("Dialog", 0, 20));
    panel2.setBackground(Color.blue);
    panel2.setLayout(borderLayout1);
    label1.setFont(new java.awt.Font("Dialog", 1, 20));
    label1.setText("Pannello di autorizzazione");
    label2.setBackground(Color.blue);
    label2.setFont(new java.awt.Font("Dialog", 0, 15));
    label2.setText("Password");
    jButton1.setFont(new java.awt.Font("Dialog", 1, 12));
    jButton1.setHorizontalTextPosition(SwingConstants.LEFT);
    jButton1.setText("START");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jButton1_actionPerformed(e);
      }
    });
    jPanel1.setBackground(Color.cyan);
    jPanel1.setBorder(BorderFactory.createLineBorder(Color.black));
    jPanel1.setLayout(borderLayout2);
    this.getContentPane().setBackground(SystemColor.activeCaptionBorder);
    jPassword.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jPassword_actionPerformed(e);
      }
    });
    this.getContentPane().add(panel1, BorderLayout.NORTH);
    panel1.add(label1, null);
    this.getContentPane().add(panel2, BorderLayout.SOUTH);
    panel2.add(label2, BorderLayout.WEST);
    panel2.add(jPassword, BorderLayout.CENTER);
    panel2.add(jButton1, BorderLayout.EAST);
    this.getContentPane().add(jPanel1, BorderLayout.CENTER);
  }
  void jButton1_actionPerformed(ActionEvent e)
  {
  String s= new String(jPassword.getPassword());
  if (s.equals("prova"))
  { ok2 = true;
  }
  else
  { ok2 = false; }
  repaint();
  }
  void jPassword_actionPerformed(ActionEvent e) {
  }
}