문제

In JDesktopPane, i have included a JPanel with tree view listing some devices. I dont need those resizable and close options in that panel show in the figure. (Maximize, Minimize, Close). I tried many ways, but not able to hide those functions. Any ideas.

enter image description here

도움이 되었습니까?

해결책

The component you actually need to be dealing with is the JInternalFrame which contains the JPanel you mentioned above. This should have a number of functions to enable/disable the actions associated with the min/max/close buttons (E.g.: setMaximizable(bool enabled) ).

I do not know if this would hide the buttons or merely disable them, so you may have to use some variant of the trick mentioned by R.J - manually removing the buttons.

다른 팁

setMaximizable(false), 
setMinimizabel(false), 
setClosable(false)

You can remove the minimize, maximize and close buttons from a swing component like this:-

public void removeMinMaxClose(Component comp) {
    if (comp instanceof AbstractButton) {
        comp.getParent().remove(comp);
    }
    if (comp instanceof Container) {
        Component[] comps = ((Container) comp).getComponents();
        for (int x = 0, y = comps.length; x < y; x++) {
            removeMinMaxClose(comps[x]);
        }
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top