SWT/Jface 如何销毁控件,如何重新生成控件?

本文通过一个完整的SWT/Jface小例子,展示了如何在界面上动态销毁和重新生成控件。主要涉及到Composite、Button的创建、布局以及SelectionListener的使用,详细解释了控件销毁及加载过程中的常见问题。
摘要由CSDN通过智能技术生成

看到网上有人提出这样的问题,他的代码是有些问题的。

不在乎问题有多深,在乎解决方法和点滴的积累。

完整的小例子,大家可以跑跑,点点。

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class DynamSample{
    Display display;
    Shell shell;
    Composite c;
    Composite c1;
    Composite c2;
   
    public DynamSample(){
        display = new Display();
        shell = new Shell(display);
        shell.setText("SWT Sample");
        shell.setLayout( new FillLayout(SWT.VERTICAL));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值