How to set JtextArea to keep fixed no of rows? - java

How can i keep no of rows constant in text area.
I need to create a console window for my application.
If rows exceeds predefined no of rows first rows must get disposed.
As if first written row will be destroyed first when i append anything which exceeds no of rows set.
One more thing , i need to keep vertical scroll bar. That means no of rows must not be the whatever rows are visible when text area it opened.
For example : - no of visible rows on view port are 30.
It should keep 120 rows information, which will can be seen with the help of scroll bar.

Sounds like what you want to do is create your own Document implementation. See Document.

The Message Console shows one way.

Related

GridBagLayout: changes alignment after adding checkbox

I have two classes which creates two different dialog box. Both the classes have same code, except one has additional lines of code, which creates a checkbox
first Class, with Checkbox
Second Class, without Checkbox
There is slight alignment difference in "save" button. How can I fix this.
Is there a particular reason you're using fixed row and column sizes? One of the great features of GridBagLayout is its ability to center/align and fill. This also tends to make things look better on different screen sizes, different fonts, etc.
To answer your specific question, my guess is that the checkbox is taller than the row you're putting it into, pushing the next row down.
When I debug GBL, I often set row/column background colors to different things and print out (or view in a debugger) sizes of the things I'm trying to fit into the container.
I had to adjust the row height as the checkbox was taller than the row and was pushing the third row downward( Thanks to Ingrid Biery). so I changed the 2nd row height from 25 to 30 and it worked.

SmartGWT ListGrid large dataset problems

I have a SmartGWT ListGrid with 16 fields each containing Strings. The grid is attached to a data source provided via REST. I am facing issues though when the amount of data in the datasource is large.
When dealing with very small numbers there are no problems, even when dealing with 200,000 records there are still no problems. However when it comes to much larger datasets, for example one I tried earlier had 2.6 million records the grid only displays the first 850,000 (approximatley) records then refuses to page any further. Even more oddly, when my datasource has about 20 million records the grid only displays the first 20 then refuses to page at all.
Strangley I can see the data coming back in my RPC response using the isc.showConsole(); and can see that it is returning the correct data, in fact even when it returns 64 valid records it only displays the first 20. The totalRecords is properly returned as 20 million but it just will not page.
My grid is setup as follows
ListGrid grid = new ListGrid();
DataSource ds = Application.getMyDataSource();
grid.setCriteria(new Criteria("someid", 627263));
grid.setDataSource(ds);
grid.setAutoFetchData(true);
My Datasource is setup correctly as it works perfectly on smaller datasets, each field is created as a DataSourceTextField.
The server side accepts the incomming request, looks for the someid coming in, checks the _startRow, _endRow parameters finds those rows (I'm not using a database for this) and manually sets the startRow, endRow and totalRow fields.
When I inspect the data coming back the data is correct yet the grid refuses to display it correctly.
What am I missing? Is there a maximum size for list grids? From what I've seen they should handle millions of records, yet mine seems to fail completely.
EDIT
Upon further inspection it seems it is an error with the way SmartGWT handles the sizing of the scrollbar. I have no idea how to fix this at the moment.
When scrolling to the bottom of the table on what should be a 2.3 million row table, the last row displayed is 894,785. This is well short of the number of rows expected.
All data coming back from the data source is correct at this point. Interestingly clicking on the last row and scrolling with the down arrow on keyboard works fine, this to me re-enforces the point that it is a scroll bar issue.
In order for progressive loading to work, grid has to be tricked in a way to indicate there's more data.
Since we don't want to draw 1000 empty records (actual totalRows) when only 150 is fetched with data, we need to set totalRows = 160 or something to generate a close enough scroll thumb size, as well as allow scrolling below 150 records, to trigger progressive loading of next page.
Check:
Paging and total dataset length in ResultSet
http://forums.smartclient.com/showthread.php?t=516
http://forums.smartclient.com/showthread.php?t=2750
When you drag the scroll thumb too fast towards the bottom, grid might 'intelligently' skip loading intermediate rows.
ListGrid.showAllRecords might be what you need to check based on http://forums.smartclient.com/showthread.php?t=23638.
That last thread also indicates issues with browsers and large datasets.

Placing Objects in a certain layout(For game)

So this what i want to do, i have a scene right now, and i want to create "Pages" on the scene with level icons i create.
Now i want to be able to set the amount of levels i want to have. for example,
int levels = 100;
Then i want it to be able to create "Pages". What i mean by pages is it will be space between each of the level sections.
I would like to be able to set the rows and columns like this:
int rowsPerPage = 5;
int colPerPage = 10;
Each of my level icons are 80x80 width and height.
So with this information i would like be able to place the level icons on rows per page bases and column per page basis.
Each level icon should have some padding space between them.
Once it reaches its makes row and column per page on the first page i would like to create a second page making some space between the first set of rows and columns. Once it reaches is max icon per row it should then start a new row on that page
Right now im not sure where to begin. The reason i am using this is because i have set up gesture detection so my users can scroll from "Page" to "Page" to select a level.
I know this isnt a place to just ask for code, but im stuck on my current project because of this and it would be really great to get some assistance.
Thank you guys in advance.
Thank you.
No one will write your code for you if you haven't even attempted it yourself...
This is from google... It may not be exactly what you want. However, it is a start :)
http://www.andengine.org/forums/tutorials/menu-scroll-example-t5740.html

GWT Celltable fixed columns

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.

set scroll bar position in JTable/SWT Table

I would like to ask question that is not directly related to any technology but it’s a logic level question. Forgive me if I am wrong.
I am trying to solve this issue in Java side.
We have a list view (may be JTable or SWT Table). We are displaying records from a table in to that list. The table may have millions of records. And the table size is keeps increasing. As the table size is huge and it keeps increasing we are keeping a cache of 3000 records and displaying the cache in the table. So at a single point only 3000 records will be there in the view. At this time, the scroll bar of the view (JTable or SWT Table) shall be set based on the cache only (in this case 3000 records).
And based on the user events like, PgUP, PgDwn, DownKey, UpKey, Mouse Scroll etc we are refreshing the cache so that the view will be refreshed.
But we need to give users an actual feel that the scroll position based on the records in the table. I think it is not possible as the scroll position is set by the OS based on the number records in the display. Can somebody can assist me with an alternate method. If I am not explained my question correctly, I will explain this in details. Please help.
Usually a scrollbar is set at the top of the list, or at the bottom, depending on if the property "AutoScroll" is set to true or false.
I believe there IS a method where you can set the scrollbar at a specific point, but last time I tried using it, it was kinda clunky.
It sounds like you're trying to make the scroll bar do two things at once, and that can be confusing. You could use a separate control to the do the paging. A row of buttons in a JToolBar looks nice, but a JComboBox will take up less room. There's some good answers about this here.

Categories

Resources