• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

scrollpane

 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
horizontal scrollbar is not being displayed. vertical is.
if i make the frame narrower, the text wraps instead of the scrollbar being displayed.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Don't use magic numbers or literals. All classes will have variables defined for use with the methods of the class.

In the case of a BorderLayout you should be using BorderLayout.CENTER.



Don't hardcode the preferred size of a component. The preferred size should be dynamic so the scrollbars can adjust as text is added/removed.

To prevent wrapping check out No Wrap Text Pane.
 
Randall Twede
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Don't hardcode the preferred size of a component. The preferred size should be dynamic so the scrollbars can adjust as text is added/removed.


well, the eventual goal is to work sort of like Word or Open Office. if i change the page setup i want what is displayed on the screen to change. for example if i change paper size the words will wrap in a different place.

i also tried setSize(int, int) but that acts the same way.
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you need to manipulate the preferred size to mimic a paper size then is should be done on the scroll pane, not the text pane.
 
Randall Twede
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i solved this particular problem, but it creates another.
what i did was set the preferred size of the JTextPane(i also gave it a compound border).
added it to a JPanel with a FlowLayout.
and put the JPanel in the JScrollPane.
it now looks and works almost exactly like other word processors except now it is limited to a single page.
but this is a different problem so i am marking this one resolved.
if you would like to see what it looks like now, here is the code:

i notice that Wordpad works differently than Open Office. it changes the width when you change the page setup, but it displays no border and it is one continuous piece of text. it does not display the separate pages. it does not even have a print preview. and this is the windows 8 version. duplicating this seems more promising.
 
No more fooling around. Read this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic