Non intendevo variabile di sistema, ma sfruttabile nel codice(non penso che esisti CLASSPATH +"1.jpg"). Ho modificato la classe Ex( per fare in modo che nel JPanel venga vista solo l' immagine e che la dimensione del frame sia ottimizzata) come segue:
Codice PHP:
public class Ex {
public static final String classPath = "C:/Users/Luca/Java/";
public static void main(String[] args) {
JFrame frame = new JFrame("Frame di prova");
frame.setVisible(true);
frame.setSize(640,480);
frame.setResizable(false);
Image img = Toolkit.getDefaultToolkit().getImage(classPath + "fiore.jpg");
MyComp mycomp = new MyComp(img);
frame.add(mycomp);
adattaFrame(frame,img);
}
public static void adattaFrame(JFrame frame,Image img){
int screenWidth = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
int screenHeight = (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight();
frame.setSize((int)img.getWidth(frame),(int)img.getHeight(frame));
if(img.getWidth(frame)>screenWidth)
frame.setSize(screenWidth,frame.getHeight());
if(img.getHeight(frame)>screenHeight)
frame.setSize(frame.getWidth(),screenHeight);
}
}
Sta volta avviando con bluej il frame si ridimensiona, mentre col prompt no...