Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #38597
| From | Martin Gregorie <martin@mydomain.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Displaying a ragged array |
| Date | 2018-09-17 19:46 +0000 |
| Organization | albasani.net |
| Message-ID | <pnp0a1$rio$2@news.albasani.net> (permalink) |
| References | <pnmkqh$7dp$1@news.albasani.net> <pnod1l$mos$1@dont-email.me> |
On Mon, 17 Sep 2018 10:17:22 -0400, Eric Sosman wrote: > When queried for an "absent" cell, your TableModel could return > something -- null, "", whatever -- instead of throwing an exception. > Agreed. > The JTable could then display the "absent" value in whatever way you > pleased. Implementing your own TableCellRenderer would probably be > helpful. > Probably necessary. As I said, this is intended to be a CSV file editor and I'd certainly want to use different background colours for (empty) data fields, non-existent fields and comment lines. > Whether the tabular display works well would seem to depend on > "how ragged" the grid becomes. Your TableModel must advertise the > number of rows and columns in the grid, which probably means a lot of > work whenever the maximum row length changes. > Its easy to determine the max width of a column, but how fast it runs might be another issue. > If you've got twenty rows > of four columns and one of a hundred, things may get awkward. > It goes without saying that the table must scroll on both axes and it should be possible to set a max width on columns, say 20 chars by default. Wider columns (apart from comment lines) would only be viewable as a whole by using the field editor as a viewer. >> Would I be better off with a custom built structure containing, say, an >> array of JButtons to display fields in the ragged array and that can be >> clicked to add a field, edit or delete it? > > It appears the items in a single row are related somehow > Yes they are field in a single line. > [Are] those in a single column also related? > Somewhat - in parts of the some (most?) files they will contain the same data, but some files have several sections, separated by some form of delimiter line, and these will contain different data, so the "same column holds the same data type" only applies with a section of this type of file. > If so, a tabular display might > make the "vertical" relationships more apparent, and perhaps more useful > (you might sort on Column 3, for example). > Yes, that's the idea, though sorting is probably not terribly useful. > If there's no "vertical" relationship worth preserving, a table > of one column where each cell displays multiple items (maybe as a bunch > of JButtons, maybe as a JList, maybe as ...?) might work. Again, wild > discrepancies in the row lengths could be unpleasant. > Indeed. I'll probably end up trying both types - whichever is easiest to set up being tried first. > Have you considered using a JTree? > No, but will take a look at it. -- Martin | martin at Gregorie | gregorie dot org
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-16 22:17 +0000
Re: Displaying a ragged array Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-09-17 16:00 +0200
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-17 19:32 +0000
Re: Displaying a ragged array Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-09-17 23:29 +0200
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-17 23:43 +0000
Re: Displaying a ragged array Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-09-19 18:12 +0200
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-19 17:49 +0000
Re: Displaying a ragged array Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-09-19 14:25 -0400
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-19 19:29 +0000
Re: Displaying a ragged array Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-09-20 15:30 +0200
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-20 15:06 +0000
Re: Displaying a ragged array Eric Douglas <e.d.programmer@gmail.com> - 2018-09-24 08:11 -0700
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-24 17:52 +0000
Re: Displaying a ragged array Eric Douglas <e.d.programmer@gmail.com> - 2018-09-24 12:01 -0700
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-10-23 21:00 +0000
Re: Displaying a ragged array Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-09-17 10:17 -0400
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-17 19:46 +0000
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-17 23:53 +0000
csiph-web