Problems loading data in a JTable - java

I am doing a proyect which is a Database Manager, I have a list at the left side with all the table names I can choose, and in the right side I have the table. The problem is that I am doing something wrong and the JTable shows like this:
Anyone can say me what does that cell values mean?
thanks

You're probably trying to display hash map values in your table. When it goes to load them, it prints the class name and not the values. Same thing happens if you try to display a JLabel or something like that without using a custom table cell renderer.
Its hard to say for sure though. Please post code and we can help you better.

Related

The vertical lines of the table of the last cell on the page are not drawn to the end

Sometimes will it be happens, sometimes not. The construction of the table is too complex. It generated from xml/xslt transformation. Why the table has this form ? Simple I did not find other solution for width inner tables.
You can see trouble in the screenshot, why it happens and how it fix ?
ps. itext and xmlparser v.5.5.11
I am removed the html construction like on the screenshot and made more simple/flat tables with rowspans and colspans. Also I made extends Table class and override end() method. Also I added some better calculation for relative widths of the table and use it new value. Now it's getting a bit better, but not perfect.

How to select whole column on headerClick in Vaadin Table?

I am new to Vaadin, trying to figure out how I can implement column selection on headerClick in Vaadin (the expected result: i click on any column and it becomes selected, just like row).
Seems that it is not so obvious to do. Please, can anyone advice me on that issue? Thank you in advance!
Unfortunately, There is no API to do that in the current Grid and Table components. But as #Morfic mentioned you can configure a HeaderClickListener and then you'll have to save the column clicked as a state somewhere and add a wrapper on top of your datasource collection to get the data of the column in a scalar valued list.
If you need Excel-like features please check out Vaadin Spreadsheet component, it's a paid component but will work for you.

How to make a TableEditor editable when there is nothing in it

I am having a problem with the TableEditor in SWT. I am working from the code in this link:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet88.java
The code works pretty much perfect for what I want except for one thing. If the table has nothing in it, then I can't edit the column that I need to edit.
More specifically, I am using a TableViewer to populate the table with data from elsewhere in my code. If the table is populated with data from that other place then I can edit the value, but for some reason I can't edit the column when there is nothing in it (i.e. if I haven't already taken data from somewhere else). This is a pretty big drawback for me.
Hopefully it's just a matter of changing an attribute of the Editor, but I can't seem to find where/how to change it. Has anyone come across this problem before? Any help on this would be greatly appreciated!
Thanks in advance! :)
Usually you would want to somehow hint the user there's a way to edit this. This can be achieved by adding a synthetic item in a table:

Help with Java program (Swing + database)

Could somebody give me a suggestion on how to simply and effectively make GUI representation of directories which are contained inside the database. Now, getting information using SQL queries is one thing. I can do that.
In fact using separate small examples I can put a file inside the database along with his information and I can get the file out of the database. The thing is I was just doing this without GUI, just to test does it work.
Now I need a GUI of this and I really don't know where to start. DO I use JTable, JList or something third? Also, I think I need an multidimensional array because I have, for example, id of a file, name_of_file and size.
So I need different types to put them in: int, String and int.
Also, I need to obviously hide the id of a file from the user yet keep it at the same time in order to be able to reference it.
How do I hide it in a GUI component?
So, let's say that I have a database table for files with these columns:
id, name, size, binary_of_file.
My real table has a bit more of columns like, id of a parent directory, id of a owner, etc. but for now this is not important.
So, I tell database to give me all info about the file (except it's binary because I just want to list the files):
...
ResultSet rs = statementObject.executeQuery("SELECT id, name, size FROM Files;");
while(rs.next()){
//Where do I store the values in? Which GUI component and how?
...
I guess I need an JPanel that will contain this component that will show my files from the database. What component? Please help!
It sounds like you want to use a JTable, it has a TableModel interface that you can implement to adapt to your resultset.
Also follow the link at the top of the docs. to Creating a Table Model.
Perhaps a combined JList/JTable component would fit this need.
That is a screen shot of the GUI of FileBro.
My idea is that the JTree on the left would represent the 'directories' and table (names) of the DB. The JTable on the right would contain the data of the selected table. Change the Locate Open Edit Print buttons for Create Update Delete and the panel below that to show details of records, and it would be the start of a DB CRUD component.

JList with custom cell renderer vs Jtable

My current application uses a JList and everything is well (the only customization I did was to set the italic font on some of the rows).
Now I want to "upgrade" the user interface and instead of just labels in the List, I want a checkbox and a text field to be able to update the entry.
I started changing the code and adding a custom cell renderer and a custom cell model. My current problem is that the JPanel that the cell renderer is returning is not using the whole width of the container, so several list items are actually shown on the same line.
But now, I am wondering whether I should just change the whole thing to use JTable. I still need to add / remove items in the list though...
Any suggestion which one is better ? and if going with the JList, how should I go about fixing my current problem ?
In my experience using JTable is usually easier as it allows more complex data and functionality out-of-the-box. Usually when I try to do something the JList can't do, I just switch to JTable without a second thought. What you want sounds like something that should be pretty trivial to implement in a table. I suggest you try it out with some mock data to see if you can make it look and work the way you like (especially in case you want it to look like a list).
Try calling setLayoutOrientation(JList.VERTICAL) on your JList. That will restrict JList to a single column.

Categories