gpt4 book ai didi

java - java中的边框

转载 作者:行者123 更新时间:2023-11-29 08:18:49 25 4
gpt4 key购买 nike

我想将单个标题边框设置为一组文本字段,我该如何在 java/swing 中执行此操作。

我试过下面的代码,但面板内的文本字段正在压缩

// Create panel and add some components to it.
JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT));

pnl.add(new JLabel("Name"));
pnl.add(new JTextField());

// Add titled border to panel, which will therefore surround
// all child components placed on the panel.
pnl.setBorder(BorderFactory.createTitledBorder("It's Friday!"));

最佳答案

这是一个使用 Swing 的例子:

// Create panel and add some components to it.
JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT));

pnl.add(new JLabel("Name"));
pnl.add(new JTextField());

// Add titled border to panel, which will therefore surround
// all child components placed on the panel.
pnl.setBorder(BorderFactory.createTitledBorder("It's Friday!"));

关于java - java中的边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2070001/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com