Image as well as Text in a Component
i need a TextArea Like component in JAVA,
which can RECEIVE text as well as image.
The user can enter text and copy image into it.
this swing component's content i have to save in a database,
and retrieve it.
plz help me to solve the issue.
1)TextPane ,JEditorPane can be used?.this trial failed.
2) is there any other method to solve it?
-bejoy
[401 byte] By [
BEJOYa] at [2007-11-26 22:54:31]

# 5
This is one way to support pasting of images and text into a JTextPane:
JTextPane pane = new JTextPane();
pane.getActionMap().put("paste-from-clipboard", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
JTextPane pane = (JTextPane) e.getSource();
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
BufferedImage image;
try {
image = (BufferedImage) t.getTransferData(DataFlavor.imageFlavor);
pane.insertIcon(new ImageIcon(image));
} catch (Exception e1) { e1.printStackTrace(); }
}
else
pane.paste();
}
});
Saving the content and loading it back is a completely different story...
# 6
i have tried the above code .
i tries as follows
1) I TRIED TO USE JTextPane, JEditorPane .
but when these applets come to the webpage it gives security exception comes.
i have to use these component in an Intranet site.
2) how to get the data as a stream without missing the sequence of data from the JTextPane or JEDitorPane?.
3)is it possible to store data as a stream(i know possible but..) while showing in JSP is it possible
to render the text part of the stream as text and image part of the stream as image?
4)Plz is there any other method? to achieve this?
-bejoy