I have created a grid which contains some columns and a button on the far right. Using this button, the user can show / hide selected grid columns. The problem is that the rightmost column name is partially hidden by this button.
As can be seen in the following picture. Is there a method to make it so that either:
The button is moved slightly to the right, even outside the border of the grid
The rightmost column name is moved to not be underneath the button
If possible, I would like to implement the first solution, as the column names can be reorganized by the user and the solution would have to be dynamic.
Related
I'm trying to create a table where the first row contains 1 button, and the other rows contain multiple columns. Example picture:
How could I make this?
I've attempted the following: add button to table but that only allows you to add a button like this:
I've looked at other stackOverflow posts, but those answers contain dead links, which are no help to me.
This is relatively easy by placing the button outside the table. Here is how to go about it:
Create a panel with a BorderLayout. Add the table (to a scroll pane) to the CENTER of the border layout. Add the button to the PAGE_START of the border layout. Job done.
I have a very basic problem with jtable. I have a jtable that has multiple columns with one of column having a button. When i click on that button a panel drops, and asks to select an option from given options. When i select that option, value replaces in one of the column.
Now, i want when i select multiple rows, and do the same thing as above, it should replace that column in all the selected rows.
Problem: Currently, my table is losing selection when i am clicking the button in one of the column in jtable after multiple row selection.
I searched google and stackoverflow a lot, but could not find anything meaningful. Anyhelp or sample code is appreciated.
Thanks
If I understood your problem correctly then the solution is fairly simple.
First of all the issue probably occurs because once you click on the button java sets a new focus on the button and therefore clearing the focus on the other rows. That won´t be a problem in a single selection because you still click into the selected row, however doing that with multiple rows in one go won´t work that way.
To solve this you need to save your previous selections in something like an ArrayList and after the whole option thing you can apply the changes to every element in the ArrayList and reload the table.
A cleaner and more intuitive approach though would be to place the button outside of the JTable.
I am working on an application that uses a TableView and has a Table Menu Button to add or remove columns from the list.
Since I wanted my column headers to have tooltips, I had no choice but to create a label and use it in the following manner in :
// Some code here
TableColumn col;
// some code here
col.setGraphic(header_title);
The problem with this is that when the program runs, the table menu button shows a list of empty text:
On the other hand when I do:
// Some code here
TableColumn col;
// some code here
col.setText(rs.getString("column_title"));
col.setGraphic(header_title);
I can see the text on the column menu, but the actual titles are appended to the graphic:
I have tried to look for a way to perform a setContentDisplay(GRAPHIC_ONLY), but this does not seem to exist for TableColumn, and I am not sure how to access the header node in order to set this setting.
Any help would be greatly appreciated.
Just forget about the inbuilt table menu button. It's absolutely minimal and not worth mentioning. If you e. g. want to click away 10 columns you have to click on the button, hide the column, click on the button, hide the column, etc. In other words: It closes as soon as you press a menu item.
You can't even extend it with e. g. a hide all and a show all button. And it's buggy: When the last column gets hidden, the menu button vanishes as well, so you have to restart your application if you want to see anything in your table again.
Just create your own table menu. There are 2 examples on this gist:
example which uses a lookup, i. e. works without reflection
example which uses reflection
Then you can adapt whatever header you want and whatever menu items you want.
Is there a way to make, let say first 3 out of 7, columns fixed in Cell table. I want to be able to see always first three columns and have horizontal scroll on others.
You will have to create a custom widget that consists of a ScrollPanel, which includes two CellTable widgets set side by side. The right table should be wrapped in a FlowPanel with overflow-x property set to AUTO (overflow-y should remain at HIDDEN).
You can use the same DataProvider for both tables to synchronize all changes. Be careful with the SelectionModel though, if you need it. I would limit selection to the first column of checkboxes and disable selection by clicking on a row.
Make sure that your widget fits into its space, or you may end up with two horizontal scrollbars - one for the ScrollPanel and one for the right table. Finally, remember to set sizes on both tables so that they have the same height.
What i want to do is to create a menu with 3 choices, the two first are left and right and the last is Go to Page. But i want 2 lines, one with left and right, and below the Go to Page (Not everyone in the same line. How can i do this ?
There is no way to control the size of specific items in the options menu. You can however experiment with changing the order of them.
When working with 3 items, the first item will span the entire top row, and the last 2 items will be split in the bottom row.
If order is very important, create a linearlayout at the bottom of your screen with buttons with the size and order your want. Then override the onCreateOptionsMenu function and toggle the Visible attribute of the linearlayout containing your menu.