4

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

Firnaz
  • 553
  • 7
  • 31
  • 1
    [JInternalFrame](http://docs.oracle.com/javase/7/docs/api/javax/swing/JInternalFrame.html) has `setMaximizable()`, `setIconifiable()` and `setClosable()`. – kiheru Oct 03 '13 at 11:03
  • 1
    Is that a [`JInternalFrame`](http://docs.oracle.com/javase/7/docs/api/javax/swing/JInternalFrame.html)? If so, use `setIconifiable(false)` and `setMaximizable(false)`. – Gabriel Negut Oct 03 '13 at 11:03

3 Answers3

3

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.

Alan
  • 3,307
  • 1
  • 19
  • 22
2
setMaximizable(false), 
setMinimizabel(false), 
setClosable(false)
0

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]);
        }
    }
}
Rahul
  • 44,383
  • 11
  • 84
  • 103