Rieccomi qui a dare fastidio
Ho terminato la mia bella applicazione, la voglio distribuire ed allo stesso tempo non voglio che lasciare un unico file in mano all'utilizzatore finale (evitiamo che l'user "scassi" il giocattolo).
Quello che ho fatto:
[list=1][*]ho messo la cartella immagini nella directory "src" del progetto[*]ho modificato il file "build.xml" come indicato sul web[*]ho dato un bel clean & build[*]ho verificato che nel jar file ci sia la cartella (e ci sta)[/list=1]
funziona tutto eccetto la visualizzazione delle immagini.
ecco il codice [uso un progetto di test per fare prima]
codice:
package locationjlabeltest;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
public class LocationJLabelTest extends JFrame{
private JLayeredPane vassoio;
private static JPanel pannello3=new JPanel();
public LocationJLabelTest(){
super ("testJLabelLocation");
this.setMinimumSize(new Dimension(400, 400));
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
location2(this);
}
public void location2(JFrame frame){
JPanel pannello=new JPanel();
JPanel sfondo=new JPanel();
sfondo.setBackground(Color.YELLOW);
sfondo.setBounds(0,0, 400,400);
pannello.setBackground(Color.black);
pannello.setBounds(100, 200, 100,100);
System.out.println(getClass().getResource("./images/icona.png"));
/* Strada che dovrei seguire, ma non funziona!!! */
// JLabel a=new JLabel(new ImageIcon(getClass().getResource("./images/icona.png")));
/* Strada che funziona ma non mostra le immagini */
JLabel a=new JLabel(new ImageIcon("./images/icona.png"));
ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent itemEvent) {
int state = itemEvent.getStateChange();
if (state == ItemEvent.SELECTED) {
JPanel pannello2=new JPanel();
pannello2.setBackground(Color.red);
pannello2.setOpaque(true);
pannello2.setBounds(300, 100,50,50);
vassoio.add(pannello2,new Integer(4));
pannello3.setVisible(true);
System.out.println("settato!");
}
else{
System.out.println("De settato!");
pannello3.setVisible(false);
vassoio.remove(0);
repaint();
}
}
};
pannello.add(a);
JCheckBox box=new JCheckBox("prova");
box.addItemListener(itemListener);
box.setOpaque(false);
JPanel boxed=new JPanel();
boxed.setOpaque(false);
boxed.add(box);
boxed.setBounds(10, 20, 100,50);
vassoio=new JLayeredPane();
vassoio.add(boxed,new Integer(2));
vassoio.add(pannello,new Integer(1));
vassoio.add(sfondo,new Integer(0));
pannello3.setBackground(Color.blue);
pannello3.setOpaque(true);
pannello3.setVisible(false);
pannello3.setBounds(300, 220,50,50);
vassoio.add(pannello3,new Integer(3));
frame.add(vassoio);
frame.setVisible(true);
}
public static void main(String[] args) {
LocationJLabelTest l=new LocationJLabelTest();
}
}
Come spiegato con i commenti nel codice la soluzione ai mali del mondo sarebbe quella di usare:
codice:
JLabel a=new JLabel(new ImageIcon(getClass().getResource("./images/icona.png")));
ma l'applicazione non parte nemmeno!!! (potrei provare a lanciare il portatile, ma partirebbe nel modo errato
)
Se invece uso:
codice:
JLabel a=new JLabel(new ImageIcon("./images/icona.png"));
mi parte l'applicazione ma non sivedono le immagini... 
Invocare, invano o meno, tutte le divinità di tutte le religioni non è stato utile: confido in voi.
Grazie anticipato per le risposte.