Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-16-2008, 05:18 PM
Member
 
Join Date: Mar 2008
Posts: 3
ofir3dvb is on a distinguished road
Image with JWindow -> trails
Hi all !

First let me apologize for my bad english.
Secondly, I tried to show on the screen transpaernt animated gif, in another words, sprite(character) which walk on the desktop, well, i succsed, but there is a problem, if the sprite move is head, then on the screen you will see the sprite before and after the movmenet, there are trails.


for those who not understand the problem:




my code very simple at this moment:

public class WS extends JWindow
{
Image img=null;
Image img2=null;
Toolkit tk=null;
public WS()
{
tk=Toolkit.getDefaultToolkit();
this.setSize(500, 500);
this.setLocation(500, 500);
img2=tk.getImage("MijalNo.gif");

this.prepareImage(img2, null);

this.setVisible(true);

}


public void paint(Graphics g)
{
g.drawImage(img2, 0, 0, this);
}
}


i hope that you could help me.
thank you.

Last edited by ofir3dvb : 03-16-2008 at 05:21 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-17-2008, 02:18 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,141
hardwired is on a distinguished road
Code:
import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; import javax.imageio.ImageIO; import javax.swing.*; public class WS extends JPanel { BufferedImage img = null; Dimension size = new Dimension(100,100); public WS() { try { String path = "MijalNo.gif"; img = ImageIO.read(new File(path)); } catch(IOException e) { System.out.println("Read error: " + e.getMessage()); } size.setSize(img.getWidth(), img.getHeight()); } protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(img, 0, 0, this); } public Dimension getPreferredSize() { return size; } public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JScrollPane(new WS())); f.setSize(500, 500); f.setLocation(200, 100); f.setVisible(true); } }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-18-2008, 06:21 PM
Member
 
Join Date: Mar 2008
Posts: 3
ofir3dvb is on a distinguished road
thank you !

i think that will be it, i just didnt know who to implement it

thanks again i will check it out !
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JWindow/JFrame with boarders Java Tip Java Tips 0 03-12-2008 12:35 PM
Converting multiple banded image into single banded image... Image enhancement archanajathan Advanced Java 0 01-08-2008 06:29 PM
Image resizing alley Java 2D 2 11-13-2007 11:10 AM
How to mouse-drag a JWindow? cruxblack New To Java 3 08-06-2007 10:52 AM
Image Verification peiceonly Java Servlet 1 04-27-2007 05:50 PM


All times are GMT +3. The time now is 02:49 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org