gpt4 book ai didi

java - 生成 SQLite 数据作为按钮 (SWT)

转载 作者:行者123 更新时间:2023-12-01 11:36:04 25 4
gpt4 key购买 nike

我需要从 SQLite 数据生成按钮,但尺寸为 100%,如下图所示:

enter image description here

问题是我的主布局是绝对的:(

    TabFolder tabFolder = new TabFolder(shell, SWT.NONE);
//tabFolder.setLayout(new GridLayout());
tabFolder.setBounds(10, 319, 740, 342);

TabItem tbtmPizzas = new TabItem(tabFolder, SWT.NONE);
tbtmPizzas.setText("Members");

Composite composite = new Composite(tabFolder, SWT.NONE);
tbtmPizzas.setControl(composite);


// for this example, I simply repeated this button with different bounds
Button button = new Button(composite, SWT.NONE);
button.setText("Michael");
button.setBounds(10, 10, 137, 52);

最佳答案

这应该可以帮助您开始工作:

public static void main(String[] args)
{
Display display = new Display();
Shell shell = new Shell();
shell.setLayout(new FillLayout());

TabFolder folder = new TabFolder(shell, SWT.NONE);

TabItem item = new TabItem(folder, SWT.NONE);
item.setText("Item");

Composite content = new Composite(folder, SWT.NONE);
content.setLayout(new GridLayout(3, true));

String[] myData = {"This", "is", "some", "random", "data"};

for (String data : myData)
{
Button button = new Button(content, SWT.PUSH);
button.setText(data);
button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
}

item.setControl(content);

shell.pack();
shell.open();

while (!shell.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
display.dispose();
}

看起来像这样:

enter image description here

关于java - 生成 SQLite 数据作为按钮 (SWT),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29979924/

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