Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / January 2006

Tip: Looking for answers? Try searching our database.

Displaying small pictures in a text window

Thread view: 
Allan Bruce - 13 Jan 2006 15:49 GMT
I want to display small pictures in a text window, its actually emoticons in
a messenger I want to implement.  How should I do this in Java.  Ideally I
would like to support animated pictures, but any method to display any
format would be welcome.

Thanks
Allan
Andrey Kuznetsov - 13 Jan 2006 18:28 GMT
>I want to display small pictures in a text window, its actually emoticons
>in a messenger I want to implement.  How should I do this in Java.  Ideally
>I would like to support animated pictures, but any method to display any
>format would be welcome.

see JTextPane.insertIcon(Icon g)

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Allan Bruce - 13 Jan 2006 21:20 GMT
> >I want to display small pictures in a text window, its actually emoticons
> >in a messenger I want to implement.  How should I do this in Java.
> >Ideally I would like to support animated pictures, but any method to
> >display any format would be welcome.
>
> see JTextPane.insertIcon(Icon g)

Thanks,

Can I also change the colour of fonts with a JTextArea?  I had a look but
couldnt see how.  Is there a way to have changable colour fonts AND be able
to add the pictures?

Many Thanks
Allan
Andrey Kuznetsov - 13 Jan 2006 23:09 GMT
> Can I also change the colour of fonts with a JTextArea?  I had a look but
> couldnt see how.  Is there a way to have changable colour fonts AND be
> able to add the pictures?

with JTextPane you can many things.
some important keywords: setCharacterAttributes, setParagraphAttributes,
AttributeSet

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Allan Bruce - 14 Jan 2006 03:07 GMT
>> Can I also change the colour of fonts with a JTextArea?  I had a look but
>> couldnt see how.  Is there a way to have changable colour fonts AND be
[quoted text clipped - 3 lines]
> some important keywords: setCharacterAttributes, setParagraphAttributes,
> AttributeSet

Aha, JTextPane!  I was using a JTextAre.  Thanks, its working now.
Allan
Allan Bruce - 14 Jan 2006 03:43 GMT
>> Can I also change the colour of fonts with a JTextArea?  I had a look but
>> couldnt see how.  Is there a way to have changable colour fonts AND be
[quoted text clipped - 3 lines]
> some important keywords: setCharacterAttributes, setParagraphAttributes,
> AttributeSet

Actually, there is one last thing - I might be pushing it here!  What if I
wanted to add a background image instead of the plain coloured background.
Do you know if this is possible?

Thanks
Allan
Andrey Kuznetsov - 14 Jan 2006 11:08 GMT
> Actually, there is one last thing - I might be pushing it here!  What if I
> wanted to add a background image instead of the plain coloured background.
> Do you know if this is possible?

probably you could create your own BTextpane
and override paintComponent as follow:

public void paintComponent(Graphics g) {
   paintBackgroundImage();
   super.paint(g);
}

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Roedy Green - 14 Jan 2006 03:53 GMT
>Can I also change the colour of fonts with a JTextArea?

Yes, is the usual way. see http://mindprod.com/jgloss/jtextarea.html
but everything must be the same.  If you want variety, you need a
JTextPane or JEditorPane.

See http://mindprod.com/jgloss/jeditorpane.html
http://mindprod.com/jgloss/jtextpane.html

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Allan Bruce - 16 Jan 2006 21:36 GMT
> >I want to display small pictures in a text window, its actually emoticons
> >in a messenger I want to implement.  How should I do this in Java.
> >Ideally I would like to support animated pictures, but any method to
> >display any format would be welcome.
>
> see JTextPane.insertIcon(Icon g)

I have this implemented now, however some of the animated gifs come out
slightly corrupted, in that a few of the frames are wrong, or they only show
part of the file - is there anything I can do or should be doing to avoid
this?

Thanks
Allan


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.