I have a strange problem with Jasper Reports`iReport:
I have to use Version 3.7.6 and in this version I have to create a dynamic table.
The user is able to define how many columns the table will have and I am calculating this table in the Java - Backend before report initialization and present it to the user. I am not using the table component for this but instead a List of Textfields:
The Java Representation looks like this (very simple):
List<List<String>>
What I am doing is to take a list component that is using subreports to print the contents of the many strings into the report. The List component is printing columns of text fields next to each other (Print Order Horizontal). The subreport consists of nothing but a textfield. This textfield is printed over and over for every column and in the end I have a nice table.
This works very well.
What doesn´t work is when I try to make the text field in the subreport wider.
When it has the standard size of 53px the table looks very well.
When I increase the size I notice that the textfield itself gets wider but the list component still thinks the next column should be 53px. So the text fields overlap each other because the list component refuses to increase its size.
Is there any way to tell the list component to increase its column size when printing horizontal ?
Ok, here is the answer:
The size of the columns for the list component is derived from the columnWidth property of the report. When I change this I can create wider textfields ...
Related
I have an excel template which has the table and charts already setup, just need to add data. There is a collapsible table (using group row) which has a variable number of rows. Beneath this table are two bar charts at the same vertical level.
After filling the table data the two charts are shifted down so when the table is expanded there is no overlapping between the table and charts.
To enable this the chart properties are set to 'Move but dont size with cells'. This works but when any columns or rows are resized the two charts start to move. This can be fixed by using the 'Dont move or size with cells' option.
I have tried the below code but am getting NPE with the following code. The getGraphicFrame() returns null.
dbSheet.getDrawingPatriarch().getCharts().get(0).getGraphicFrame().getAnchor().setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE);
Can someone advise how this can be done? Thanks.
I have to build a page within a java application containing 4 tables (we've chose to use javaFX to use, therefore we're using TableView tables)
There is a problem though. Using multiple tables on 1 pane doesnt seem succesfull. Here you can see the result: http://i.imgur.com/lmPB6Ih.png?1 (I cannot post images yet..)
As you can see it only shows 1 player (a goalkeeper) instead of all the desired players. Whenever i disable all tables but one it shows the desired information.
You can find my code via this link: http://pastebin.com/5AAchCKh
You can't reuse the TableColumn objects.
This fails:
tableTeamField.getColumns().addAll(name,position,age,worth,shooting,...);
tableSelectionField.getColumns().addAll(name,position,age,worth,shooting,...);
When the data is applied to the tables, only the data from the last table is shown in all of them. Basically, you are applying to the sane column different values: only the last one will be visible.
So you need to create different TableColumns for each TableView. This will work:
tableTeamField.getColumns().addAll(name1,position1,age1,worth1,shooting1,...);
tableSelectionField.getColumns().addAll(name2,position2,age2,worth2,shooting2,...);
I have 1 bill which contain table, but my requirement is I want to Print values of rows and columns, with correct margin and on correct position. I am using jswing and jTable. Can anyone help me??
If I were you, I would use not a jTable, but something which intended to print: PDF, *.docx, *.rtf. In this way you have full control on page size and orientation and user may simply edit template in his favorite text processor (f.e., if a new blank has the third column 10 mm smaller).
There are many tools for Java to convert in PDF/doc format. I suppose most of them may insert value in specified field on the template.
I got a question about the NatTable SWT datagrid widget which I want to use to display a huge log file.
As the log file can be several GB in size, I cannot load it in memory entirely. The application should use as little heap space as possible. Thus, my IDataProvider implements its getDataValue method to read a log file line on the fly, with the help of a little caching mechanism and a cache for raw line positions within the file. When opening a file, almost nothing is known about its contents - not even the amount of rows the table will eventually have to display.
This leads to several problems which currently freak me out:
1) I have to estimate the total row count (using average line length) until the file has been scanned entirely and a maximum line count is really known for sure. As soon this is the case my getRowCount method returns the actual, correct number of rows. This seems to freak out the NatTable widget, it loses its current position entirely and jumps to row # 1!
2) When doing something intuitive as double-clicking on the border of a column (to auto-size the column, just like in Excel), my application freezes completely as suddenly ALL rows cells contents is queried using my provider and the whole concept is abused! I did not want anything to trigger a full file read!
Does anybody have some hints for me? The documentation is so little and so bad...
Any hint is greatly appreciated! How can I prevent my application from freezing??
Thanks!
1) Sounds like the selection isn't preserved when you change the row count - a row count change implies a backing data change hence it's probably playing safe and setting the selection to the first row. You could query the selected row before changing the row count and then reset the selection after you change the row count.
2) In order to figure out what the max-width of the column is, the table has to query each value for that cell in every row... Either you have to implement a paging mechanism such that you return something resulting in zero width when the row isn't visible, or you'll probably want to raise a bug against NatTable to request a feature for an auto-resize mode based on only the visible columns!
I am using JTable for displaying the information. After rendering the information if I drag the columns to reorder them, the information is displayed in the same fashion in the session. But when I try to capture the changes by checking the column names by iterating the column names, the sequence is same as the older one. Why is the latest view not available from the API?
As commented by Hovercraft Full Of Eels, the column indices in the view change independently of the column indices in the model. JTable's JavaDoc has this to say about it:
By default, columns may be rearranged in the JTable so that the view's columns appear in a different order to the columns in the model. This does not affect the implementation of the model at all: when the columns are reordered, the JTable maintains the new order of the columns internally and converts its column indices before querying the model.
JTable offers the methods convertColumnIndexToModel() and convertColumnIndexToView() that you can use to translate column numbers from one to the other. You can use these to figure out if (and how) the columns were rearranged.
To be notified of column changes as they happen, use a TableColumnModelListener:
myTable.getColumnModel().addColumnModelListener( new TableColumnModelListener() {
//etc.
} );