How do I populate a JComboBox
from a text file?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Very vague question. Are you saying you want one entry per line? If so you want to use something like a BufferedReader, read all the lines, save them as a String array. Create a new JComboBox passing in that String constructor.
Break down your requirements into separate steps and the code will follow:
1) read a line of data from the file 2) use the JComboBox addItem(...) method to add the data to the combo box
Here's an example that reads a properties file to get keys (for the combo) and values (for a text area). See
enum Rule
in the source.