/ Published in: Java

This is a sample JTextArea with a custom background image.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; private static final long serialVersionUID = 7502204181430286959L; panel.add( new CustomTextArea() ); frame.setContentPane( panel ); frame.pack(); frame.setVisible( true ); } public CustomTextArea() { super(); init(); } } public void init() { ta.setFont( f ); ta.setLineWrap( true ); ta.setWrapStyleWord( true ); ta.setPreferredSize(getPreferredSize()); ta.setOpaque( false ); add( ta ); } super.paintComponent( g ); g.drawImage(image, 0, 0, null); } }
Comments
