You are not logged in.

jcfuller

Beginner

  • "jcfuller" started this thread

Posts: 1

Date of registration: Dec 18th 2008

  • Send private message

1

Thursday, June 25th 2009, 1:10pm

Multi-line jbgrid header

Is it possible to create a jbgrid with multi-line header similar to attached?

James
jcfuller has attached the following image:
  • grid.JPG

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

2

Thursday, June 25th 2009, 3:51pm

Hi James,

yes this could be possible, maybe one solution could be to make your own TableCellRenderer.

You have to do this by making a new class, maybe you could use a JLable as SuperClass, and you must Implement the Interface TableCellRenderer. You first have to search for this class via the menu

Project->References(Classpath)

and then add it by checking the checkmark in front of TableCellRenderer



in your new class type:

Jabaco Source

1
Implements TableCellRenderer


Jabaco then automatically will add the following function to your class:

Jabaco Source

1
2
3
Public Function getTableCellRendererComponent(arg2 As JTable, arg3 As Object, arg4 As Boolean, arg5 As Boolean, arg6 As Integer, arg7 As Integer) As Component

End Function


and you have to add this line to this function:

Jabaco Source

1
getTableCellRendererComponent = Me




regards

OlimilO

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

3

Friday, December 9th 2011, 5:54pm

Jabaco Source

1
2
JBGrid1.HeaderHeight = 60  
JBGrid1.Header(1) = "<html>multiline header<br>JBGrid</html>"

:D

Perry

Beginner

  • "Perry" is male

Posts: 40

Date of registration: Jan 15th 2011

Location: Sarasota, FL

Occupation: Cabinet Design

Hobbies: Programming

  • Send private message

4

Tuesday, February 25th 2014, 2:22pm

I'm trying to reproduce this Application in Jabaco.



Notice the multi line Header, and how it is arranged.
I've read a bit on methods of creating multiline headers, but I have not located anything on combining cells.
Also Note that in some cases the text is centered in the header.
Though I can align text in the cells right, left or centered with the .DataMatrix().TextAlign property, I could not find a similar method to align text in the header.
I've tried a work around by using 2 JBGrids, the one at the top with only a header to use as a top header line. That works only until you need to scroll a grid horizontally. The Top header line, being another JBGrid, is not syncronized to scroll with it.

So my questions before I just give up as if "You can't get there from here".
Is there a way to reproduce the grid layout just pictured?
Lacking that, is there a way to syncronize the scrolling of 2 separate JBGrids?
I noticed the the JBGrid doesn't have a scroll event, nor is it clear where I might set the scroll position through code. So I am at a loss how to capture that event, let alone to sync a second grid to it.

Any help with this would be appreciated, even if "You can't get there from here". At least I could stop beating myself up over it.

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

5

Wednesday, February 26th 2014, 7:44am

Hey there Perry,

Quoted

multiline headers
I would say that's not a multiline header but multiple headers!
Not easy to achieve since JTable does not support a second header by default.
Your approach sounds fine to me.
Did you look at my JBGrid sample App?

attached .zip

I showed how to scoll vertically. Maybe that will help with horizontally scrolling too!
I will look into it but I don't have the time right now.

The centered text is not a problem. You will have to create a new property '.HeaderAlign' in JBGrid.jsrc and do the alignment in the JBHeaderRenderer.jsrc

I have it here somewhere!


Also: search stackoverflow and find Java equivalents, you will get the idea...

http://stackoverflow.com/questions/18363…s-in-java-swing
Dani

This post has been edited 1 times, last edit by "Dani" (Feb 26th 2014, 7:51am)


Rate this thread
WoltLab Burning Board