• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BorderLayout JLabel size problem

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using a BorderLayout for two components: a JLabel at "EAST" and a JList at WEST. The JLabel was constructed with an ImageIcon. The problem is that the resulting JLabel is very wide. on Windows 98 SE clients, the contentPane gives 50% space to the "East" component and 50% space to the "West" component.
On a Windows Millenium Edition client machine, the content pane uses almost all the space for "east" component, (the JLabel with the image) and only 1% to the JList. Just the very thin edge of the JList is displayed.
I have looked for methods in the various objects whereby I might restrict the size or display of a given component but so far, have not found anything to help out with this problem.
Any suggestions?
i.e. I need to keep my <applet> tags width parameter setting the way it is which restricts the overall size of the applet display.
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi JOhn,
Have you thought about using multi-lined label to avoid the long label? You can do it with the following HTML stuff:
label.setText( "< html >First line< p >Second line< /html >" );
Regards,
Manfred.
 
John Davis
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Manfred,
Thanks for the tip, its good to know about these things.
However, my label doesn't even have any text. The constructor for the JLabel is:
final JLabel photoLabel = new JLabel();
The JLabel content comes from:
photoLabel.setIcon(new ImageIcon(photoURL) );
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi JOhn,
Just so we understand the same thing here. Your layout:
list | icon
This means that you have nothing in the center. The way a BorderLayout works is:
Fit North component by asking about height and stretching width.
Fit South component by asking about height and stretching width.
Fit West component by asking about width and stretching height.
Fit East component by asking about width and stretching height.
Center gets any leftover room.
Use the program below, replacing the image file with yours to see how the layout works.

On my systems, I get the list against the left edge and wide enough for its contents, and the image on the right wide enough for its contents, with a large red center area.
Regards,
Manfred.
 
reply
    Bookmark Topic Watch Topic
  • New Topic