Background information:
I am implementing a visual diagram editor, which consists of
- different complex elements (re-sizable, with title bar, sub-elements) and
- different simple elements (not re-sizable, no title bar, no sub-elements).
All elements are draggable.
I am using JInternalFrame (for complex elements) along with JPanel
(for simple elements) to represent elements of a schematic diagram. There is a container (either a JDesktopPane or a JLayeredPane), which contain
all these elements.
I have several problems with this concept:
Case 1 – The container is a JDesktopPane:
- JInternalFrames are always above other elements.
- Clicking other elements don’t “deactivate” previously active JInternalFrame
Case 2 – The container is a JLayeredPane:
- After clicking some elements inside a JInternalFrame, it stays
“activated” forever.
Case 3 – JInternalFrame used for everything, but without decoration for simple elements:
- My custom border (which is needed when I manually remove
JInternalFrame’s title bar) is every time replaced by current LAF border, after
activating/deactivating the JInternalFrame.
I don’t get the whole concepts behind activating JInternalFrames anyway.
If I could make a JInternalFrame not activable at all, I could
choose Case 2 any would be happy.
Please advice me, what would be an simple and straightforward solution to given problems.
NOTE: Selection of components and activation of JInternalFrame
seem to be different things.
I might misunderstand your problem. Have you tried to look at the setSelected() method of JIF? It seems there are support for method override and vetoable activation events.
Edit: Maybe we have some terminological misunderstanding as the javadoc states:
Edit 2: Now I re-read your 2nd case. I would say each JIF has its own separated focus/selection environment. You could create a method which traverses all your JIFs and deselects anything in it unless its the component you wanted to be selected.