Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37618
| From | Daniele Futtorovic <da.futt.news@laposte.net> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: How do you update the view space of a JTable? |
| Date | 2017-10-31 11:10 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <ot9i92$7eg$1@dont-email.me> (permalink) |
| References | <8a75cc49-c369-41bb-8e5e-254977d4e410@googlegroups.com> <ot7kpq$koi$1@dont-email.me> <0a028d23-313f-4c8f-8516-80a5111e406a@googlegroups.com> |
On 2017-10-30 18:29, Eric Douglas wrote: > On Monday, October 30, 2017 at 12:42:43 PM UTC-4, Daniele Futtorovic wrote: >> >> Set a background for your scroll pane. >> >> Alternatively, you could mess with the TableModel to make it seem like >> there's more rows than you have data, but that's likely not the best idea. >> >> Mind rule #5008: if an established API like Swing repeatedly gets in the >> way of what you're trying to do, there's a good chance what you're >> trying to do is not a good idea. > Not a good idea to do what a framework doesn't expect you to do? How would you ever be able to do anything new? > I did find the way around this problem, though there's other problems because I'm making a dynamic JTable in a way apparently no one seems to have done before. See my other thread about frozen table rows. > > I'm trying to add a method to my JTable called setFrozenRows(int) to allow the user to scroll the table while leaving the first x rows in place. > The only way I found to do this is by wrapping 2 tables into 1 scrollpane (JScrollPane contains a JPanel which contains 2 JScrollPanes which each contain a JTable). > The API is not designed to do this, where I want to refer to them as 1 table. If I call setFrozenRows(2), rows 0-1 show in the top fixed table, and the bottom scrollable table starts with model row 2. Then if I call setSelectedRow(2) it should highlight the first row in the bottom table. I've been trying to do this with both tables sharing one table model, except clicking the first row of the second table still refers to it as row 0. A row filter didn't help with this. Run the example in the other thread and you'll see the row selection listener calling them row 0-1-0-1-2.. > > Either there is a better way to design that and I'm doing something wrong, or the design of the JTable classes is overly simplistic and needs to be hacked/overridden to handle it. > Just sharing something I've learned over the years and issuing a humble recommendation. You say you've found a workaround, but it sounds like a lot of work and not much around to show for it. My empirically-based expectation is that it won't get much better until you reconsider your approach. From the sounds of it, what you're having is purely a visual, a presentation problem. There are many, many ways to present things, and it generally doesn't pay to brute-force one specific way of presenting when the framework doesn't seem to accommodate it. -- DF.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How do you update the view space of a JTable? Eric Douglas <e.d.programmer@gmail.com> - 2017-10-17 08:47 -0700
Re: How do you update the view space of a JTable? Eric Douglas <e.d.programmer@gmail.com> - 2017-10-18 06:11 -0700
Re: How do you update the view space of a JTable? Daniele Futtorovic <da.futt.news@laposte.net> - 2017-10-30 17:41 +0100
Re: How do you update the view space of a JTable? Eric Douglas <e.d.programmer@gmail.com> - 2017-10-30 10:29 -0700
Re: How do you update the view space of a JTable? Daniele Futtorovic <da.futt.news@laposte.net> - 2017-10-31 11:10 +0100
Re: How do you update the view space of a JTable? Eric Douglas <e.d.programmer@gmail.com> - 2017-10-31 04:46 -0700
Re: How do you update the view space of a JTable? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-10-31 07:59 -0400
Re: How do you update the view space of a JTable? Eric Douglas <e.d.programmer@gmail.com> - 2017-10-31 05:21 -0700
Re: How do you update the view space of a JTable? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-10-31 08:32 -0400
Re: How do you update the view space of a JTable? Eric Douglas <e.d.programmer@gmail.com> - 2017-10-31 06:13 -0700
Re: How do you update the view space of a JTable? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-10-31 17:13 -0400
Re: How do you update the view space of a JTable? Daniele Futtorovic <da.futt.news@laposte.net> - 2017-10-31 23:33 +0100
Re: How do you update the view space of a JTable? Eric Douglas <e.d.programmer@gmail.com> - 2017-11-01 06:29 -0700
Re: How do you update the view space of a JTable? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-11-01 10:37 -0400
Re: How do you update the view space of a JTable? Eric Douglas <e.d.programmer@gmail.com> - 2017-11-01 08:37 -0700
Re: How do you update the view space of a JTable? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-11-01 13:20 -0400
csiph-web