Solved

Look & Feel and the JTree

Posted on 1998-11-15
2
389 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

759 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