help: jComboBox - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

help: jComboBox

tollitolli Posts: 44Member
hi guys....wanna make sure my code is alright:

i have a drop down menu with items to select being the names of eiles available in a directory. after hard search i implemented this code by adding some code lines to the templated constructor of JFrame: note that am working using netbeans 5.5:

public class NewJFrame extends javax.swing.JFrame {

/** Creates new form NewJFrame */
public NewJFrame() {
String curDir = System.getProperty("user.dir");
File dir = new File(curDir);

String[] children = dir.list();
if (children == null) {
// Either dir does not exist or is not a directory
else {
for (int i=0; i<children.length; i++) {
// Get filename of file or directory
String filename = children[i];
if (filename.indexOf(".txt")!=-1)

i am running the program and until now no errors appear however i think entering a directory can be done in a more efficient way especially if a large number of files exist. who may help me thinking about an alternative solution?

Sign In or Register to comment.