I dont want to cancel any columns. I just dont want to see column names. So normaly i use the JTable with scroll pane. And i use this code:
scrollPane.setViewportView(table);
But when i use this i cant hide the column names. So i tryed something else and i fine this code:
scrollPane.setColumnHeaderView(table);
This does what i need but when i use this code ,i cant see the all table and there is no scroll bar.
So basicly i want a table with scroll bar and with out columns name. Im sure its easy but i cant find it.
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 need to make table view for large table. There are about 20 columns and it is the problem for me because I do not know how to make some kind of a slider to make possible looking at any column I want.
Now I am not able to see all column because my screen is to small. I would like to have "resaizable" tableview.
I've read how to create a JTable on JScrollPane with data in code, but how can I create a empty table with column header without adding data to it?
I want to add data to it from a form - not from my code.
If you use Netbeans for Development, it will be quite easy to work with JTables.
Using Netbeans, simply select Table from the palate and put it wherever you wish it to display.
Then in properties, you can change column names, add new columns and delete older. Also there only you will get an option of rows to display, simply put that to zero (0).
Voila! Your table is ready with column names and No Rows.
How do I remove unused rows from a JTable?
I first create a table of a fixed size in a JPanel and then fill elements as needed.
Now I don't want unused rows to be displayed in my table. Please help.
I presently get a table with lots of empty rows in bottom, only top 5-6 rows being used, with rest blank. I want to hide them or remove them somehow
Work the other way around. Start with an empty DefaultTableModel. DefaultTableModel supports an addRow() method. So, as you get data to add to the model use:
model.addRow(...);
Don't let the GUI editor determine how you code your GUI. Adding cleanup code to remove rows is a bad design.
DefaultTableModel has a method removeRow which removes a row from the table. Pass the row index which you want to remove from the table.
Now I don't want unused rows to be displayed in my table.
This I am not sure please post an SSCCE to show us what is the flag that says these rows are not used.
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.