0

I've already done research on how to make a JInternalFrame show only its content without the borders.

Remove the top title bar: hiding title bar of JInternalFrame? -java

Remove the surrounding borders: how to remove the borders in JInternalFrame?

Everything works smoothly, until I tested my work with Numbus UI, I could get the title bar off, but the surrounding borders are stuck there:

enter image description here

The expected result (which works on other L&Fs) should be:

enter image description here

I assume there's some UI related setting that should solve it (UIDefaults, or comp.putClientProperty()); but I can't figure what it is.

Community
  • 1
  • 1
Mordechai
  • 15,437
  • 2
  • 41
  • 82
  • isn't easier to use undecorated JDialog or JWindow (used for accordion/docking) – mKorbel Jun 30 '16 at 08:57
  • @mKorbel I'm more comfortable with using lightweight components. – Mordechai Jun 30 '16 at 19:53
  • This way i don't have to take care of parent frame move, iconify etc. events. – Mordechai Jun 30 '16 at 21:36
  • Another issue: With Windows Aero when a `JFrame` is deiconified it will show an animation, but making the [previously] hidden window visible [again], will show instantly; this looks awkard. `JInternalFrame` nicely solves it, so my docking goes along with the animation. – Mordechai Jun 30 '16 at 22:18

1 Answers1

0

With trial and error, I found a clean but still incomplete solution.

All I have to do is change the UI of the JInternalFrame to just any other. The new UI will not do any actual rendering, since I removed the title-bar and borders.

This solution is incomplete, DO NOT CALL anywhere in your code:

SwingUtilities.updateComponentTreeUI();

This will cause the internal frame to reset back to the default UI.


EDIT: Finally found a solution to the above reset problem. Just prevent Swing from installing any other than my custom set UI.

Using a subclass of JInternalFrame:

@Override
public void updateUI() {
        LookAndFeel laf = UIManager.getLookAndFeel();
        try {
            UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
        } catch (UnsupportedLookAndFeelException e) {
        }

        super.updateUI();

        try {
            UIManager.setLookAndFeel(laf);
        } catch (UnsupportedLookAndFeelException e) {
        }
    }

This effectively ignores any change to set the UI, but I'm not happy with it. It resetsthe whole Look and Feel, and may cause race conditions which may cause unwanted LaF settings.

I'm still on the search for a solution, setting only this component to Metal.

Mordechai
  • 15,437
  • 2
  • 41
  • 82