You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Dani

Intermediate

  • "Dani" started this thread

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

1

Tuesday, November 27th 2012, 10:46am

JBGrid - ColHeaderClick() Event added to Framework

Hey there,

I was missing a ColHeaderClick() Event in the JBGrid and was tired of adding a Mouselistener to every Grid I used in my projects (mostly database frontends).
So I added one to the JBGridHeader in the framework!

ColHeaderClick() Event is fired by clicking on a ColumnHeader.
ColHeaderIndex is set accordingly.
-1 for no column -> click on blank headerspace on the right side of the columns

The downside:
I am not quite sure how to indicate this event visually.
You can use this to indicate that interaction with the header is possible

Jabaco Source

1
2
'MousePointer
JBGrid1.Parent.getTableHeader.setCursor(VBMousePointerToJCursor(vbHandCursor))


When you add a JTable to a ScrollPane in Java the TableHeader behaves like JButtons do.
Mouseover, Mousepressed, 3D appearance...

In Jabaco the JBHeaderRenderer overrides the DefaultTableHeader and defines the appearance of JLabels.
Now since I am not a Java programmer I don't know of the possible approaches to mimic a ButtonDown Event visually.

So far my ColHeaderClick() Event is triggered in the JBGrid mouseReleased() Event which then sorts out what column the mousepointer is over.

Here the JBHeaderRenderer should be told how to paint that column header while Mouseover, Mousepressed, ...
In JBHeaderRenderer.getTableCellRendererComponent() this could be used to represent the aktion

Jabaco Source

1
2
3
4
'Mouseover
...setBorder or setForeground...
'Mousepressed
Call myHeader.setBorder(getMarginBorder(BorderFactory.createEtchedBorder(0), 1))    '(1), 1)) for normal



Also fixed an issue where JBGrid1_AfterCellEdit() was not fired!


Dani

Dani

Intermediate

  • "Dani" started this thread

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

2

Tuesday, November 27th 2012, 10:58am

as I have stated above,

when you add a JTable to a ScrollPane in Java the TableHeader behaves like JButtons do.
Mouseover, Mousepressed, 3D appearance...


The whole TableHeader appears much more polished



It would be nice to have that appearance for the JBGrid as well.
And it is easy to do.

BUT: I can not find a way to have icons (pictures) on the ColumnHeaders with the DefaultTableHeaderRenderer
Does anybody know if/how that is possible without overriding the Default Renderer.
Through the ColumnModel possibly?

Dani

Rate this thread
WoltLab Burning Board