java jframe编辑文本,Java:在JPanel / JFrame中列出项目的可编辑列表

Sorry, I'm kind of a beginner to GUI interfaces (well, a beginner to java, really), and I was wondering: How does one make a list of items that the user can add items to or remove items from, with the press of a + or - button?

What I really want (sorry if I'm being a little vague here) is one of those lists you sometimes see in application windows, which looks like a text box but cannot be typed in. Right now my application (it's a small app to organize the schedule of a hospital) just reads from a text file and writes to another text file. No GUI, no window, the user just writes a bunch of names in the text file, one per line, then runs the jar and opens the output file and the schedule is there. I want them to just be able to add or remove names from a list with buttons — adding a name by clicking 'plus' and typing the name, and removing a name by selecting the name and clicking 'minus'. I still, however, want it to save to a text file, so that the next time the user opens the app, all the names are still on the list.

Just to be clear, I don't want a list displaying the output (i.e. the names organized into a schedule), just one containing the input.

Thanks a lot for any help you can give.

解决方案

You probably want a JList with a couple of JButton instances to add/remove items.

HJghw.png

See:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值