wood burning stoves
The moose likes Swing / AWT / SWT and the fly likes viewports and scrollbars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "viewports and scrollbars" Watch "viewports and scrollbars" New topic

viewports and scrollbars

Joe Crew
Ranch Hand

Joined: Apr 02, 2001
Posts: 49
Hi all,
I've created a JTextPane to be a text editor. I added the JTextPane to a JScrollPane so I can scroll the JTextPane when needed. Now I need to enforce some of the limits of the size of the area. The user enters in the height and width of the JTextPane when the start the app:> java texteditor 3.0 4.0
When the user enters in the height and width, and the sizes are smaller than the screen size, I set the scrollpane properties scroll.VERTICAL_SCROLLBAR_NEVER and scroll.HORIZONTAL_SCROLLBAR_NEVER. This of course says there are no scrollbars and works fine. BUT the problem is when the user gets to the bottom of the JTextPane and keeps typing in text, they are allowed to do it. I don't want the user to be able to do this. If the user defines an area as 3" by 4", that is ALL I want them to have and nothing more. I called getScrollableTracksViewportHeight() and it indicates false when I think I need it to be true. But I see no property to setScrollableTracksViewportHeight(). Is there any way to stop the user from being able to type in text when they reach the bottom of a JTextPane?
Also sometimes the user will enter they want their editor to be 10 inches wide and 8 inches in height. Since this is a larger area than the 640x480 screen they are using, my editor automatically put in scrollbars so they can get their full 10x8 required size. Now the horizontal and vertical scrollbars are turned on, no problem. However, when the user reaches their limit of 10 inches wide, I want to force word wrap. It's like I want to define the viewport to have viewable width of say 5 inches, but I want to the total width to be 10 inches only. I want to turn on the scrollbars, but then stop the user at 10 inches. Is there a way to make the entire JTextPane 10 inches wide, but make the viewable part of it 5 inches wide. I hope you all can understand what I am asking here. Please let me know if you need more clarification. Any ideas would be appreciated.
Thanks in advance,
Joe Crew
I agree. Here's the link: http://aspose.com/file-tools
subject: viewports and scrollbars
It's not a secret anymore!