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 06-30-2008, 02:39 PM
Member
 
Join Date: May 2008
Posts: 22
amith is on a distinguished road
repaint problem
i hav five images iam loading it with repaint after that i just want one image to fall from top to bottom using threads when iam using this only the image falling from top to bottom is visible but the five images loaded previously are not visible only the new image falling from top to bottom is visible can u suggest some paint method to this thing
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-30-2008, 02:48 PM
Niveditha's Avatar
Senior Member
 
Join Date: May 2008
Posts: 282
Niveditha is on a distinguished road
Send a message via Skype™ to Niveditha
Add the bigger image which covers from top to bottom then add the rest 5 small images...
__________________
To finish sooner, take your own time....
Nivedithaaaa
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-01-2008, 01:10 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,142
hardwired is on a distinguished road
Now we can slide up and down.
Code:
import java.awt.*; import javax.swing.*; public class SlidingDown extends JPanel implements Runnable { Image[] images; int[] yLocs; public SlidingDown() { String prefix = "images/geek/geek"; String[] ids = { "-c---", "--g--", "---h-", "----t" }; images = new Image[ids.length]; for(int i = 0; i < images.length; i++) { String path = prefix + ids[i] + ".gif"; images[i] = new ImageIcon(path).getImage(); } yLocs = new int[images.length]; for(int i = 0; i < yLocs.length; i++) { yLocs[i] = -images[i].getHeight(this); } } protected void paintComponent(Graphics g) { super.paintComponent(g); for(int i = 0; i < images.length; i++) { int x = (getWidth() - images[i].getWidth(this))/2; g.drawImage(images[i], x, yLocs[i], this); } } public Dimension getPreferredSize() { return new Dimension(300,400); } public void run() { int height = getPreferredSize().height; int index = 0; do { yLocs[index]++; repaint(); if(yLocs[index] > height) { index++; } try { Thread.sleep(100); } catch(InterruptedException e) { break; } } while(index < images.length); System.out.println("all done"); } private void start() { Thread thread = new Thread(this); thread.setPriority(Thread.NORM_PRIORITY); thread.start(); } public static void main(String[] args) { SlidingDown test = new SlidingDown(); JFrame f = new JFrame(); f.add(test); f.pack(); f.setLocation(200,200); f.setVisible(true); test.start(); } }
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
Problem in repaint Preethi AWT / Swing 16 03-18-2008 09:10 PM
Repaint problem swimberl Java 2D 1 02-16-2008 10:12 PM
Repaint problem swimberl Java 2D 0 01-06-2008 04:28 AM
repaint validate doLayout Gajesh Tripathi AWT / Swing 1 10-27-2007 07:53 PM
Repaint fails when using threads rjevans2000 Threads and Synchronization 1 09-22-2007 12:22 AM


All times are GMT +3. The time now is 05:03 PM.


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