|
Re: How to display file data in TextWindow or TextPanel?: msg#00257java.imagej
Hi, thanks Wayne for the help, now I can display the file data in a TextWindow. The data is like: 1 20020704001 PlugIn 2 20020704002 PlugInFilter 3 20020704003 PlugInFrame This is the sourcecode: import ij.*; import ij.text.*; import ij.util.*; import ij.plugin.PlugIn; import java.util.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class Record_Display implements PlugIn { public void run(String arg) { listRecords(); } public void listRecords() { File f = new File("plugins/demos/data.txt"); FileReader fr; BufferedReader br; ArrayList<String> al = new ArrayList<String>(); try { fr = new FileReader(f); br = new BufferedReader(fr); String s; String[] ss; while ((s = br.readLine()) != null) { ss = Tools.split(s, " "); al.add(ss[0] + "\t" + ss[1] + "\t" + ss[2]); } br.close(); } catch (IOException e) { e.printStackTrace(); } showList("Record Display", "Number\tID\tName", al); } void showList(String title, String headings, ArrayList<String> al) { String[] list = new String[al.size()]; al.toArray((String[])list); StringSorter.sort(list); StringBuffer sb = new StringBuffer(); for (int i = 0; i < list.length; i++) { sb.append(list[i]); sb.append("\n"); } TextWindow tw = new TextWindow(title, headings, sb.toString(), 300, 400); } } By the way, how can I find the source of the ImageJ's Menu: "File"->"Import"->"Text File..."? Sincerely Yili Zhao
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Opening multiple images simultaneously, Robert W. Baer, Ph.D. |
|---|---|
| Next by Date: | Linux launcher for ImageJ, Huw Blackwell |
| Previous by Thread: | Re: How to display file data in TextWindow or TextPanel?, Wayne Rasband |
| Next by Thread: | Antwort: Re: How to display file data in TextWindow or TextPanel?, Joachim Wesner |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |