我正在使用Swing创建一个简单的Java GUI,我在标题栏下面有一个白色条,我似乎无法弄清楚如何摆脱它。我感谢任何帮助和提示,因为我已经搜索了所有有类似问题且无法找到任何内容的人。感谢
Java GUI图片:
import javax.swing.*;
import java.awt.*;
public class ja {
public static void main(String[] args) {
JFrame f = new JFrame("jA");
JPanel p = new JPanel();
p.setLayout(new FlowLayout());
f.setSize(400, 600);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel bg = new JLabel(new ImageIcon("brown.jpg"));
bg.setLayout(new FlowLayout());
p.add(bg);
JButton b1 = new JButton("b1");
JButton b2 = new JButton("b2");
JButton b3 = new JButton("b3");
bg.add(b1);
bg.add(b2);
bg.add(b3);
f.add(p);
f.setVisible(true);
}
}
答案 0 :(得分:4)
FlowLayout在父容器的边框和子组件之间使用5像素的间隙。
你可以:
使用FlowLayout
,但将此间隔设置为0像素。阅读FlowLayout API以查看此构造函数参数。
在面板上使用BorderLayout
。