Is it possible for JTable column headers to be verticaly aligned? - java

I'm working on a hotel booking timeline feature for hotel management system. I have a JTable where rows represent rooms and columns represent days. If room is booked for that day, the corresponding cell is highlighted. Since these cells don't have any content and only serve to visually represent days when the rooms are booked, it seems rather pointless for them to have width larger then height. But if I adjust them to be equal column headers containing days are shortened and instead of "02.01.2012." all I see is "...". Since this is not an option I was wondering is it possible to "rotate" the header cells so the text in them is aligned vertically.

You may use the method described in Vertical Table Header Cell Renderer to show the header text in a vertical manner.

Related

javaFx set splitpane size to wrap tableview

My requirement is displaying a varying number of Rows in a tabelView, where each row contains a label column and a second colum,n with either a textBox, comboBox, richtext or datePicker.
The user may enter some of the values and start a search via a button, displaying the result sint he bottom half of the splitPane.
This table is displayed in a vertical splitPane like this:
Name | txtName
date | datepickerDate
gender | cmbGender
----------------------------
Results will be shown here
The number of rows of the top-table may vary from 1 to 20+.
I have fixed the maximum splitPane size to be 50%-50% distributed, if the table requires more space than 50% of the window, the user needs to scroll.
What i need is a possibility to, at runtime, know how much space the table actually needs. this is dependent on font-size and contents of the cells (eg.: a richtext-control is slightly larger than a textbox) is there a way to know the actuall space the tableview is going to need?
All question i found here relate to fitting the tableview to the window-size, i need it the other way round, i need to place the SplitPane separator where the table ends
Thanks in advance,
BillDoor

Apache POI (DOCX) XWPFTable asymmetric cell

I want to create a table looks like
this.
but the only way to to this is with an horrible merge of cells.
i try to make two separate table but the top table, follow the cell width of bottom table like this.
There is a way to make an asymmetric table without merge cells?
You don't have to 'merge' cells, but you do have to tell it how many grid columns or rows the cell spans. Picture a grid that has a column that matches every column position, and a row that matches every row position. In your example, you would have a grid with 18 columns and 3 rows. Then for each cell that spans one or more grid column or row, you must have a span attribute that tells how many grid positions are spanned by the cell. The result is the same as merging, and it might even be what you meant by merging, but that is the way the spec reads.

Change orientation of rows and columns of Vaadin Grid

How do I rotate or change orientation of rows and columns in the new Grid widget in Vaadin 7?
My requirements are such that I need to change both. a) header-rows and b) cells content. In this image, there are twelve columns (1-12) and eight rows (A-H), so I've to change the orientation of twelve columns into eight rows and eight rows into twelve columns and all its cell content as well.
It seems that Vaadin 7 does not have such feature implemented in new Grid. However, one can manually rotate the items within container to change orientation.

jtable of characters in Java

I want to create a jtable where each cell should be the size of a single character, without any separation between adjacent characters (i.e adjacent columns). There are no borders between columns so the visualization of a sequence of columns is indistinguible of a jLabel. I have tried many things like making the width of a column as small as possible until each cell is displayed as ... meaning there is no space to print the character. So say I want to have 5 consecutive cells to print the name Alice. What I have achieved so far is a table with this aspect
A l i c e
If I make the column width smaller it shows
... ... ... ... ...
And what I want is:
Alice
Thanks!!
Alvaro
What is the point of doing something like this? This will only work for a single row.
What if you have two rows:
Alice
SWITCH
The minimum width of the column will be controlled by the "W" in the second row, which means you will always have extra space around the "l" in Alice.
Why don't you just use a JPanel with a BoxLayout and then add multiple JLabels to the panel?
Anyway, if you feel you still need a JTable then you can check out the Table Column Adjuster which attempts to fit the text. The basic code would be:
TableColumnAdjuster tca = new TableColumnAdjuster(table, 0);
tca.setColumnHeaderIncluded( false );
tca.adjustColumns();
Also, make sure you use JTable.setIntercellSpacing(...) to set the Dimension to 0.

JTable get the first visible row

I have a Swing JTable. It is large and users can scroll up and down to see the row of data they want to work on. When the user stops scrolling, I want to know the row number of the JTable that is the first visible row that the user can see. I want to use this to scroll back to this position in the table after the user is through additional operations (I know how to do the scrolling piece - its getting the first visible row that has me stumped).
You first need to find out which part of the table is visible and then map the visual coordinates to the underlying row:
JViewport viewport = scrollPane.getViewport();
Point p = viewport.getViewPosition();
int rowIndex = table.rowAtPoint(p);
In addition to that you might want to experiment with offsets to p (such as, e.g., offsetting it by half a row height etc.) depending on the behavior you want to achieve when the first visible row is only partly visible.

Categories

Resources