Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37575

Re: How do you update the view space of a JTable?

Newsgroups comp.lang.java.programmer
Date 2017-10-18 06:11 -0700
References <8a75cc49-c369-41bb-8e5e-254977d4e410@googlegroups.com>
Message-ID <63f3cd00-ae3d-4173-abc1-b403ca5af839@googlegroups.com> (permalink)
Subject Re: How do you update the view space of a JTable?
From Eric Douglas <e.d.programmer@gmail.com>

Show all headers | View raw


On Tuesday, October 17, 2017 at 11:47:18 AM UTC-4, Eric Douglas wrote:
> If I call setFillsViewportHeight(true) it doesn't paint the entire view space of the JScrollPane if the table doesn't have enough rows to fill it.
> 
> I'm calling setFillsViewportHeight(false), and I'm overriding the BasicTableUI.paint() to do some custom cell drawing, but within this method the getClipBounds() of the Graphics is only returning the size of the rows.  How do I increase this size?  I've tried calling and overriding every method I can think of that should affect the size but it doesn't change.  The only other thing I know of is to call setFillsViewportHeight(true) and have to clear any unused space.

So, I couldn't figure out how to call setFillsViewportHeight(false) and be able to draw anything in a JViewport outside of the space the table rows take up.  The solution which seems to work is to call setFillsViewportHeight(true). This does not automatically clear the JViewport area outside of where the rows are drawn, and paints garbage in this space such as when I'm trying to drag a row.  The fix to that is to override BasicTableUI and override the public void paint(Graphics g,JComponent c) to include this code.

          Graphics2D g2d = (Graphics2D) g.create();
          Composite saveMe = g2d.getComposite();
          g2d.setComposite(AlphaComposite.Clear);
          g2d.setBackground(c.getParent().getBackground());
          g2d.clearRect(0, 0, c.getWidth(), c.getHeight());
          g2d.setComposite(saveMe);
          // call super.paint and/or manually paint table cells here
          g2d.dispose();

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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