문제

private JButton btnTask = new JButton(); ... TaoGlobal.taskbar.add(btnTask);

How to remove btnTask from JToolBar?

Thanx.

도움이 되었습니까?

해결책

i tried remove, but forgotten for repaint

Well the general code should be:

panel.remove(...);
panel.revalidate();
panel.repaint();

The revalidate() is important because it tells the panel to layout the components. Your code may work if your are removing the last component, but I doubt is will work when you remove the first component.

다른 팁

JToolBar is a Container, and hence removal can be achieved via toolbar.remove(btnTask).

If you look at that javadoc you'll see other useful methods, like remove(index) and removeAll().

Maybe this would be useful for you: http://java.sun.com/docs/books/tutorial/uiswing/components/toolbar.html and http://java.sun.com/j2se/6/docs/api/javax/swing/JToolBar.html

The last link shows you all the methods that you can use.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top