• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Manually sizing JScrollPane  RSS feed

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

I am working on a GUI, and in it is a JScrollPane. In the ScrollPane is a JPanel that holds multiple JTextPanes. That way there will be multiple viewable TextPanes in one scrollpane. However I want the scrollpane to not show all of the Panel that it contains; I want it to be a smaller size. I have tried putting the scrollpane in another panel, which goes in my applet, but the panel resizes because it is in a layout manager. How would I be able to make the size of the viewport set to what I want it to be?

Thanks for any help,

Andrew
 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not going to like my answer. By using an appropriate layout manager, or a combination of layout managers, possibly in conjunction with EmptyBorders.

To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
 
Andrew Cho
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok thanks Darryl,
Heres an example of what I'm talking about


Thanks for your help,
Andrew
 
Sheriff
Posts: 21504
96
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An applet is never an SSCCE, as I need an HTML page to be able to display it.
 
Rancher
Posts: 2958
20
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

An applet is never an SSCCE, as I need an HTML page to be able to display it.



I also agree with this.

I'm not sure how IDE's work, but when using the command line there is a simple solution provided the poster adds the following as the first line to the posted source code:



Now from the command line you can do the following:

javac TestApplet2.java
appletviewer TestApplet2.java

However, I agree the safest way to post code is to post an application as many people will not go to the trouble of testing applets.

Anyway, back to the question. As mentioned by Darryl its a matter of understanding how layout managers work. You set the preferred size of the wrong component:



 
Andrew Cho
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah sorry about posting an applet instead of an application. While i was making the application however, I put in the code from Rob, and I got it to work.

Thanks guys,
Andrew
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!