Hi,
we got a list, that is to big, to be shown at once. That´s why we would like to replace it with a ScrollPane, but the ScrollPane never appears.
Could it be, that it isn´t possible use “this.setLayout(null);” in the construktor, some say, that I have to usw a Layout Manager, is that true?
best regards Phibedy
You’re right you can’t do that. Just don’t call setLayout() at all and it will use the default of a FlowLayout.
By never appears, you mean the scroll bar? update the policies for both horizontal and vertical bars.
thx for for answers
@ Eli Delventhal: If I remove “setLayout” the buttons are centered on the top of the Jpanel ???
If I dont use Layout.set(null), what else should I do, to be able to set buttons on coordinates?
@ ReBirth: Yes I mean the scrollbar.
scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
“scroller” is JScrollPane. You can set it to alwasy show.
Thx, works great ;D
But I got another problem:
public static Icon getIcon(String path) {
Icon icon = null;
icon = new ImageIcon(path);
System.out.println(path);
return icon;
}
At first, I call the method getIcon, after that, I replace the Icon in the directory and call the method again, but it always returns the old Icon not the one that I pasted.
If I don´t call it at first and replace the Icon in the directory and then call the method, it returns the new Icon that I pasted.
best regards Phibedy
You have to call invalidate() on your JFrame. The docs say to call validate() but it never works for me.