Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Look & Feel and the JTree

Posted on 1998-11-15
2
Medium Priority
?
392 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 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 …
This video teaches viewers about errors in exception handling.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

719 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