Example usage for javax.swing JTextPane insertIcon

List of usage examples for javax.swing JTextPane insertIcon

Introduction

In this page you can find the example usage for javax.swing JTextPane insertIcon.

Prototype

public void insertIcon(Icon g) 

Source Link

Document

Inserts an icon into the document as a replacement for the currently selected content.

Usage

From source file:PaneInsertionMethods.java

public static void main(String[] args) {

    final JTextPane pane = new JTextPane();

    pane.replaceSelection("text");
    pane.insertIcon(new ImageIcon("imageName.gif"));
    pane.insertComponent(new JButton("Click Me"));

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(pane, BorderLayout.CENTER);
    frame.setSize(360, 180);//from  w w w . j a va 2s. c o  m
    frame.setVisible(true);
}