gpt4 book ai didi

java - 设计页面中的 GUI 和 RUN 时的 GUI 不同(Eclipse)

转载 作者:行者123 更新时间:2023-12-01 11:19:23 26 4
gpt4 key购买 nike

我想通过轻松地将组件拖放到 Eclipse 的设计页面来管理 GUI 中组件的位置。这是我在设计页面中看到的 GUI。(右键单击>测试/预览)

Design page

我认为在设计页面中完成重新排列组件后,当我运行应用程序时它看起来会很相似。但是,这个GUI出现了。 After run

不同的外观让我很难调整组件,例如 DAY 2 的宽度、Meduction 的高度、DOB : 和绿色背景。
请告诉我是否有解决此问题的方法。谢谢。

最佳答案

您可以使用 GridLayout,其中每天是一列,主题(诊断、治疗等)是行。然后,您在每个网格单元格(例如第一天和诊断)中创建一个组合,其中包含当天和主题的按钮。

[编辑]我建议的实现是:(SWT.BORDER 标记顶级网格的所有单元格)

    GridLayout topLevelLayout = new GridLayout();
topLevelLayout.numColumns = 4;
parent.setLayout(topLevelLayout);

// head row
Label label = new Label(parent, SWT.BORDER);
label.setText("Activity");
label = new Label(parent, SWT.BORDER);
label.setText("Day 1");
label = new Label(parent, SWT.BORDER);
label.setText("Day 2");
label = new Label(parent, SWT.BORDER);
label.setText("Day 3");

// new row - first cell
label = new Label(parent, SWT.BORDER);
label.setText("Diagnosis");

// Day1 & Diagnosis
GridLayout cellLayout = new GridLayout();
cellLayout.numColumns = 2;
Composite composite = new Composite(parent, SWT.BORDER);
composite.setLayout(cellLayout);
Button button = new Button(composite, SWT.NONE);
button.setText("ECG");
button = new Button(composite, SWT.NONE);
button.setText("Blood Pressure");
button = new Button(composite, SWT.NONE);
button.setText("Vital signs");
// other subjects of diagnosis at day 1...

// Day2 & Diagnosis
composite = new Composite(parent, SWT.BORDER);
// same layout like for day1 & diagnosis
composite.setLayout(cellLayout);
button = new Button(composite, SWT.NONE);
button.setText("ECG");
button = new Button(composite, SWT.NONE);
button.setText("Labs");
button = new Button(composite, SWT.NONE);
button.setText("Blood pressure");
// other subjects of diagnosis at day 2...

// Day3 & Diagnosis
composite = new Composite(parent, SWT.BORDER);
// same layout like for day1 & diagnosis
composite.setLayout(cellLayout);
button = new Button(composite, SWT.NONE);
button.setText("Stress Tests");
button = new Button(composite, SWT.NONE);
button.setText("Labs");
button = new Button(composite, SWT.NONE);
button.setText("Cardiac rhythm");
// other subjects of diagnosis at day 1...

label = new Label(parent, SWT.BORDER);
label.setText("Treatment");

关于java - 设计页面中的 GUI 和 RUN 时的 GUI 不同(Eclipse),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31438504/

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