الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيفية اضافة خلفية(صورة)على textArea

مغلق
بدأه microsmart1 في 14 أكتوبر 2006 · 2 رد · 649 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

ما هو الكود الخاص بإضافة خلفية أو وصورة على تكست مع امكانية الكتابة على التكست

حيث اننى بحثت عن الكود فى ال api ولم اجده

#2
اقتباس
You'll need to subclass the component, make sure it is not opaque,

and override the paintComponent() method such that the image is drawn before the superclass' paintComponent() method is called.

import javax.swing.*;
import java.awt.*;

public class BackgroundSample {
  public static void main(String args[]) {
	JFrame frame = new JFrame("Background Example");
	final ImageIcon imageIcon = new ImageIcon("draft.gif");
	JTextArea textArea = new JTextArea() {
	  Image image = imageIcon.getImage();
	  Image grayImage = GrayFilter.createDisabledImage(image);
	  {setOpaque(false);}  // instance initializer
	  public void paintComponent (Graphics g) {
		g.drawImage(grayImage, 0, 0, this);
		super.paintComponent(g);
	  }
	};
	JScrollPane scrollPane = new JScrollPane(textArea);
	Container content = frame.getContentPane();
	content.add(scrollPane, BorderLayout.CENTER);
	frame.setDefaultCloseOperation(3);
	frame.setSize(250, 250);
	frame.setVisible(true);
  }
}

لست متواجد بشكل يومي

#3

ألف شكر جدا يبشمهندس مجدى والله تعبينك معانا جدا

وجارى تجربة الكود

مع جزيل الشكر لشخصك على دائم الاهتمام والمساعدة

هذا الموضوع مغلق.

مواضيع مشابهة