Lines to support selection of cells - java

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);

Related

Adding a summary header for columns and rows

I would like to add a single header for a group of columns and rows.
I've tried using ColumnGroupHeaderLayer but the text is in the centre of the column. Instead I would like it to always have the text drawn in the centre of the visible cell and always remain in the same position as I scroll.
I've looked through a lot of documentation but I'm struggling to find anything on how I could do this.
Example
Is it possible to achieve this with NatTable?
I answered the question in the forum where you posted at the same time
https://www.eclipse.org/forums/index.php/t/1099224/

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.

How to: JTable look and feel like Windows 7 Details View or Vuze table

In Windows 7 if we set the content of a Folder in Details view, then it turns into a table like structure, in which if we hover a row it renders a rectangular shape with light blue color and slightly curvy corner on that row and if we select a row a similar shape with blue color set on that row. This similar effect is shown by Vuze's table.
Is there any way to achieve this table rendering for JTable? If so what is the way to get it?
Any information will be helpful to me.
Thanks in advance.
The highlighted portions in the following image shows what I intended to achieve. The first highlight is the selected row and the second one is hovered.
you can do that by implement Substance Custom Look and Feel for JTreeTable,
plugin for SwingX
TreeTable by aepryh (best and open code for TreeTable)
notice you have to change XxxRenderer to SubstanceXxxRenderer (works on Xp / Win7 / 2008R2)
There's nothing built-in to achieve this. You can achieve the hover effect by using custom cell renderers and mouseover listeners. This answer gives you an overall picture of what to do.
As for the rectangular effect, again - custom cell renderers only, with either images, or drawRoundRect
I just noticed this post. JIDE has a component that does what you need. It is in paid JIDE Grids product. You can find a screenshot at http://www.jidesoft.com/images/navigation-components.png. Of course you can do this by yourself by overriding the paintComponent of a regular JTable. Using cell renderer approach won't work as the rollover effect needs to span the whole row.

JList: Horizontal_WRAP fitted?

Hey,.. i wanna show pictures with names onit in a jList, i know it get's also in a JPanel but i'm now using a jList, doesn't matter..
My question is why does the jlist don't fit the images only in 2 horizontal 'cells' and then go one row down?
sry my english is bad and i don't know how to describe it better, but look on the picture, why does the jlist dont set the e.g. 3rd picture right next to the 2nd?
JList.HORIZONTAL_WRAP works correctly in the ListDialog JWS demo, as described in Initializing a List. I suspect a layout problem, but you might compare your code to the examples found there.
If you use HORIZONTAL_WRAP you can adjust the number of columns with setVisibleRowCount. If you want them automatically fitted to the width of the list, use 0 or something negative.

Hiding a particular cell grid in Jtable

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

Categories