Solved

Look & Feel and the JTree

Posted on 1998-11-15
2
384 Views
Last Modified: 2013-11-23
Hi,

I'm using swing 1.0.3 and jdk 1.1.6.
Development Platform: Windows NT 4.0
Deployment Platform : Windows NT 4.0 Application

I've implemented my own renderer and editor for a tree (JTree). I've did that by extending the classes 'BasicTreeCellRenderer' and 'DefaultCellEditor'. Then I've
implemented my own 'getTreeCellRendererComponent()' and 'getTreeCellEditorComponent()'. Both methods return a 'JPanel' which include a 'JLabel' and a 'JButton'
(I have to do that, because I want to display an image and a button with another image and text).
Now my problem:
Everything works fine with the 'Metal Look and Feel'. But if I try the Windows or Motif L&F the tree doesn't care about the space the components (my renderer and editor) do need (which means, the tree doesn't care about the getPreferredSize()).
It only shows the top of each renderer and cuts the bottom because the renderer (and editor seem to be too big).
How can I tell the Motif and Windows L&F, that they should ask for the preferredSize of its compoments and adapt to them.

Can you help me ?

Thankyou in advance,
JFM.
0
Comment
Question by:JFM
2 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 1227531
i don't have any documentation round here, but you can check if JTree has .setRowHeight method (or something similiar). I'm almost sure that JList and JTable has one. If JTree has such method, you can set the desired height directly.

  heyhey
0
 
LVL 3

Accepted Solution

by:
mjenkins earned 100 total points
ID: 1227532
Invoke JTree.setRowHeight(0); <-- That is a zero.

This tells the UI manager that the preferred size will be used to size the components.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
computer science syllabus 3 53
Python Assistance 7 36
Free Alternative to JIRA 4 58
what is a "java.lang.System Property"   ? 20 41
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now