Hiding a particular cell grid in Jtable - java

I am trying to display numbers in the steps of 5,10,15,20 in a Jtable.
In case of 5 the column names will be 0,5,10,15...
In case of 10 the column names will be 0,10,20,30...
In case of 15 the column names will be 0,15,30,45...
In case of 20 the column names will be 0,20,40,60...
Right now I am able to display 5 and what I need is the same structure but by hiding the vertical cell grid between 5 and 10,15 and 20 and so on.After all this I should remove the column names 5,15,25 and so on.Its not merging columns because my cells are implementing JProgressBar and I need it for painting it in different proportions.Like a cell representing 0-5 may be painted from 0-3 or 3-5 or 2-4.And each cell may be painted based on some value like this.
EDIT::Something similar to Multiple - Span cell as in this link text but my need is merging almost alternate cells by hiding the grid rather than using an Array.Thats why I mentioned it as hiding the vertical border rather than merging the cell.

I think the best way to hide what you don't want to see is deleting it.
But If what you want is to hide or make invisible, most of swing components have a method call
setVisible(boolean value)
Here an example how to hide a row(I hope it helps):
http://www.rgagnon.com/javadetails/java-0216.html

Related

How can I render a JList inside a JTable cell?

In three of the columns of my JTable that I have set up I would like to have a list in each cell of the column. I'm not sure where to start on possibly creating a custom cell renderer class if that's the best option? My goal is to list the group names each on their own line in each cell, and expand the cell height as new lines are added. Each group will have an AdmType and Admitted entry, so I will also need to figure out how to add another checkbox to the Admitted column cell for every new Group entry.
This below solution did not work for me, but it clearly worked for the person who posted a screen shot of their success. My problems may be due to how I have my TableModel set up.
https://stackoverflow.com/a/32793088/6867420

How to change JTable column width depending on data?

How would I resize the column for it to just fit the largest string in that column. For example in one column I might have a word like "Monday" and I want this column to be shorter than the "Wednesday" column.
The data changes often as it shows the next 3 days, so I would want Java to automatically change it depending on the input data rather than me having to manually set the column width.
My JTable is within a JScrollPane if that changes anything
Hope that makes sense. Please point me in the right direction.

Can i add a button in a jface table row using ITableLabelProvider?

As I am having some 8 odd columns in my table, I dont wanna use ColumnLabelProvider. It will be tiresome and lengthy to add colours and all for every column using ColumnLabelProvider. So is there a way to add buttons in a LabelProvider implementing ITableLabelProvider?

Java Swing set color of rows and columns based on index with defaulttablemodel

I want to be able to do two things:
set colors of rows based on index, so first row is red, second blue,
third green
be able to set color of columns also based on something, be it index
or their names etc, whatever is possible.
I do not need to detect selection change or anything. Could someone tell me how to do that? What methods would help etc? In case the title wasn't read, this is regarding DefaultTableModel in JTables.
set colors of rows based on index,
Table Row Rendering might give you some ideas.
be able to set color of columns also based on something
You can provide a custom render for any column. Then you can add you logic to color the column based on something. Read the JTable API and follow the link to the Swing tutorial on How to Use Table and you will find a section on creating a custom renderer.

Lines to support selection of cells

I'm using the Netbeans RCP and want to make cell selection in a jtable more visible.
Therefore I like to draw red lines like the following:
See screenshot: http://i.stack.imgur.com/WRRyq.png
I only used GIMP to draw the lines on the screenshot ;-)
When selection increases and more cells are selected, the red lines should be the borders of the selection and should mark the whole width in the columnheader and the whole height in the row header.
My table will be much larger with a fixed columncount of ~35 and undefined count of rows.
Does anyone tried something like this before??
Thanks a lot in advance!
- Michael
Those may direct you to helpful information. Sorry I cannot provide exact answer to your case.
Outline view is a big fat JTable, so basically searching for information on parent components will give you more information on internal things.
org.openide.explorer.view.OutlineView outlineView;
To enable row selection:
outlineView.getOutline().setRowSelectionAllowed(true);
To define row selection mode: outlineView.getOutline().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
To disable cell selection: outlineView.getOutline().setCellSelectionEnabled(false);

Categories