如何在JComboBox中加载Tree? [英] how to load Tree inside JComboBox?

查看:66
本文介绍了如何在JComboBox中加载Tree?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在JComboBox弹出窗口中显示树?

这是示例树:

Theoretical computer science 
           Mathematical logic 
            Automata theory 
Algorithms and data structures
           Analysis of algorithms
           Algorithms

解决方案

没有默认方法将树放入组合框.有两种选择:

如果可以允许节点扩展,则可以通过在标准JComobBox中的某些选项之前添加空间来达到类似的效果.甚至在叶子选项前还有空格和破折号.

如果需要扩展节点,那么更好的选择是添加一个弹出窗口,该弹出窗口将显示在按钮下方,该按钮用于侦听树中的项目选择.根据GUI的布局,类似这样的选择可能是更好的选择.

How can I show a tree inside a JComboBox popup?

Here is example tree:

Theoretical computer science 
           Mathematical logic 
            Automata theory 
Algorithms and data structures
           Analysis of algorithms
           Algorithms

解决方案

There is no default way to put a tree in a combo box. There are a couple of options:

If you can give allowing expansion of nodes, you can achieve a similar effect by adding space before some of the options in a standard JComobBox. Or even space and a dash in front of leaf options.

If you need expansion of nodes, then a better option would be to add a popup that appears below a button that listens for selections of items in the tree. Something like this might be a better choice depending on how your GUI is laid out.

这篇关于如何在JComboBox中加载Tree?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆