Java – how to add padding using container?
•
Java
I tried to do some padding at the top, but how do I use the container?
JFrame frame = super.screen.getFullScreenWindow();
//Container contentPane = frame.getContentPane();
//JPanel contentPane = new JPanel();
// Make sure the content pane is transparent
if (contentPane instanceof JComponent) {
((JComponent)contentPane).setOpaque(false);
}
else {
// ??
}
contentPane.setBorder(new EmptyBorder(10,10,10) );
//frame.getContentPane().add(contentPane,BorderLayout.CENTER);
yield
[javac] symbol : method setBorder(javax.swing.border.EmptyBorder) [javac] location: class java.awt.Container [javac] contentPane.setBorder(new EmptyBorder(10,10) ); [javac]
Solution
You can override container #getinsets, but you should use swing components
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
