Testing Combo Box loading (not JCombo) ========================================= == CurrentDriveLetter.java import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; public class CurrentDriveLetter { public String getRelativePath() { String relativePath = null; Path currRelativePath = Paths.get(""); String currAbsolutePathString = currRelativePath.toAbsolutePath().toString(); System.out.println("Current absolute path is - " + currAbsolutePathString); relativePath = currAbsolutePathString; return relativePath; } public String getPathRoot() { File file = new File("test.txt"); Path dllPath = Paths.get(file.getAbsolutePath()); Path driveLetter = dllPath.getRoot(); System.out.println("Current root is - " + driveLetter.toString()); return driveLetter.toString(); } } ======================================== === FilePathResource.java public class FilePathResource { /* replacing...with getComposersResource public String getURLResource() { return "http://cisackson.cgilinks.com/COTFCatalog/jComboBox-composersLN.txt"; } */ public String getComposersResource() { return getDrive() + "Categories/Categories.txt"; } public String getListFileWriterResource() { return getDrive() + "Root/SheetMusicLinks/MusicScores/pdf/"; } public String getIndexFileWriterResource() { return getDrive() + "Root/SheetMusicLinks/index.html"; } public String getSheetMusicLinksDirectoryResource() { return getDrive() + "Root/SheetMusicLinks/"; } public String getMusicScoresReadResource() { return getDrive() + "Root/SheetMusicLinks/MusicScores/pdf/"; } private String getDrive() { CurrentDriveLetter currentDriveLetter = new CurrentDriveLetter(); return currentDriveLetter.getPathRoot().toString(); } } =========================================== === MainWindowTest.java import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Button; import java.io.IOException; import java.util.ArrayList; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Combo; public class MainWindowTest { protected Shell shell; /** * Launch the application. * @param args */ public static void main(String[] args) { try { MainWindowTest window = new MainWindowTest(); window.open(); } catch (Exception e) { e.printStackTrace(); } } /** * Open the window. * @throws Exception */ public void open() throws Exception { Display display = Display.getDefault(); createContents(); shell.open(); shell.layout(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } /** * Create contents of the window. * @throws IOException */ protected void createContents() throws IOException { shell = new Shell(); shell.setSize(450, 524); shell.setText("SWT Application"); shell.setLayout(null); ArrayList arrayList; ReadCategoriesSourceFile categoryFileReader = new ReadCategoriesSourceFile(); arrayList = categoryFileReader.getCategoriesResourceFileArray(); Combo comboCategories = new Combo(shell, SWT.NONE); for (String str : arrayList) { System.out.println(str); comboCategories.add(str); } //comboCategories.setItems(new String[] {"Bach", "Bartok", "Billingsly"}); comboCategories.setToolTipText("List of Composers"); comboCategories.setBounds(77, 75, 254, 23); comboCategories.setText("Composers List"); Button btnTestButton = new Button(shell, SWT.NONE); btnTestButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { System.out.println("The test phase is now over. Use JRE 22 and select the default JRE button (second button)"); if(comboCategories.getSelectionIndex() > -1) { System.out.println("You selected: " + comboCategories.getItem(comboCategories.getSelectionIndex()) ); } } }); btnTestButton.setBounds(316, 371, 75, 25); btnTestButton.setText("Test Click"); } } =================================================== === ReadCatagoriesSourceFile.java import java.net.*; import java.util.ArrayList; import java.io.*; public class ReadCategoriesSourceFile { public ArrayList getCategoriesResourceFileArray() throws IOException { //Read lines of text from a file into an ArrayList of String items. FilePathResource filePath = new FilePathResource(); String resourceFilePath = filePath.getComposersResource(); ArrayList arrayList = new ArrayList(); URL cisackson; BufferedReader in; String inputLine; try { in = new BufferedReader(new FileReader(resourceFilePath)); while ((inputLine = in.readLine()) != null) { arrayList.add(inputLine); } in.close(); arrayList.sort(null); return arrayList; } catch (IOException e) { e.printStackTrace(); } return arrayList; } } ===================================================== == END