المكتب الهندسي الأول( الأنظمـة المحوسبة العالمية )
هل تريد التفاعل مع هذه المساهمة؟ كل ما عليك هو إنشاء حساب جديد ببضع خطوات أو تسجيل الدخول للمتابعة.

المكتب الهندسي الأول( الأنظمـة المحوسبة العالمية )

ملتقى هندسي وبرمجي لكافة أقسام وفروع الهندسة و لتكنلوجيا تصميم الحواسيب والبرمجيات المختلفة و قسم خاص للتجارة الالكترونية والوظائف الشاغرة والبحث عن موظفين
 
الرئيسيةأحدث الصورالتسجيلدخول
أهلا وسهلا بك أخي الكريم في منتديات الأنظمة المحوسبة العالمية للهندسة و الكمبيوتر والتجارة الالكترونية نأمل ان تستفيد منا وتفيدنا من خبراتك ... وجزاك الله خيرا
منتديات الانظمة المحوسبة العالمية لكافة فروع الهندسة وهندسة الكمبيوتر ( تصميم وصيانة اللوحات الالكترونية والكمبيوترات والروبوتات واستخدام لغات البرمجة المختلفة وبرمجة الويب والانترنت ويوجد العديد من البرامج المتطورة ويوجد قسم للتجارة الالكترونية العامة عبر الانترنت , وقسم متخصص بكل ما يتعلق بالاجهزة الذكية الالكترونية ) فأهلا وسهلا بكم

 

 عمل صور متحركة باستخدام الجافا

اذهب الى الأسفل 
كاتب الموضوعرسالة
omar talahma

omar talahma


ذكر عدد المساهمات : 369
تاريخ التسجيل : 10/01/2010
العمر : 33
الموقع : دورا - الخليل - فلسطين
العمل/الترفيه : هندسة كمبيوتر
المزاج : جيد

عمل صور متحركة باستخدام الجافا Empty
مُساهمةموضوع: عمل صور متحركة باستخدام الجافا   عمل صور متحركة باستخدام الجافا Emptyالسبت مايو 29, 2010 10:45 am

// Fig. 21.2: LogoAnimatorJPanel.java
// Animating a series of images.
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Graphics;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.Timer;

// Fig. 24.3: LogoAnimator.java
// Displaying animated images on a JFrame.
import javax.swing.JFrame;

public class LogoAnimator
{
// execute animation in a JFrame
public static void main( String[] args )
{
LogoAnimatorJPanel animation = new LogoAnimatorJPanel();

JFrame window = new JFrame( "Animator test" ); // set up window
window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
window.add( animation ); // add panel to frame

window.pack(); // make window just large enough for its GUI
window.setVisible( true ); // display window

animation.startAnimation(); // begin animation
} // end main
} // end class LogoAnimator

class LogoAnimatorJPanel extends JPanel
{
private final static String IMAGE_NAME = "deitel"; // base image name
protected ImageIcon[] images; // array of images
private final int TOTAL_IMAGES = 30; // number of images
private int currentImage = 0; // current image index
private final int ANIMATION_DELAY = 50; // millisecond delay
private int width; // image width
private int height; // image height

private Timer animationTimer; // Timer drives animation

// constructor initializes LogoAnimatorJPanel by loading images
public LogoAnimatorJPanel()
{
images = new ImageIcon[ TOTAL_IMAGES ];

// load 30 images
for ( int count = 0; count < images.length; count++ )
images[ count ] = new ImageIcon( getClass().getResource(
"images/" + IMAGE_NAME + count + ".gif" ) );

// this example assumes all images have the same width and height
width = images[ 0 ].getIconWidth(); // get icon width
height = images[ 0 ].getIconHeight(); // get icon height
} // end LogoAnimatorJPanel constructor

// display current image
public void paintComponent( Graphics g )
{
super.paintComponent( g ); // call superclass paintComponent

images[ currentImage ].paintIcon( this, g, 0, 0 );

// set next image to be drawn only if Timer is running
if ( animationTimer.isRunning() )
currentImage = ( currentImage + 1 ) % TOTAL_IMAGES;
} // end method paintComponent

// start animation, or restart if window is redisplayed
public void startAnimation()
{
if ( animationTimer == null )
{
currentImage = 0; // display first image

// create timer
animationTimer =
new Timer( ANIMATION_DELAY, new TimerHandler() );

animationTimer.start(); // start Timer
} // end if
else // animationTimer already exists, restart animation
{
if ( ! animationTimer.isRunning() )
animationTimer.restart();
} // end else
} // end method startAnimation

// stop animation Timer
public void stopAnimation()
{
animationTimer.stop();
} // end method stopAnimation

// return minimum size of animation
public Dimension getMinimumSize()
{
return getPreferredSize();
} // end method getMinimumSize

// return preferred size of animation
public Dimension getPreferredSize()
{
return new Dimension( width, height );
} // end method getPreferredSize

// inner class to handle action events from Timer
private class TimerHandler implements ActionListener
{
// respond to Timer's event
public void actionPerformed( ActionEvent actionEvent )
{
repaint(); // repaint animator
} // end method actionPerformed
} // end class TimerHandler
} // end class LogoAnimatorJPanel
الرجوع الى أعلى الصفحة اذهب الى الأسفل
omar talahma

omar talahma


ذكر عدد المساهمات : 369
تاريخ التسجيل : 10/01/2010
العمر : 33
الموقع : دورا - الخليل - فلسطين
العمل/الترفيه : هندسة كمبيوتر
المزاج : جيد

عمل صور متحركة باستخدام الجافا Empty
مُساهمةموضوع: رد: عمل صور متحركة باستخدام الجافا   عمل صور متحركة باستخدام الجافا Emptyالسبت مايو 29, 2010 10:56 am

iهذا الكود جاهز فقط اعمل له نسخ ثم ألصقه على برنامج
JCreator Pro
الرجوع الى أعلى الصفحة اذهب الى الأسفل
 
عمل صور متحركة باستخدام الجافا
الرجوع الى أعلى الصفحة 
صفحة 1 من اصل 1
 مواضيع مماثلة
-
» عمل متصفح ويب باستخدام لغة الجافا
» برنامج الرسام باستخدام لغة الجافا
» كود بلغة الجافا يعمل على زيادة حجم كرة باستخدام JSlider
» طريقة اخيار الالوان في الجافا بثلاث طرق switches ,HSB,RGB

صلاحيات هذا المنتدى:لاتستطيع الرد على المواضيع في هذا المنتدى
المكتب الهندسي الأول( الأنظمـة المحوسبة العالمية ) :: هندسة الكمبيوتر و البرمجيات - سوفت وير و هارد وير :: أقسام لغات البرمجة والمكتبات البرمجية المشهورة :: لغة البرمجة java-
انتقل الى: