Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undecorated JDialog border

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:

enter image description here

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!

like image 794
Mark Avatar asked Jul 01 '13 21:07

Mark


People also ask

Where is JDialog used in an application?

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 set a frame border in Java?

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.

How do I add a border to a JFrame?

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.


2 Answers

You need to change the Border of the root pane:

getRootPane().
   setBorder( BorderFactory.createLineBorder(Color.RED) );
like image 87
camickr Avatar answered Nov 04 '22 12:11

camickr


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());
like image 31
user2526311 Avatar answered Nov 04 '22 13:11

user2526311