JFrame margin

Discuss here any questions about the WebLaF library.
Bugs can be posted directly to GitHub issues tracker.

JFrame margin

Postby lorenzo » Mon Mar 23, 2015 5:47 pm

Hello,
when I create and show an unmaximized decorated JFrame, it gets diplayed with a transparent margin of about 25 px around the actual frame. As an example, the frame in the following code is shown at some distance from the top-left corner of the display, even though I set its bounds to start at (0,0).

Code: Select all
import java.awt.EventQueue;
import java.awt.Rectangle;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.UIManager;

public class TesterGUI extends JFrame {

   public static void main(String[] args) {
      EventQueue.invokeLater(new Runnable() {
         public void run() {
            try {
               UIManager.setLookAndFeel("com.alee.laf.WebLookAndFeel");
               JFrame.setDefaultLookAndFeelDecorated(true);
               new TesterGUI().setVisible(true);;
            } catch (Exception e) {
               e.printStackTrace();
            }
         }
      });
   }
   
   public TesterGUI() throws Exception {
      setTitle("Test");
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      getContentPane().add(new JLabel("Hello world!"));
      setBounds(new Rectangle(0,0,300,300));
      pack();
   }
}


How can I disable this effect, so that the actual frame stretches along the whole bounds that I set?
Thank you in advance,

Lorenzo
lorenzo
 
Posts: 3
Joined: Mon Mar 23, 2015 5:27 pm

Re: JFrame margin

Postby lorenzo » Mon Mar 23, 2015 6:51 pm

Sorry, I figured it out:
Code: Select all
if (getRootPane().getUI() instanceof WebRootPaneUI)
         ((WebRootPaneUI)getRootPane().getUI()).setShadeWidth(0);
lorenzo
 
Posts: 3
Joined: Mon Mar 23, 2015 5:27 pm

Re: JFrame margin

Postby mgarin » Tue Mar 24, 2015 12:33 am

Yep, this is basically what you can do as an option.
Unfortunately there is no other convenient way to draw window shade, so it has to take some space.
User avatar
mgarin
Site Admin
 
Posts: 223
Joined: Mon Apr 16, 2012 1:01 pm
Location: Russia, Saint-Petersburg


Return to Questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron