I have created a draggable JComponent in Java Swing and want to display it bigger than the JFrame it contains is (it's supposed to be a game map, movable by drag&drop). As i found didn't find a way to display the component alone bigger than the frame, I tried to put it into a JScrollPane and remove the horizontal as well as the vertical scrollbar, but Eclipse says "invalid verticalScrollBarPolicy". Is there a workaround for that or - even better - a way to scale my Draggable JComponent to a size greater than the JFrame without having to add it to extra panels or components?
Thanks in advance!
I tried to put it into a JScrollPane and remove the horizontal as well as the vertical scrollbar, but Eclipse says "invalid verticalScrollBarPolicy".
Make sure you use the proper variables:
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
a way to scale my Draggable JComponent to a size greater than the JFrame
Implement the getPreferredSize()
method to return the appropriate size of your component.