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.
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.
Joined: Nov 02, 2000
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) );
Joined: Jan 09, 2001
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.