使用文本文件中的用户列表填充JComboBox

时间:2023-01-28 18:13:07

I have created a JFrame application in Netbeans, which has user creation and user log in for a tutorial application I am making, how would I populate a JComboBox from a text file when a user is created?

我在Netbeans中创建了一个JFrame应用程序,它有用户创建和用户登录我正在制作的教程应用程序,在创建用户时如何从文本文件中填充JComboBox?

I have created the application/user creation, But I am stuck on the JComboBox selection from the file... I have seen multiple things on how to, but nothing is working at this time.

我已经创建了应用程序/用户创建,但我仍然坚持从文件中选择JComboBox ...我已经看到了很多关于如何做的事情,但目前没有任何工作。

使用文本文件中的用户列表填充JComboBox

The application takes a persons:

该申请需要一个人:

  • First Name
  • 名字
  • Last Name
  • Desired Username (The thing I want in the JComboBox)
  • 期望的用户名(我在JComboBox中想要的东西)

And the log-in is literally just selecting the user from the JComboBox and listing all users created and clicking a button to log-in. The text file is located: F:\ProjectDecember\Users.txt

登录实际上只是从JComboBox中选择用户并列出所有创建的用户并单击登录按钮。文本文件位于:F:\ ProjectDecember \ Users.txt

Any help would be appreciated.

任何帮助,将不胜感激。

Thank You.

谢谢。

1 个解决方案

#1


1  

Check out Combo Box With Custom Renderer.

查看具有自定义渲染器的组合框。

It shows how you can create a custom renderer for your custom Object that you add to the combo box. It also shows an approach that you can use so you don't break the default functionality of the combo box when you use this custom renderer.

它显示了如何为添加到组合框的自定义对象创建自定义渲染器。它还显示了一种可以使用的方法,因此在使用此自定义渲染器时不会破坏组合框的默认功能。

#1


1  

Check out Combo Box With Custom Renderer.

查看具有自定义渲染器的组合框。

It shows how you can create a custom renderer for your custom Object that you add to the combo box. It also shows an approach that you can use so you don't break the default functionality of the combo box when you use this custom renderer.

它显示了如何为添加到组合框的自定义对象创建自定义渲染器。它还显示了一种可以使用的方法,因此在使用此自定义渲染器时不会破坏组合框的默认功能。