Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #36653
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: How are you supposed to set JTable height? |
| Date | 2017-05-22 17:15 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <ofvk6m$1ku$1@dont-email.me> (permalink) |
| References | (6 earlier) <ofpasc$rti$1@dont-email.me> <961818ff-485d-49dd-8c3d-e0558911cf94@googlegroups.com> <ofun7i$m5l$1@dont-email.me> <5f3ffc95-aa9c-4e39-b810-5bf5d25b5a44@googlegroups.com> <588e1a19-3194-4984-8767-7013e6dd9e7b@googlegroups.com> |
On 5/22/2017 12:18 PM, Eric Douglas wrote:
> On Monday, May 22, 2017 at 9:43:03 AM UTC-4, Eric Douglas wrote:
>> On Monday, May 22, 2017 at 9:00:56 AM UTC-4, Eric Sosman wrote:
>>> On 5/22/2017 7:55 AM, Eric Douglas wrote:
>>>> On Saturday, May 20, 2017 at 7:59:28 AM UTC-4, Eric Sosman wrote:
>>>>>
>>>>> I can't help you with this part, since I've never tried to mess
>>>>> with the plaf layers. On the other hand, I've never needed to: For
>>>>> filtering, sorting, and custom-painting rows and cells, I've just
>>>>> used RowFilter, TableRowSorter, and sometimes a customized
>>>>> TableCellRenderer or TableCellEditor. These have met my needs
>>>>> without recourse to mucking about in the lower levels.
>>>>>
>>>>
>>>> RowFilter doesn't work unless getRowCount() only returns the amount of visible rows.
>>>> I want the user to be able to filter on values in one column, but I still want to get and set values in another column including the rows they don't see.
>>>
>>> I don't know which of the several getRowCount() methods you
>>> refer to: That of JTable, or of TableModel, or of any of several
>>> other table-related classes and interfaces. But in any event,
>>> all I can say is that RowFilter and TableRowSorter have worked
>>> just fine without me needing to worry about what's visible and
>>> what's not. It seems probable that you're doing something far
>>> more intricate than I've ever attempted, so I'll have to bow out.
>>>
>> That of JTable, which has to match the filter.
>> I call methods on the table to get and set values, which makes sense when we want to process only what the user sees as they're seeing them. Normally sort order is not an issue. In this case I want the user to be able to filter so they only see some of the rows, but there is another process linked to the table which needs to get and update all the rows, so either it needs to get the model to work directly with the data which I don't otherwise do, or it needs methods on the table that work with model row values instead of view rows.
>
> Oh well, JTable doesn't allow zero row height so they don't make it easy. I guess if I can't tell them not to paint certain rows I'll just go with the RowFilter, and a flag on the table telling get and set methods to use model instead of view.
Setting should surely be done through the model, not through the
table. You then needn't worry about whether the altered cells are or
are not filtered, are or are not scrolled out of the viewport, do or
do not belong to funny-sized rows, do or do not lie in columns that
the user has rearranged, ...
Getting should also probably be done through the model, for all
the same reasons. The only reason I can imagine for wanting to do
it through the table instead is if you need to do something different
with visible vs. non-visible cells.
With Swing components, one should "almost always" manipulate and
query data through the model rather than through the view. Do things
to the ButtonModel and the JButton responds, do things to the ListModel
and the JList responds, ... do things to the TableModel and the JTable
responds. You've revealed none of your code, but I begin to suspect
that much of your trouble arises from trying to work backwards, trying
to make the view govern the model instead of vice-versa.
--
esosman@comcast-dot-net.invalid
Thirteen hundred thirty-nine days to go.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
How are you supposed to set JTable height? Eric Douglas <e.d.programmer@gmail.com> - 2017-05-19 07:20 -0700
Re: How are you supposed to set JTable height? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-05-19 11:22 -0400
Re: How are you supposed to set JTable height? Eric Douglas <e.d.programmer@gmail.com> - 2017-05-19 10:45 -0700
Re: How are you supposed to set JTable height? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-05-19 14:29 -0400
Re: How are you supposed to set JTable height? Eric Douglas <e.d.programmer@gmail.com> - 2017-05-19 11:42 -0700
Re: How are you supposed to set JTable height? Eric Douglas <e.d.programmer@gmail.com> - 2017-05-19 13:06 -0700
Re: How are you supposed to set JTable height? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-05-20 07:59 -0400
Re: How are you supposed to set JTable height? Eric Douglas <e.d.programmer@gmail.com> - 2017-05-22 04:55 -0700
Re: How are you supposed to set JTable height? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-05-22 09:00 -0400
Re: How are you supposed to set JTable height? Eric Douglas <e.d.programmer@gmail.com> - 2017-05-22 06:42 -0700
Re: How are you supposed to set JTable height? Eric Douglas <e.d.programmer@gmail.com> - 2017-05-22 09:18 -0700
Re: How are you supposed to set JTable height? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-05-22 17:15 -0400
csiph-web