如何在java swing中创建多个项目选择的下拉列表? [英] How to create a drop-down list in java swing with multiple item selection?

查看:483
本文介绍了如何在java swing中创建多个项目选择的下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 JList JComboBox 。我需要使用 JList 提供的多种选择功能的组合框下拉功能。

I'm aware of JList and JComboBox. I need the combo box drop down functionality with multiple selection functionality that JList provides.

这是因为列表太大,无法使用简单列表显示。我还需要选择多个项目,否则我将一直满足于 JComboBox

This is because the contents of the list are too huge to be displayed using a simple list. I also need to select multiple items, otherwise I would have been content with JComboBox.

任何建议? p>

Any suggestions?

推荐答案

使用多选时,最好使用列表而不是组合框。作为GUI隐喻,人们期望组合框是单​​选,而列表可以是。

When using multi-select, it's better to use a list than a combo box. As GUI metaphors go, people expect a combo box to be single select, whereas lists can be either.


列表的内容也是使用简单的列表显示巨大

the contents of the list are too huge to be displayed using a simple list

JList code> JScrollPane的。您可以致电 setVisibleRowCount(int) JList 上指定一次应显示多少行。

Place the JList in a JScrollPane. You can call setVisibleRowCount(int) on the JList to specify how many rows at a time should be shown.

这篇关于如何在java swing中创建多个项目选择的下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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