Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Look & Feel and the JTree

Posted on 1998-11-15
2
Medium Priority
?
394 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 300 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

886 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