help: jComboBox

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.

Howdy, Stranger!

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