running java gui on linux and windows
hi
i have a small code, and run on both linux and windows machine.
import javax.swing.*;
import java.awt.*;
public class ArdalanResim extends JFrame
{
javax.swing.ImageIcon icon;
Image image;
public ArdalanResim()
{
icon = new ImageIcon("background.jpg");
JPanel panel = new JPanel()
{
protected void paintComponent(Graphics g)
{
// Dispaly image at at full size
g.drawImage(icon.getImage(), 0, 0, null);
super.paintComponent(g);
}
};
panel.setOpaque( false );
panel.setPreferredSize( new Dimension(800, 600) );
getContentPane().add( panel );
}
public static void main(String [] args)
{
ArdalanResim ar = new ArdalanResim();
ar.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ar.setSize(800, 600);
ar.setLocationRelativeTo( null );
ar.setVisible(true);
}
}
on windows box, code runs fast (about in 1-2 seconds) but in linux it
takes 7 seconds to see the background.jpg. after investigating of code,
i see that the "icon = new ImageIcon("background.jpg");" causes the
delay. i tried on Debian Etch and Fedora Core 4 linux (p4 machine).
what should i do to make it faster?
thanks.