I have a question regarding the border around an undecorated JDialog
using the Metal L&F
.
Look at this picture to see the border that is on this window:
I'm trying to figure out how to either get rid of or change the color of the blue border around the very outside of the JDialog
. I looked at the UI defaults for the Look & Feel
but I wasn't able to come up with any that worked for this.
Does anybody have any ideas on how to get rid of that border?
Thanks!
JDialog is one of the important features of JAVA Swing contributing to interactive desktop-based applications. This is used as a top-level container on which multiple lightweight JAVA swing components can be placed to form a window based application.
How do you put a border in Java? To put a border around a JComponent , you use its setBorder method. You can use the BorderFactory class to create most of the borders that Swing provides. The Border API.
You can't have a border directly on a JWindow or JFrame. You need to put a JPanel with the desired border using the default JWindow/JFrame LayouManager (a BorderLayout). Then the JPanel is extended giving the impression that its borders are the JWindow one.
You need to change the Border
of the root pane:
getRootPane().
setBorder( BorderFactory.createLineBorder(Color.RED) );
If you want to get rid of it you can use
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
To change the look of it from the Java style to the windows style you can use
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With