Skip to main content

Inserting picture into jtextarea

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2012-05-01

Is it possible to insert picture into jtextarea. If it is, please kindly assist me with how to do it.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2012-10-10

Im not sure if this is what you r looking for. But after few googling found a way to insert background image.

public final class AreaTest extends JFrame
    public AreaTest(final Image image)
        Container container = getContentPane();
        container.setLayout(new BorderLayout());

        JTextArea textArea = new JTextArea()
            //Image grayImage = GrayFilter.createDisabledImage(image);

            public void paintComponent (Graphics g)
                g.drawImage(image, 0, 0, (int)getSize().getWidth(), (int)getSize().getHeight(), this);
                //g.drawImage(grayImage, 0, 0, (int)getSize().getWidth(), (int)getSize().getHeight(), this);


    public static void main(String[] args)
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image image = toolkit.createImage("RedDevil.png");

        AreaTest areaTest = new AreaTest(image);
        areaTest.setSize(300, 300);
        areaTest.setTitle("Area test");