Solved

Look & Feel and the JTree

Posted on 1998-11-15
2
386 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
egit plugin on eclipse 8 64
servlet example 17 32
Visual Studio 2013 and Eclipse Neon 6 38
Java syntax, or is it Selenium 6 15
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

803 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