Kaushik Balasubramanain
Kaushik Balasubramanain

Reputation: 1258

Leave a Gap between Border and JFrame

I have a JPanel which is set to BorderLayout. I have added 2 JPanels inside this panel, one south and one center. In the center panel, i added a LowerBevelBorder. I am finding i am not able to leave a gap between the Main frame and the border. How do i do that? This is my panel1.setBorder(BorderFactory.createLoweredBevelBorder());

Upvotes: 2

Views: 3330

Answers (1)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285405

Use a compound border which allows you to nest borders without having to create containers just for this purpose. The API can help you set this up. e.g.,

int eb = 10;
panel1.setBorder(BorderFactory.createCompoundBorder(
    BorderFactory.createEmptyBorder(eb, eb, eb, eb), // outer border
    BorderFactory.createLoweredBevelBorder()));      // inner border

Note code not tested.

Note also that this depends on what panel1 is. If it's not the BorderLayout main JPanel, then your best bet is to set the Border of the BorderLayout-using JPanel to be an EmptyBorder.

Upvotes: 5

Related Questions