I want to show all the categories in the database in each line of a JTable i have done that. Now when i click on the each row of JTable i need to show the list of products under it (considered as child of the category) as a drop down not as a drop down list which closes automatically when focus is lost, but it should stay there until i click on minimize icon in the same row. It is just like expanding content. so i can expand all categories individually. The working is similar to JTree but i need it in JTable so that i can show more information on each row in a proper format. Any ideas ?
You need TreeTable functionality. I bet this article will help you.
You will need to have the table model add/remove the subcategory rows when the button on the category is clicked.
You should look at NetBeans Outline. Here's an example that shows how it looks.
Related
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.
I build a JTable in which every cell is a JTable itself. I need to make the cells of the nested (inner) tables clickable so that some additional information will be displayed in a pop-up window on a mouse click.
What is the best way to do this? Should I define every cell as a button?
Thank you in advance.
Instead, create two instances of JTable, master and detail. In a ListSelectionListener added to master, update the model displayed by detail using setModel(), as shown here.
Can I show a PDF in a column of a JTable as link to download!? Is that possible
cause I've searched on Google but can't find anything,
Actually I have table in database named projet(id,nomprojet,date,cout,rapportpdf,pdf). Some projet have a rapport some else no, so i have the project ligne in JTable
Can i have column as link to save rapportpdf on Desktop,
Maybe one approach would be to have the column containing the link to be rendered as a button. See Table Button Column. Then when the user clicks on the button you can display the pdf.
If you want the column to look like a regular hyperlink, then you would need to create a custom renderer so it display like a link and a custom editor to invoke the action when you click on it. MadProgrammer has given you the link to the tutorial which explains renderers and editors in more detail.
I need to create a ComboBox in Java that will have information in a column on the left and a Checkbox in a column on the right so that a user can select multiple items in the ComboBox. This needs to be a ComboBox because there could be 100 items in the list that may need to be checked but they cannot take up much space on the user interface.
Does anyone know how to do this?
Using a JList inside a JScrollPane seems more appropriate for dealing with that many items. It supports the standard CTRL-click to select multiple items.
A multi-selection combobox with 100 items sounds like a UI nightmare.