Search code examples
javaswingjinternalframe

JInternalFrame decoration


Internal frame Decoration

I would like to know, is there any way to set my internal frame decoration as normal window decoration instead look like the image inside the link above? Thank you very much.


Solution

  • I'd say not. The internal frame decorations are supplied by the look & feel, where as the JFrame & JDialog's get there decorations from the OS.

    Having said that, there are some Look & Feels that supply custom decorations themselves (to the top level windows).

    Metal for instance has the following UI properties:

    RootPane.colorChooserDialogBorder = javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder@182d9c06
    RootPane.errorDialogBorder = javax.swing.plaf.metal.MetalBorders$ErrorDialogBorder@63b9240e
    RootPane.fileChooserDialogBorder = javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder@687b6889
    RootPane.informationDialogBorder = javax.swing.plaf.metal.MetalBorders$DialogBorder@7e0c2ff5
    RootPane.plainDialogBorder = javax.swing.plaf.metal.MetalBorders$DialogBorder@5a5e5a50
    RootPane.questionDialogBorder = javax.swing.plaf.metal.MetalBorders$QuestionDialogBorder@95c083
    RootPane.warningDialogBorder = javax.swing.plaf.metal.MetalBorders$WarningDialogBorder@61b383e9
    

    Using these you should be able to swap the internal frame's border.

    But under the default system look and feel for windows RootPane only supplies the following properties...

    RootPane.ancestorInputMap = javax.swing.plaf.InputMapUIResource@4ba33d48
    RootPane.defaultButtonWindowKeyBindings = [Ljava.lang.Object;@1cc7b00c
    RootPaneUI = com.sun.java.swing.plaf.windows.WindowsRootPaneUI
    

    Now...there might be away to get this to work using JNI, but I suspect because Swing uses a lightweight painting process, it would only end in a mess.