7

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!

Tamara Koliada
  • 1,200
  • 2
  • 14
  • 31
Mark
  • 418
  • 1
  • 4
  • 13
  • Can my answer in you another question http://stackoverflow.com/a/32752359/5370194 help you? – Jun Sep 24 '15 at 02:34

3 Answers3

11

You need to change the Border of the root pane:

getRootPane().
   setBorder( BorderFactory.createLineBorder(Color.RED) );
Nathan
  • 8,093
  • 8
  • 50
  • 76
camickr
  • 321,443
  • 19
  • 166
  • 288
5

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());
user2526311
  • 1,004
  • 2
  • 10
  • 19
  • This does not do what I want it to. I need the title bar to stay at the top while also having the frame undecorated. The only way to do this is to use the metal look & feel. Setting the window decoration style to none gets rid of the title bar at the top. – Mark Jul 01 '13 at 21:25
2

You can do something like this:

((JPanel)getContentPane()).setBorder(BorderFactory.createLineBorder(Color.BLUE));

enter image description here


You can try to do this in order to change the most outsude border:

getRootPane().setBorder(BorderFactory.createLineBorder(Color.BLUE));

Is this what you want to do?

Maroun
  • 94,125
  • 30
  • 188
  • 241