Emulating this SWT shell in Swing

I met with SWT (Eclipse uses the GUI lib) and I want to create the following using Swing.

enter image description here

Previous screenshot taken with SWT

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display, SWT.RESIZE);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

I was wondering how can I emulate this in Swing?

PS The border around this shell is currently the native border for my Windows color scheme, I don’t want to just create a MatteBorder and emulate the color, I would like to use my own border for windows.

+4
source share
3 answers

, : Swing?
: . , Swing. : "" , SWT.

, .

Swing - Java . Swing - - JFrame JDialog - , Java - ( ). Swing. Swing , , . , , , - , .

Swing / L & F (Look and Feel). L & F, , . , L & F - Swing / L & F . L & F, , .

@camickr , (, ) Swing - JDialog/JFrame setUndecorated, true, JWindow, " ". Graphics2D, , , .

- - Swing , . , , .

- SWT Swing ( JavaFX), . - .

EDIT: JDK 7 , , , - Window.Type.UTILITY. .

+3

undecorated JDialog. MatteBorder . LAF.

+3

In Eclipse, I am sure that this is done using org.eclipse.swt.widgets.Shellc SWT.Borderas a style. I can’t figure out how to do this in Swing. You could write one, but it would not have an LAF system.

If this is really important, I would suggest using SWT instead, but this may require rewriting. Otherwise, you could use a SWT shell with Swing components built into it, but in my experience it is very difficult and difficult to debug.

+2
source

All Articles