Java布局管理器垂直中心

Java布局管理器垂直中心,第1张

Java布局管理器垂直中心

尝试使用a

GridBagLayout
并添加带有空
GridBagConstrants
对象的面板。
例如:

public static void main(String[] args) {    Jframe frame = new Jframe();    frame.setLayout(new GridBagLayout());    JPanel panel = new JPanel();    panel.add(new JLabel("This is a label"));    panel.setBorder(new LineBorder(Color.BLACK)); // make it easy to see    frame.add(panel, new GridBagConstraints());    frame.setSize(400, 400);    frame.setLocationRelativeTo(null);    frame.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);    frame.setVisible(true);}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5600807.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存