package com.test;

import java.util.ArrayList;
import java.util.List; import model.People; import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn; public class LBMShow {static class ListLabelProvider extends LabelProvider {
public String getText(Object element) {
Country country = (Country)element;
return country.getName();
}
public Image getImage(Object element) {
return null;
}
}
static class ContentProvider implements IStructuredContentProvider {
public Object[] getElements(Object inputElement) {
if(inputElement instanceof List){
List list = (List)inputElement;
return list.toArray();
}
return new Object[];
}
public void dispose() {
} @Override
public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
// TODO Auto-generated method stub }
}
static class Country {
private String name; public Country(){
}
public Country(String name){
this.name = name;
}
public String getName() {
return name;
} public void setName(String name) {
this.name = name;
}
public static List getCountryList(){
List list = new ArrayList();
list.add(new Country("中国"));
list.add(new Country("美国"));
list.add(new Country("日本"));
return list;
} }
private static org.eclipse.swt.widgets.List list;
/**
* Launch the application
* @param args
*/
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(, );
shell.setText("SWT Application");
// shell.open(); final ListViewer listViewer = new ListViewer(shell, SWT.BORDER);
list = listViewer.getList();
list.setBounds(, , , ); listViewer.setContentProvider(new ContentProvider());
listViewer.setLabelProvider(new ListLabelProvider());
listViewer.setInput(Country.getCountryList());
//可以直接添加
// listViewer.add(new Country("英国")); //可以添加一条
shell.setLayout(new FillLayout());
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}}

SWT的ListVierer的使用的更多相关文章

  1. eclipse里打开SWT项目找不到source/design的图形UI设计界面

    因为前天重新装了个新版的eclipse, 结果今天打开一个SWT的项目,突然找不到source/design的图形UI设计的两个切换按钮 我把SWT组件重新装了还是找不到.结果后来发现是因为重装ecl ...

  2. eclipse Swt编程—窗口小部件widget

    1.标签Label // 标签(Label类)组件是SWT中最简单的组件.Label类的构造方法和格式如下: // Label(Composite parent,

  3. Eclipse swt开发环境搭建

    原料: eclipse swt.下载链接为: Eclipse 4.6.2 Release Build: 4.6.2 配置说明: Developing SWT applications using Ec ...

  4. 使SWT/JFace支持跨平台

    由于SWT的实现机制,在不同平台下,必须引用不同swt*.jar. 由于这个瓶颈,我们要为不同的平台编译不同的版本.但是这是可以避免的.这将是本文要讨论的内容. 我一共google到了3种soluti ...

  5. 使Docker Container支持运行SWT程序

    1, 下载安装JDK的docker container 我是从这个源下载已经做好的JDK8的container: https://registry.hub.docker.com/u/dockerfil ...

  6. org.eclipse.swt.custom.StyledText.getScrollbarsMode()I

    错误: org.eclipse.swt.custom.StyledText.getScrollbarsMode()I 解决方法: 1 卸载,并手工清除myeclipse全部文件 2 重新安装myecl ...

  7. swt controls里的控件list

    swt controls里的控件list,怎么显示滚动条,并且滚动条自动移动到最下边时,显示最新内容 package com.jokul; import org.eclipse.swt.widgets ...

  8. SWT布局管理器

    一.充满式布局管理器(FillLayout类) FillLayout类是最简单的布局类,它把组件摆放成一行或者一列,并强制组件大小一致.一般,组件的高度与最高的组件一致,宽度与最宽的组件相同.,它里面 ...

  9. SWT组件添加事件的四种方式

    在我们CS日常开发过程中会经常去为组件添加事件,我们常用的为AWT与SWT.SWT的事件模型是和标准的AWT基本一样的.下面将按照事件的四种写法来实现它. 一.匿名内部类的写法 new MouseAd ...

随机推荐

  1. QNX---Interrupt vector numbers(原创!!!)

    Interrupt intr Description 0 A clock that runs at the resolution set by ClockPeriod() 1 Keyboard 2 S ...

  2. js验证日期

    寻寻觅觅,Web开发里,对日期的验证太多了,网上好多是用正则表达式来验证,但是这种验证也只能验证格式,没办法验证有效性,比如平年(2月28天)和闰年(2月29天).平时用得多,以前经常用一次写一次,腻 ...

  3. Thinkphp入门 五 —模型 (49)

    原文:Thinkphp入门 五 -模型 (49) [数据库操作model模型] model  模型  数据库操作 tp框架主要设计模式:MVC C:controller   控制器   shop/Li ...

  4. git 提交ignore files

    1,首先在命令行创建.gitignore文件 $ touch .gitignore 2,在文件.gitignore 加入要忽略的文件入 $ echo *.class > .gitignore 3 ...

  5. android onKeydown

    package wyf.ytl; import android.app.Activity; import android.content.Context; import android.os.Bund ...

  6. mysql READ-COMMITTED 模式下 行锁不会升级到表级锁

    mysql> select sn,id,info from s100 group by id; +-----+------+------+ | sn | id | info | +-----+- ...

  7. hadoop(六) - ZooKeeper安装与配置

    一. ZooKeeper配置 1.使用winscp上传zk安装包 zookeeper-3.4.5.tar.gz 2.解压安装包tar -zxvf zookeeper-3.4.5.tar.gz -C / ...

  8. Repeater

  9. ubuntu12.04安装搜狗输入法配置,安装packettracer字体设置,软件推荐

    装上系统,后的各种配置,各种出错之后的解决. 一.安装搜狗输入法 如果系统以前安装了先卸载: sudo apt-get remove fcitx* #删除配置文件 sudo apt-get purge ...

  10. Android 表格布局<TableLayout>

    表格布局即,tableLayout,表格布局通过行.列的形式来管理UI组件,TablelLayout并不需要明确地声明包含多少行.多少列,而是通过TableRow,以及其他组件来控制表格的行数和列数, ...