
بعض الشرح باللغة العربية
هذا الكود البسيط والجميل ومهمته وضع اي صورة بشكل متكرر على كامل نافذة البرنامج, الكود يستخدم تقنية رسم الصورة على النافذة وليست وضع الصورة على مكون ثم تكرير المكون Component. مبدا الطريقة وهو بداية رسم الصورة الاساسية على الزاوية العليا اليسرى ثم نسخ المساحة بشكل متكرر حتى نقوم بتغطية النافذة بشكل كامل, وهكذا والكود موجود في الاسفل مع التوضيع لكل تعليمية او اي تابع مستخدم. والطريقة للحصول على الصورة بسيطة جدا حيث المسار ممكن ان يكون على القرص الصلب c,d,e … وممكن ان يكون على موقع ويب http://…
Some explain in Engish
This is a very simple and nice code and its function is to make the image tiles on your Form. The code use Draw Function in Graphics2D library in JAVA not a component like JLabel and tiles it . The way we do this is to draw the image on the TOP-LEFT corner and then we copy the area of image till we fill all form. The image may be on HARDDISK Driver such as c:\ d:\ … or on website like http:\\eadoking.com\logos\eadoking.com_logo.png
CLASS 1 (EadokingImagePanel.java)
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.net.URL;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
/**
*
* @author Eadoking
* @website http://eadoking.com
* @email eadoking@yahoo.com
* @email info@eadoking.com
* @mobile +963 932728084
*/
public class EadokingImagePanel extends JPanel {
private Image image = null;
public EadokingImagePanel() {
// the image path may be URL on network sich as
// String fileURL = "http://virtual-linux-server/eadoking_website_local/eadoking.com_logo.png";
// or it could be direct path from hard disk like
// d:\eadoking.com_logo.png WE PUT THEN
// d:\\eadoking.com_logo.png : \\ cuz first \ is an escape character
String filePATH = "http://localhost/eadoking.com_logo.png";
try {
// URL because netword path
// File if on harddisk sucj as d:\img
image = ImageIO.read(new URL(filePATH));
} catch (IOException ex) {
ex.printStackTrace();
}
}
@Override
public void paintComponent(Graphics g) {
// cast the Graphics to Graphics2D
Graphics2D g2d = (Graphics2D) g;
// if image = null means if image not found or something wrong when load it
// if that happens then do nothing (return)
if (image == null) {
return;
}
// get the image height and width
int imageWidth = image.getWidth(this);
int imageHeight = image.getHeight(this);
// draw the image in the top left corner
g2d.drawImage(image, 0, 0, this);
// repeat drawing image
for (int i = 0; i * imageWidth < = getWidth(); i++) {
for (int j = 0; j * imageHeight <= getHeight(); j++) {
if (i + j > 0) {
g.copyArea(0, 0, imageWidth, imageHeight, i * imageWidth, j * imageHeight);
}
}
}f
}
}
CLASS 2 (EadokingSimpleFrame.java)
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
/**
*
* @author Eadoking
* @website http://eadoking.com
* @email eadoking@yahoo.com
* @email info@eadoking.com
* @mobile +963 932728084
*
*
*/
public class EadokingSimpleFrame extends JFrame {
public EadokingSimpleFrame() {
setTitle("Eadoking Window with tiled Image");
// this code get the Default Toolkit
Toolkit kit = Toolkit.getDefaultToolkit();
// get the screen resolution
Dimension d = kit.getScreenSize();
// this is the screen width and height
int screenWidth = d.width;
int screenHeight = d.height;
// set the frame size 50% of the screen (desktop)
setSize(screenWidth / 2, screenHeight / 2);
//this simple instruction put the frame in the center of the screen
setLocationRelativeTo(null);
// creat new object of the ImagePanel
EadokingImagePanel imgPanel = new EadokingImagePanel();
//add the panel to the frame to be shown
add(imgPanel);
//set the frame vtrisible
without it we can't c the frame
setVisible(true);
//when we press (x) close then program terminated
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
CLASS 3 (EadokingMainProgram.java)
import java.awt.EventQueue;
/**
*
* @author Eadoking
* @website http://eadoking.com
* @email eadoking@yahoo.com
* @email info@eadoking.com
* @mobile +963 932728084
*/
public class EadokingMainProgram {
public static void main(String[] args) {
Runnable r= new Runnable() {
public void run() {
EadokingSimpleFrame frame=new EadokingSimpleFrame();
}
};
EventQueue.invokeLater(r);
}
}
انشاء الله بكون وضحت المعلومات بشكل واضح واي سؤال او استفسار انا جاهز مع تحيات عيدووو Eadoking
Hope everything is clear and uderstood , any question am ready, with regards. 3edoOo (Eadoking)





Very cute
))),
Very cute
))),
Perfect work!,
Perfect work!,
Great site. Keep doing.,
Great site. Keep doing.,
Great work,webmaster,nice design!,
Great work,webmaster,nice design!,
I bookmarked this link. Thank you for good job!,
I bookmarked this link. Thank you for good job!,
welcome bro and wait all new stuff
welcome bro and wait all new stuff
v5lqNY I bookmarked this link. Thank you for good job!
v5lqNY I bookmarked this link. Thank you for good job!
for more about me go to about-me or contact me or
hope u like this code
for more about me go to about-me or contact me or
hope u like this code
lot about you
lot about you
RT @eadoking Window with a tiles image drawing on java frame | Ead AlDoukanje Eadoking Official Website : Your Way to… http://bit.ly/HCd90
RT @eadoking Window with a tiles image drawing on java frame | Ead AlDoukanje Eadoking Official Website : Your Way to… http://bit.ly/HCd90