Original Post
I'm writing a tile based map editor, and I want to be able to load and remove textures dynamically into a window where they can then be selected. I have one JPanel as the window, which contains another JPanel onto which the textures are loaded (this is the only way I could find to get the layouts to look right). The JPanel which acts as the main window has a scrollbar, but when the JPanel which conatins the textures gets too big the scrollbar doesn't allow me to scroll to them. Most likely I've done something stupid, heres the code which makes the window The class TextureWindow extends JPanel The addTex method loads a texture and adds it to the TextureWindow, this works The JPanel is the main window, and it contains the TextureWindow that has the textures painted onto it I add the whole thing to my gui via the scrollbar (eg mainPanel.add(textureWindow.getScrolly()) Heres a sample screen of what it looks like at the moment: http://img53.imageshack.us/img53/9794/scrollwindow4pn.jpg I'd really appreciate any help you have with this, I've spent the last few days slowly working it out bit by bit but everytime I think I've got it something else goes wrong
public TextureWindow(TileCache t) {
textureButtons = new ArrayList();
textureMap = new HashMap();
tileCache = t;
JPanel panel = new JPanel();
panel.add(this);
panel.setPreferredSize(new Dimension(170, 400));
layout = new GridLayout(0, 4, 5, 5);
setLayout(layout);
addTex("grass1.gif");
scrolly = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}