Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / June 2006

Tip: Looking for answers? Try searching our database.

running java gui on linux and windows

Thread view: 
erchamion.beren@gmail.com - 19 Jun 2006 14:44 GMT
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.
Thomas Hawtin - 19 Jun 2006 16:47 GMT
> 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.

My guess is that the problem is down to lack of hardware acceleration,
due to poor drivers.

I think you should be able to emulate that problem on Windows using
-Dsun.java2d.noddraw=true (i.e. do not use Direct Draw).

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.