本文介绍了如何设置JFrame的插图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以设置JFrame的插图?我尝试过

Is there a way to set the insets of a JFrame?I tried

frame.getContentPane().getInsets().set(10, 10, 10, 10);

frame.getInsets().set(10, 10, 10, 10);

但它们似乎都不起作用.

but none of them seem to work.

推荐答案

JPanel contentPanel = new JPanel();

Border padding = BorderFactory.createEmptyBorder(10, 10, 10, 10);

contentPanel.setBorder(padding);

yourFrame.setContentPane(contentPanel);

因此,基本上,contentPanel是框架的主要容器.

So basically, contentPanel is the main container of your frame.

这篇关于如何设置JFrame的插图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 16:46
查看更多