2

I want to fix the header of my content so it does not scroll down with the content. Is it possible to do it with a, and if yes, could you please shed some light as to how I can go about implementing it without using a JTable.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Raymond Nakampe
  • 371
  • 7
  • 22

2 Answers2

3

JScrollPane has

public void setRowHeader(JViewport rowHeader)

See e.g. http://www.java2s.com/Code/Java/Swing-JFC/Scrollpaneruler.htm

StanislavL
  • 56,971
  • 9
  • 68
  • 98
  • 2
    Use `setColumnHeaderView` to get the header above the content and you don't have to make your own view port. – Walter Laan Sep 20 '12 at 12:27
  • @ Walter Laan You are right! Both row and column headers are possible. – StanislavL Sep 20 '12 at 12:32
  • Thanx a lot for the info @ StanislavL, I appreciate it, @ Walter thank you, exactly what I needed, it really worked wonders. Wish I could mark it as useful but I dont have enough reputation points. Once again thank you guys. – Raymond Nakampe Sep 20 '12 at 15:27
2
  • JTable in the JScrollPane has TableHeader fixed in Rectangle

  • there are three (standard)ways where isn't TableHeader fixed on some Point

    1. JTable in the JScrollPane is layed by som of LayoutManager (notice depends of type of LayoutManager or area ) into resiziable Container

    2. JTable in the JScrollPane could be draggable

    3. JTable has resizable ColumnModel

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
mKorbel
  • 109,525
  • 20
  • 134
  • 319