Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree and JSpinner (Beginner)  RSS feed

 
Verena Dear
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm completely new to java and hope to get some help from anyone you.

I want to insert one or more JSpinners in a leaf and/or branch of a JTree, when clicking on it. I also need a label in front of the spinner. Any ideas how to realize that?

Thanks for any help,

--Verena
 
Eric Snell
Greenhorn
Posts: 28
Java Mac MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd suggest reading about cell renderers and editors in the swing tutorial.

Swing tutorial tree info
Swing tutorial editor/renderer discussion

Instead of a spinner, you might consider starting with a formatted text field which can supply the same basic functionality, albeit without the spinner buttons. I think it would be easier to start with.

If you must have a label, it will make your editor/renderer a little more work.

Here's a small code snippet that should get you started:

CodeGuru.com example
 
Verena Dear
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,

thank you for your reply.

I've found another way to realise what I wanted. Now I simply add one spinner (or more) in front of the tree, so that it is not really inserted but shown at the right coordinates. By this, I can keep the label of the branch/leaf and see the spinner.

Works perfect until now.

--Verena
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!