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 / GUI / April 2005

Tip: Looking for answers? Try searching our database.

JTextPane with components as TreeCellRenderer

Thread view: 
lalo - 12 Apr 2005 23:54 GMT
Hi swingers!

Can anybody send me an example of using JTextPane as cell renderer?

I already made an implementation, using textpane for each node of a tree,
but unfortunatelly the components inserted to the textpane are not
visible. When I added an editor too, and clicked at a node to edit, the
components become visible. When finishing editing they disapears again.

The strange is, that the texts are shown, but for example an inserted
JLabel is not shown.

If I put the same component to a panel, all the components are visible.

Have anybody some ideea? I have read some post about this theme but I found
no solution for this :(

Thanks,
Lalo
Christian Kaufhold - 13 Apr 2005 10:39 GMT
> Can anybody send me an example of using JTextPane as cell renderer?
>
> I already made an implementation, using textpane for each node of a tree,
> but unfortunatelly the components inserted to the textpane are not
> visible. When I added an editor too, and clicked at a node to edit, the
> components become visible. When finishing editing they disapears again.

Try overriding paintComponent() (or paint()?) and call validate() first.

Christian
lalo - 13 Apr 2005 22:09 GMT
Hi Christian!

First of all thank's for your hint.

Finnaly I found the solution!!! :)

After debugging across the swing components I find out that is enough
if one of the component in the component hierarchy to not be visible
for not to show by the renderer.

By first shot I overwrited the java.awt.Component's isShowing() method
to always return true. This brought immediately the desired result.

Here is the JTextPane that will be shown by the cell renderers:

public class TestTextPane extends JTextPane {

    public void paint(Graphics g) {

        Container comp = getParent();

        while (comp != null) {
            comp.setVisible(true);
            comp = comp.getParent();
        }
        super.paint(g);
    }
}

Lalo


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.