Hello, I have a borderlayout with a kind of footer at the bottom that displays usefull info about whats going on, im just adding a step by step tutorial widgety thing there, its going to be a JScrollPanel with all different JLabels, and an icon of a tick or cross etc etc.
My problem is with the JScrollPane, when all the panels in it "fit" on the frame, then the scrollpane padds out the height with enough space for a scroll bar (but there isnt one, so its shared out above and below the panels) however, when there isnt enough space and the JScrollPane shows its bar along the bottom, it doesnt eat into this "extra" space, that space is removed, and it eats into the panels ( i think it actually reduces the space the panels have anyway) which i find confusing, i kind of expected it to eat into panel space (like it does normally) but it actually reduces the space
more than it needs to, and adds some needlessly when its not needed!
its kind of hard to explain, but this example shows exactly my problem, it being a footer, i just want it to extend upwards a little when the scroll bar appears instead of messing everything up!:
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame
{
public static void main(String[] args)
{
Test Test = new Test();
Test.setSize(new Dimension(600,500));
Test.setVisible(true);
}
public Test()
{
Container c = this.getContentPane();
c.add(new JLabel("resize me smaller"),BorderLayout.PAGE_START);
JPanel myPanel = new JPanel();
myPanel.setBorder(BorderFactory.createLineBorder(Color.pink));
myPanel.add(new JLabel("A nice label, oh wait its too long! (actually its too short, hence why i am adding this)"));
c.add(new JScrollPane(myPanel, JScrollPane.VERTICAL_SCROLLBAR_NEVER,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.SOUTH);
}
}
curiously its only ever the proper size
just before it needs the horizontal scroll bar
Hope someone can help
Joe