??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲日本乱码卡2卡3卡新区,亚洲Av无码国产情品久久,亚洲国产美女精品久久http://www.tkk7.com/fortune/category/7609.htmlTHE WAY TO THE MASTER...zh-cnWed, 28 Feb 2007 07:43:28 GMTWed, 28 Feb 2007 07:43:28 GMT60java 与文ghttp://www.tkk7.com/fortune/archive/2006/03/14/35251.htmlfortunefortuneTue, 14 Mar 2006 08:13:00 GMThttp://www.tkk7.com/fortune/archive/2006/03/14/35251.htmlhttp://www.tkk7.com/fortune/comments/35251.htmlhttp://www.tkk7.com/fortune/archive/2006/03/14/35251.html#Feedback1http://www.tkk7.com/fortune/comments/commentRss/35251.htmlhttp://www.tkk7.com/fortune/services/trackbacks/35251.html在java中可以读Zpd字节的对象称为“输入流”,而能向其写入一pd字节的对象称为“输出流”。这2U对象分别是用抽象类InputStream和OutputStream来实现的。对于Unicode格式保存的信息(每个字符都用?个字节来存储Q,有专门的cd理,q些cL从抽象类Reader和Writerl承而来?BR>
java以这4个抽象类为基Q衍生出一pd具体的类Q几乎可以完成所有的输入/输出q程?BR>
InputStreamcL供了一个抽象方法:abstract    int    readQ)
d一个字节ƈ它q回Q由此类衍生出来的其它具体类都会覆盖q个ҎQ以提供有用的功能?BR>cM的,OutputStreamcd义了抽象Ҏabstract    int    writeQint  bQ?BR>
完成的d操作后应C要用closeQ)Ҏ其关闭。关闭输出流的同时也会刷新输出流使用的缓冲区Q在~冲Z{待l合成一个较大的数据包的临时存储的字W,都会通过|络传送出厅R特别是Q加入没有关闭一个文Ӟ最后一个字节报可能永远都不会投递出厅R?BR>
InputStream和OutputStreamcd许我们读取单独的字节和字节数l,它们不对字符串及数字q行d。DataInputStream和DataOutputStream允许Ҏ有基本javacdq行d?BR>对于Unicode文本Q需使用Reader和Writer衍生出的c,它提供的基本Ҏ和InputStream和OutputStreamcMQabstract    int    readQ)
         abstract    int    writeQint  bQ?BR>readҎq回的要么是个Unicode字符Q?-65535间的一个整敎ͼ要么?1Q已抵达文g末尾Q?BR>无论是readq是writeҎ都会dU程的运行,直到字节被实际读出或写入为止。利用availableҎQ我们可以检查目前能够读取的字节数?BR>
int   byteAvailable     =    System.in.availableQ)Q?BR>if   QbyteAvailable  ?0Q?
{byte[]   data  =  new byte [byteAvailable]Q?BR>   System.in.readQdataQ;
}

FileInputStream ?FileOutputStream 使我们能磁盘文件和输入及输出关联v来?BR>FileInputStream fin = new FileInputStream("employee.dat");
也可?BR>File f = new File("employee.dat");
FileInputStream fin = new FileInputStream(f);

与InputStream and OutputStream cMQ?它也仅支持字节的读写操作,只能从fin对象中读取字节和字节数组Qbyte b = (byte) fin.read();

FileOutputStreamQString nameQ新Z个name指定的文件输出流Q该Ҏ会自动删除同名的M现存文gQ!Q?BR>
文本?BR>
二进制的输入输出速度很快效率很高但是人无法看懂这U格式。java使用的是Unicode字符

File, File(Input/Output)Stream, RandomAccessFile是处理本地文件的c?BR>
Data(Input/Output)Stream是一个过滤流的子c?借此可以d各种基本数据, 在文件和|络中经怋?? readByte, writeBoolean{?

Buffered(Input/Output)Stream的作用是在数据送到目的之前先缓?辑ֈ一定数量时再送到目的,用已减少dơ数.

Piped(Input/Output)Stream适合与一个处理的输出作ؓ另一个处理的输入的情?BR>


  Q要想以二进制格式写入数据,使用DataOutputStreamQ要想以文本格式写入数据Q用PrintWriter
二进制读入用DataInputStreamQ可d文本格式的数据Javaq未提供q样的类。唯一用来处理文本输入的是BufferedReadercd包含了一个方法readLine?BR>




fortune 2006-03-14 16:13 发表评论
]]>
SWT Basic Controls -- Texthttp://www.tkk7.com/fortune/archive/2006/03/13/35074.htmlfortunefortuneMon, 13 Mar 2006 08:30:00 GMThttp://www.tkk7.com/fortune/archive/2006/03/13/35074.htmlhttp://www.tkk7.com/fortune/comments/35074.htmlhttp://www.tkk7.com/fortune/archive/2006/03/13/35074.html#Feedback1http://www.tkk7.com/fortune/comments/commentRss/35074.htmlhttp://www.tkk7.com/fortune/services/trackbacks/35074.htmlText Hierarchy


graphics/07inf07.gif

Text Styles

Style

Description

SWT.SINGLE

Allow a single line to be edited  单行

SWT.MULTI

Allow multiple lines to be edited  多行

SWT.READ_ONLY

Make the control noneditable     不可~辑

SWT.WRAP

Allow strings to wrap instead of scrolling 自动换行

SWT.LEFT

Left-align the contents of the control    左对?/P>

SWT.CENTER

Center-align the contents of the control  中间寚w

SWT.RIGHT

Right-align the contents of the control   叛_?/P>



Text Events

Event

     Description

SWT.DefaultSelection

     Default selection occurred (user pressed <Enter>)

SWT.Modify

     Text has changed in the control  控g中的文本内容发生了改?/P>

SWT.Verify

     Text is to be validated in the control  文本内容需要验?/P>


text控g支持"plain"textQ这意味着text中的字符必须都是同样的字体和颜色Q如果需?更多的功能就使用org.eclipse.swt.custom.StyledTextQeclipse为用户定制的Q注意StyledText不是本地QnativeQ控?BR>
一共有2U类型的text控gQ单行的和多行的


Single-Line and Multiline Text Controls

SWT.SINGLE

Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
text.setText("Texan");


 SWT.MULTI
与单行的text不同它可以含有scroll bar  Q通过讄SWT.H_SCROLL or SWT.V_SCROLL Q?BR>
int style =
    SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
Text text = new Text(parent, style);


String Operations

setText(String string)

getText()

getText(int start, int end)  获取text的文本内容从start到end
getCharCount()  q回字符的数?BR>

Passwords and the Echo Character

int style = SWT.SINGLE | SWT.BORDER | SWT.PASSWORD;

Text text = new Text(parent, style);

text.setText("fred54"); //在text上不会显C?fred54"Q而是以echo字符代替

注意在不同的q_上echo字符是不同的Q我们常见的密码echo字符是?”,可以自己讄echo字符

setEchoChar(char echo)如果讄的字W是'\0'则不再隐藏字W,当前的字W被昄

getEchoChar() q回setEchoChar函数讄的echoQ如果未讄则返?\0'Q如果用了SWT.PASSWORD 则返回的字符不确?BR>通常来说自己讄echo字符是不明智的,因ؓq是q_look and feel的一部分?BR>

 Lines and Line Height

getLineCount() q回行数
getLineHeight() q回每行高度Q像素)该g字符的高度ƈ不相同,因ؓ行间有空?BR>
public static void main(String[] args) {

    Display display = new Display();

    Shell shell = new Shell(display);

    Text text = new Text(shell, SWT.H_SCROLL|SWT.V_SCROLL);

    int rows = 5, columns = 10;

    GC gc = new GC(text);

    FontMetrics fm = gc.getFontMetrics();

    gc.dispose();

    int height = rows * text.getLineHeight();

    int width = columns * fm.getAverageCharWidth();

    text.setSize(text.computeSize (width, height));

    shell.pack();

    shell.open();

    while (!shell.isDisposed()) {

        if (!display.readAndDispatch()) display.sleep();

    }

    display.dispose();

  }


 Line Delimiters
行定义符?BR>










fortune 2006-03-13 16:30 发表评论
]]>
SWT Basic Controls -- Buttonhttp://www.tkk7.com/fortune/archive/2006/03/13/35062.htmlfortunefortuneMon, 13 Mar 2006 08:11:00 GMThttp://www.tkk7.com/fortune/archive/2006/03/13/35062.htmlhttp://www.tkk7.com/fortune/comments/35062.htmlhttp://www.tkk7.com/fortune/archive/2006/03/13/35062.html#Feedback0http://www.tkk7.com/fortune/comments/commentRss/35062.htmlhttp://www.tkk7.com/fortune/services/trackbacks/35062.htmlButton Hierarchy

graphics/07inf05.gif


Button Styles

SWT.ARROW

Draw an arrow instead of text or an image button的Ş状显CZؓ头

SWT.CHECK

Create a check button

SWT.PUSH

Create a push button

SWT.RADIO

Create a radio button

SWT.TOGGLE

Create a toggle button

SWT.FLAT

Draw the button with a flat look  使button看v来是flat?/P>

SWT.UP

Draw an up arrow        头向上Qarrow时才有效Q?/P>

SWT.DOWN

Draw a down arrow      头向下Qarrow时有效)

SWT.LEFT

Left-align the button (or draw a left arrow)文字向左寚w或箭头向左(arrowӞ

SWT.RIGHT

Right-align the button (or draw a right arrow)文字向右寚w或箭头向叻IarrowӞ

SWT.CENTER

Center align the button  button上的文字中间寚w



Button Events

SWT.Selection

   The button was selected      button被选中事g

 
button是活动控Ӟ当用LM们会发送事?BR>
Text and Images

button支持昄文本和图像,它的使用大体上与label相同Q但是它不支持SWT.WARP和换行符Q既button上的文本字符只能是一行,而且它能只能昄文本或图像中的一U不能同旉昄

setText(String string)
getText()
setImage(Image image)
getImage()

管button支持囄昄但是通常不这么用,一般用Tool bars 来代?BR>
Alignment

setAlignment(int alignment)   讄寚w方式  SWT.LEFT, SWT.CENTER, or SWT.RIGHT中的一U?BR>getAlignment()                     q回寚w方式

通常很少使用q?个函敎ͼ因ؓ默认的对齐一般都很好

Push Buttons

SWT.PUSHQ它们通常用来产生一个动作,与其它类型的button不同push  button不会?SWT.Selection 事g中保持选中或未选中状态。它们通常被认为是未选中?BR>Button button = new Button(parent, SWT.PUSH);
button.setText("Ok");

Check Buttons

SWT.CHECK。它与push  button不同的是它会保持一个选中的状态,用户使用鼠标或者键盘选择q个状?BR>
你可以用方法设|check  button的选中状?BR>setSelection(boolean selection)  讄该button为选中状态check, radio, or toggle button时有?BR>getSelection() q回该button是否被选中

Button button = new Button(parent, SWT.CHECK);
button.setText("Overwrite when typing");
button.setSelection(true);

注意Q调?nbsp;setSelection() 不会产生一个SWT.Selection 事gQSWT的编E新手经怼对这个感到很困惑?BR>
当用LM个checkQ就会触发一个动作事件。你可以讄动作监听?BR>
ActionListener listener =....
bold.addActionListener(listener);
italic.addActionListener(listener);
监听器的actionPerformedҎ查询bold和italic两个check  button的状态ƈ且相应地把面板中的字体设为普通、加_、倾斜以及后两U组合?BR>public void actionPerformed(ActionEvent event)
{
   int mode = 0;
   if (bold.isSelected()) mode +=Font.BOLD;
   if (italic.isSelected()) mode += Font.ITALIC;
   label.setFont(new Font("Serif", mode, FONTSIZE));
}

Radio Buttons

SWT.RADIO 与check  button一样它们会保持一个布状态,但是当多个radio  button都是属于一个parentӞ一ơ只能有一个被选中
Button button1 = new Button(parent, SWT.RADIO);
button1.setText("Don't wrap");
button1.setSelection(true);
Button button2 = new Button(parent, SWT.RADIO);
button2.setText("Wrap to window");
Button button3 = new Button(parent, SWT.RADIO);
button3.setText("Wrap to ruler");


Toggle Buttons

SWT.TOGGLE    toggle  button是当被选中时一直停留在pressed状态下的push  button


Arrow Buttons
SWT.ARROW
Button button = new Button(parent, SWT.ARROW);
button.setAlignment(SWT.RIGHT);

arrow  button主要用于昄“上一”或“下一”时使用

Button Events

SWT.Selection (SelectionEvent)

button.addListener(SWT.Selection, new Listener() {

    public void handleEvent(Event event) {

        System.out.println("Ok Pressed");

}

});

Using SWT.Selection with Radio Buttons

SWT.Selection 很少与radio一起用,与check button一P它们通常使用于对话框Q对于绝大多数的操作pȝQ程序不会生一个action直到dialog被关?BR>令h意外的是当用户在一lradio button中选择一个radioӞ2个SWT.Selection 事g被发送:前一个被选中的radio button接收C?SWT.Selection 事g通知它的选中状态改为falseQ新的被选中的radio button接收C?SWT.Selection事g通知它已被选中

Listener listener = new Listener() {
    public void handleEvent(Event event) {
        Button button = (Button) event.widget;
        if (!button.getSelection()) return;
        System.out.println(
         "Arriving " + button.getText());
    }
};
Button land = new Button(shell, SWT.RADIO);
land.setText("By Land");
land.addListener(SWT.Selection, listener);
Button sea = new Button(shell, SWT.RADIO);
sea.setText("By Sea");
sea.addListener(SWT.Selection, listener);
sea.setSelection(true);








fortune 2006-03-13 16:11 发表评论
]]>
SWT Basic Controls -- Labelhttp://www.tkk7.com/fortune/archive/2006/03/13/35026.htmlfortunefortuneMon, 13 Mar 2006 06:24:00 GMThttp://www.tkk7.com/fortune/archive/2006/03/13/35026.htmlhttp://www.tkk7.com/fortune/comments/35026.htmlhttp://www.tkk7.com/fortune/archive/2006/03/13/35026.html#Feedback0http://www.tkk7.com/fortune/comments/commentRss/35026.htmlhttp://www.tkk7.com/fortune/services/trackbacks/35026.html Label Hierarchy

graphics/07inf02.gif

Label Styles

SWT.WRAP                自动调整label中的内容行以适应可见区域的大(既label内容自动换行Q?BR>SWT.LEFT                   label内容左对?BR>SWT.CENTER             label内容中间寚w
SWT.RIGHT                label内容叛_?BR>SWT.SEPARATOR      M个分割符
SWT.HORIZONTAL   使分割符水^Q仅在画分割W时使用Q?BR>SWT.VERTICAL         使分割符垂直Q仅在画分割W时使用Q?BR>SWT.SHADOW_IN     使分割符有“SHADOW_IN ”的效果Q仅在画分割W时使用Q?BR>SWT.SHADOW_OUT  使分割符有“SHADOW_OUT”的效果 Q仅在画分割W时使用Q?/P>

Label Events (none)

label是一个静态组件可用来攄文本Q图像,分隔W,一个静态的控g既不含有焦点QfocusQ也不参与tab traversalQ鼠标点M产生M影响

Label label = new Label(parent, SWT.NONE);
label.setText("User Name:");

Text and Images

label允许你设|文本或囑փ在上面如果你什么都不设|则label昄的是background color

setText(String string)    讄label昄文本内容string
getText()                      q回label的文本内?BR>setImage(Image image) 讄label昄的图?BR>getImage()                    q回囑փ

注意Q文本和囑փ只能讄其中的一U,若你惛_label上文本和囑փ都加入,你要使用CLabel








fortune 2006-03-13 14:24 发表评论
]]>
关于clone函数http://www.tkk7.com/fortune/archive/2006/03/13/34986.htmlfortunefortuneMon, 13 Mar 2006 02:34:00 GMThttp://www.tkk7.com/fortune/archive/2006/03/13/34986.htmlhttp://www.tkk7.com/fortune/comments/34986.htmlhttp://www.tkk7.com/fortune/archive/2006/03/13/34986.html#Feedback0http://www.tkk7.com/fortune/comments/commentRss/34986.htmlhttp://www.tkk7.com/fortune/services/trackbacks/34986.html要想使用clone函数首先必须实现接口CloneableQ重新定义clone函数为公有的Qƈ调用super.cloneQ)

class Employee implements Cloneable
{
   public Object clone()
      {
         try
            {
                  return super.clone();
            }
            catch (CloneNotSupportedException e) { return null; }
}
..........
}

使用clone函数是要注意一个浅拯和深拯的问题,默认的拷贝操作都是浅拯——没有克隆对象内部引用的其他对象Q所以要实现深拷贝,需要克隆可变实例字D需重徏立cloneҎ

具体知识可参考core java章节--接口和内部类

fortune 2006-03-13 10:34 发表评论
]]>
SWT Layout - FormLayouthttp://www.tkk7.com/fortune/archive/2006/03/09/34463.htmlfortunefortuneThu, 09 Mar 2006 05:51:00 GMThttp://www.tkk7.com/fortune/archive/2006/03/09/34463.htmlhttp://www.tkk7.com/fortune/comments/34463.htmlhttp://www.tkk7.com/fortune/archive/2006/03/09/34463.html#Feedback0http://www.tkk7.com/fortune/comments/commentRss/34463.htmlhttp://www.tkk7.com/fortune/services/trackbacks/34463.htmlMarginWidth, MarginHeight
页边宽度和高度Q与GridLayout中相?BR>
Display display = new Display ();
Shell shell = new Shell (display);
FormLayout layout= new FormLayout ();
layout.marginHeight = 5;
layout.marginWidth = 5;
shell.setLayout (layout);

FormData
指定了每个widget在FormLayout中怎样排列

很典型地Q一?/SPAN>FormData实例在一个合成器内被帮定于各个子control。因为对于一个表格布局其核心思想是指明各个?/SPAN>control的相对位|,所以不同于其他的布局Q给予各个子control提供讄?/SPAN>data非常重要。如果一个给定的control没有一?/SPAN>FormData实例来描q它Q则它会被默认ؓ攄于合成器的左上角Q而这U位|是你极期望的。宽度和高度属性用象素来指明一?/SPAN>control的方位。顶部、底部和左右属性较为重要,且都持有一?/SPAN>FormAttachment实例。这?/SPAN>attachment描绘了在一个合成器?/SPAN>control间的关系?BR>注意Q如果多个widgets未指明Q何attachmentQ他们都会在~省值指定的位置重叠h

使用FormAttachment指明关系

 

理解FormAttachment是用表格布局的一个非帔R要的斚w。就像早先提LQ每一?/SPAN>FormAttachment实例描述了一?/SPAN>control某一面的位置。你可以以两U不同的方式使用FormAttachment?/SPAN>

 

首先Q你可以使用父合成器的百分比来指明一?/SPAN>FormAttachment。例如,如果一个左侧的FormData被设定ؓ50%Q则control的右辚w会处于合成器的水q中央。同样地Q如果设定顶端边界ؓ75%?/SPAN>control会处于合成器自上而下的四分之三处。表6.3ȝ了用以指定百分比?/SPAN>FormAttachment构造器。以癑ֈ比的形式来指?/SPAN>FormAttachment是有用的Q但你不能L应用q种Ҏ。将你的所?/SPAN>control通用癑ֈ比方式作说明和用l对的象素点来指明他们没有太大的区别Q因为当合成器被重定大小Ӟ如何快速定位每一个元素会变得相当困难Q因?/SPAN>controlq不会如你所愿地在该位置上。用表格式布局的关键点是在于确?/SPAN>control间的怺位置Q而这正是FormAttachement所允许的?BR>

Z癑ֈ?/SPAN>FormAttachment构造器

构造器

描述

FormAttachment(int numerator)

假定分母?/SPAN>100Q意味着参数卌视ؓ一个百分比?/SPAN>

仅在SWT 3.0中可用?/SPAN>

FormAttachment(int numerator, int offset)

假定分母?/SPAN>100Q意味着参数卌视ؓ一个百分比?/SPAN>

偏移?/SPAN>offset是在癑ֈ比定位的基础上再行偏Uȝ象素数目?/SPAN>

FormAttachment(int numerator, int denominator, int offset)

假定分母?/SPAN>denominatorQ意味着参数卌视ؓ一个百分比?/SPAN>

偏移?/SPAN>offset是在癑ֈ比定位的基础上再行偏Uȝ象素数目?/SPAN>


FormAttachmentW二pd的构造器是基于对其他control的参照。它们常常将一?/SPAN>control的边~与盔R?/SPAN>control相对定位。通过?/SPAN>button1讑֮FormData叛_性到一个基?/SPAN>button2而构建的FormAttachmentQ你可以?/SPAN>button1应该L定位?/SPAN>button2的右侧。将你的l大多数control依照q种方式d位有多种好处。你的布局代码目的变得很Ҏ理解Q在q去的象素或是百分壁基础上的那个control与哪?/SPAN>control盔R的表达方式被取代后,变得很明显了,例如Q名?/SPAN>foo?/SPAN>control应该位于工具条之下;其次Q表格式布局也容易维持你的这U布局意图。无论合成器的尺寸如何大变化,它L能够l持其正的相对位置?BR>

FormData formData = new FormData();
formData.top = new FormAttachment(30,70,10);
button1.setLayoutData(formData);
指的是加入该Composite含有70个单元则该button1的顶部位于Composite从上?0个单元再?0个像素的位移


作ؓ指定相对位置之用?/SPAN>FormAttachment构造器有若q种形式Q具体ȝ如下
Q?/SPAN>

构造器

描述

FormAttachment(Control control)

现有小部gML?/SPAN>control一侧的参数?/SPAN>

FormAttachment(Control control, int offset)

现有小部gML?/SPAN>control一侧的参数Qƈ且有offset数量象素的偏U量?/SPAN>

FormAttachment(Control control, int offset, int alignment)

排列alignment必须?/SPAN> SWT.TOP?/SPAN> SWT.BOTTOM?/SPAN>SWT.LEFT?/SPAN> SWT.RIGHT?/SPAN>SWT.CENTER其中之一?/SPAN>

现有小部gML?/SPAN>control一侧的参数Qƈ且有offset数量象素的偏U量?/SPAN>


注意Q对于top和left的offset应该为正敎ͼ对于bottom和right的offset应该?BR>

相对于另一?widgetq行定位

FormData formData = new FormData();
formData.top = new FormAttachment(20,0);
button1.setLayoutData(formData); 
FormData formData2 = new FormData();
formData2.top = new FormAttachment(button1,10);
button2.setLayoutData(formData2);

上面q段代码的意思就是首先将button1剙攄在距Composite剙20%处,然后button2的顶部放|在button1?0个像素位UdQ当H口大小改变Ӟbutton1会一直随着改变q处?0%处,而button2也一直在button1下方10个像素处

formData2.top = new FormAttachment(button1,0,SWT.TOP); 指定button2的顶部和button1相同也处?0%?BR>

FormData formData = new FormData(50,50);
formData.top = new FormAttachment(20,0);
button1.setLayoutData(formData);
FormData formData2 = new FormData();
FormData2.left = new FormAttachment(button1,5);
formData2.top = new FormAttachment(button1,0,SWT.TOP);
button2.setLayoutData(formData2);

上面的代码说明button1大小?0*50像素Q距顶?0%Qbutton2的左边与button1距离?个像素,剙与button1相同
若将上面改ؓformData.top = new FormAttachment(button1,0,SWT.CENTER);则button2在button1左边5个像素处且在垂直方向上处于button1的中?BR>
注意Q千万不要定义重复的attachmentQ如定义button2的左边连着button1的右边,又定义button1的右边连着button2的左边,q样会导致未定义错误Q所以一定要定你的weidget没有重复限制他们的位|,仅定?需要限制位|的widget



参考:http://www.eclipse.org/articles/Understanding%20Layouts/Understanding%20Layouts.htm




















fortune 2006-03-09 13:51 发表评论
]]>
SWT Layout - RowLayouthttp://www.tkk7.com/fortune/archive/2006/03/08/34328.htmlfortunefortuneWed, 08 Mar 2006 11:01:00 GMThttp://www.tkk7.com/fortune/archive/2006/03/08/34328.htmlhttp://www.tkk7.com/fortune/comments/34328.htmlhttp://www.tkk7.com/fortune/archive/2006/03/08/34328.html#Feedback0http://www.tkk7.com/fortune/comments/commentRss/34328.htmlhttp://www.tkk7.com/fortune/services/trackbacks/34328.html
Type?BR>指定按行或列排列  如: new RowLayout(SWT.HORIZONTAL);defaultQhorizontal

Wrap?BR>指定该行或列I间不放下当前控g时是否自动换行;defaultQtrue

Pack?BR>指定Layout中的widgets是否采用它们的自然大,如果pack为false则所有widget强制为相同大defaultQtrue

Justify?BR>true表明Layout中的所有widgets每行都从左到叛_^均距d开defaultQfalse

MarginLeft, MarginTop, MarginRight, MarginBottom and Spacing

前面4个是指定于边框距ȝQspacing指定widget之间的间?/H4>

   RowLayout rowLayout = new RowLayout();

   rowLayout.wrap = false;

   rowLayout.pack = false;

   rowLayout.justify = true;

   rowLayout.type = SWT.VERTICAL;

   rowLayout.marginLeft = 5;

   rowLayout.marginTop = 5;

   rowLayout.marginRight = 5;

   rowLayout.marginBottom = 5;

   rowLayout.spacing = 0;

   shell.setLayout(rowLayout)

 

下面的代码用RowData对象来改变button的大?/SPAN>

import org.eclipse.swt.*;

import org.eclipse.swt.widgets.*;

import org.eclipse.swt.layout.*;

 

public class RowDataExample {

 

   public static void main(String[] args) {

       Display display = new Display();

       Shell shell = new Shell(display);

       shell.setLayout(new RowLayout());

       Button button1 = new Button(shell, SWT.PUSH);

       button1.setText("Button 1");

       button1.setLayoutData(new RowData(50, 40));

       Button button2 = new Button(shell, SWT.PUSH);

       button2.setText("Button 2");

       button2.setLayoutData(new RowData(50, 30));

       Button button3 = new Button(shell, SWT.PUSH);

       button3.setText("Button 3");

       button3.setLayoutData(new RowData(50, 20));

       shell.pack();

       shell.open();

       while (!shell.isDisposed()) {

          if (!display.readAndDispatch()) display.sleep();

       }

   }

}

 

参考:http://www.eclipse.org/articles/Understanding%20Layouts/Understanding%20Layouts.htm



fortune 2006-03-08 19:01 发表评论
]]>
SWT Layout-FillLayouthttp://www.tkk7.com/fortune/archive/2006/03/08/34303.htmlfortunefortuneWed, 08 Mar 2006 09:17:00 GMThttp://www.tkk7.com/fortune/archive/2006/03/08/34303.htmlhttp://www.tkk7.com/fortune/comments/34303.htmlhttp://www.tkk7.com/fortune/archive/2006/03/08/34303.html#Feedback0http://www.tkk7.com/fortune/comments/commentRss/34303.htmlhttp://www.tkk7.com/fortune/services/trackbacks/34303.html下图是SWT中的一些术语说?BR>



SWT共有4ULayoutQFillLayoutQRowLayoutQGridLayoutQFormLayout

FillLayout
FillLayout是最单的LayoutQ它widgets攑֜单行或单列上Q强制它们h相同的大,也就是说每个widget的高度和宽度都和其中最高或最宽的那个widget一?BR>marginHeight Q与上下Ҏ的距)Q?A >marginWidth Q与左右Ҏ的距)Qsince3.0Q?BR>

spacingQ指定widgets之间的间隔距(since3.0Q?BR>
public class Snippet172 {
 public static void main (String [] args) {
  Display display = new Display ();
  Shell shell = new Shell (display);
  FillLayout fillLayout = new FillLayout ();
  fillLayout.type = SWT.VERTICAL;
  fillLayout.marginHeight = 20;
  fillLayout.marginWidth = 15;
  fillLayout.spacing = 10;
  shell.setLayout (fillLayout);

  Button button0 = new Button (shell, SWT.PUSH);
  button0.setText ("button0");

  Button button1 = new Button (shell, SWT.PUSH);
  button1.setText ("button1");

  Button button2 = new Button (shell, SWT.PUSH);
  button2.setText ("button2");

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

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

参考:http://www.eclipse.org/articles/Understanding%20Layouts/Understanding%20Layouts.htm



fortune 2006-03-08 17:17 发表评论
]]>
SWT Layout--GridLayouthttp://www.tkk7.com/fortune/archive/2006/03/08/34267.htmlfortunefortuneWed, 08 Mar 2006 06:34:00 GMThttp://www.tkk7.com/fortune/archive/2006/03/08/34267.htmlhttp://www.tkk7.com/fortune/comments/34267.htmlhttp://www.tkk7.com/fortune/archive/2006/03/08/34267.html#Feedback0http://www.tkk7.com/fortune/comments/commentRss/34267.htmlhttp://www.tkk7.com/fortune/services/trackbacks/34267.htmlNumColumns(列数)是GridLayout中最重要的域Q它Composite划分成NumColumns列,往上添加控件时依次从左臛_排列当控件数多于列数时换?/FONT>

Display display = new Display();
   Shell shell = new Shell(display);
   GridLayout gridLayout = new GridLayout();
   gridLayout.numColumns = 3;
   shell.setLayout(gridLayout);
   new Button(shell, SWT.PUSH).setText("B1");
   new Button(shell, SWT.PUSH).setText("Wide Button 2");
   new Button(shell, SWT.PUSH).setText("Button 3");
   new Button(shell, SWT.PUSH).setText("B4");
   new Button(shell, SWT.PUSH).setText("Button 5");
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
   }
MakeColumnsEqualWidth
使每列的宽度相同Q默认gؓfalse

MarginWidth, MarginHeight, HorizontalSpacing, and VerticalSpacing
边宽度Q页辚w度,水^间隔Q垂直间?BR>
GridData
GridData是控制小部g布局的对象,例如
   GridData gridData = new GridData();
   gridData.horizontalAlignment = GridData.FILL;//horizontalAlignment是指水^寚w方式
//Q有GEGININGQENDQCENTREQFILLQ?BR>
   gridData.grabExcessHorizontalSpace = true;
   button1.setLayoutData(gridData);
注意Q每个在GridLayout中的widget都有一个自qGridDataQ如果没有ؓ它设|则pȝ会给他一个默认的GridDataQ?BR>

HorizontalAlignment and VerticalAlignment

每个alignment域指定控件在它的格子单元内水q?垂直怎样寚wQ他们是下面4个g的一?/SPAN>

          ·      BEGINNINGQ左寚wQ?/SPAN>·      CENTERQ中间对齐)·      END叛_?/SPAN>·      FILL充满格子

~省gؓhorizontalAlignment is BEGINNING Q?verticalAlignment is CENTER

HorizontalIndent

允许你将widget向右Ud指定的像素位

GridData gridData = new GridData();

gridData.horizontalIndent = 4;

button.setLayoutData(gridData);

HorizontalSpan and VerticalSpan

span域可使widget占据多个grid单元Q仅在horizontalAlignment为Fill时有效)

GridData gridData = new GridData();

gridData.horizontalAlignment = GridData.FILL;

gridData.horizontalSpan = 2;

button5.setLayoutData(gridData);

 也可以它在垂直方向占用多个grid单元Q仅在verticalAlignment为Fill时有效)

注意Q假如所有的widgetsd只有x行则你想让它在垂直方向占有x+1个grid单元是没有作用的

GrabExcessHorizontalSpace and GrabExcessVerticalSpace

当用h变窗口大时Q?A name=_Toc509864545>GrabExcessHorizontalSpace 和GrabExcessVerticalSpace指定该控件是否填充增大的I间

WidthHint and HeightHint

指定widget的大(如果horizontalAlignment或verticalAlignment为FILL的时候就没有意义了)

GridData gridData = new GridData();

       gridData.widthHint = 70;

       gridData.heightHint = 40;

       button5.setLayoutData(gridData);

注:最好不要对大小编?/SPAN>

 

Style 帔R

描述

FILL_HORIZONTAL

扩展单元来水q_充满MIZI间?/SPAN>

?/SPAN>HORIZONTAL_ALIGN_FILL

FILL_VERTICAL

扩展单元来垂直地充满MIZI间?/SPAN>

?/SPAN>VERTICAL_ALIGN_FILL

FILL_BOTH

水^和垂直地扩展单元I间?/SPAN>

{h?/SPAN>FILL_HORIZONTAL | FILL_VERTICAL.

HORIZONTAL_ALIGN_BEGINNING

居左排列单元内容?/SPAN>

HORIZONTAL_ALIGN_END

居右排列单元内容?/SPAN>

HORIZONTAL_ALIGN_CENTER

水^居中排列单元内容?/SPAN>

HORIZONTAL_ALIGN_FILL

扩展单元I间充满单元内水q空余空间?/SPAN>

VERTICAL_ALIGN_BEGINNING

排列单元内容于单元顶部?/SPAN>

VERTICAL_ALIGN_END

排列单元内容于单元底部?/SPAN>

VERTICAL_ALIGN_CENTER

排列单元内容于垂直中央?/SPAN>

VERTICAL_ALIGN_FILL

扩展单元I间充满单元内垂直空余空间?/SPAN>

 

 

Table 6.2 GridData 寸属?/SPAN>

属?/SPAN>

描述

默认?/SPAN>

widthHint

列的最宽度?/SPAN>SWT.DEFAULT指明了没有最宽度?/SPAN>

SWT.DEFAULT

heightHint

行的最高度?/SPAN>SWT.DEFAULT指明了没有最高度?/SPAN>

SWT.DEFAULT

horizontalIndent

单元左侧辚w?/SPAN>control之间的象素间隙数量?/SPAN>

0

horizontalSpan

单元所覆盖的网格的列的数目?/SPAN>

1

verticalSpan

单元所覆盖的网格的行的数目?/SPAN>

1

 

参考:http://www.eclipse.org/articles/Understanding%20Layouts/Understanding%20Layouts.htm



fortune 2006-03-08 14:34 发表评论
]]>
关于Resource的Disposal http://www.tkk7.com/fortune/archive/2006/02/23/32108.htmlfortunefortuneThu, 23 Feb 2006 07:40:00 GMThttp://www.tkk7.com/fortune/archive/2006/02/23/32108.htmlhttp://www.tkk7.com/fortune/comments/32108.htmlhttp://www.tkk7.com/fortune/archive/2006/02/23/32108.html#Feedback0http://www.tkk7.com/fortune/comments/commentRss/32108.htmlhttp://www.tkk7.com/fortune/services/trackbacks/32108.html
1、如果你用构造函数创Zwidget或者graphic对象Q当你不需要时你必L动地dispose掉它;
2、如果你不是使用构造函数得到这个widget或者graphic对象Q由于不是你allocate的,你不需要手动来dispose掉它;
3、如果你传递一个widget或者graphic对象的referencel另一个对象,那么你必d心,不要在它仍在被用中dispose掉它;
4、当你close掉一个shellQ那么这个shell及其子widget会被递归dispose掉的Q虽然你不需再dispose掉那些widgetQ但是你必须free掉与q些widget相关的图像资?
5、如果在一个widget的生命期中创Zgraphic对象Q可以通过注册一个dispose listener来freeq个graphic对象Q不q数据对象如Rectangle和Point没有使用操作pȝ资源Q不用手动dispose(它们也没有disposeҎ).



fortune 2006-02-23 15:40 发表评论
]]>JAVA开发者应该去?0几个英文|站 Q{Q?/title><link>http://www.tkk7.com/fortune/archive/2006/02/23/32062.html</link><dc:creator>fortune</dc:creator><author>fortune</author><pubDate>Thu, 23 Feb 2006 01:51:00 GMT</pubDate><guid>http://www.tkk7.com/fortune/archive/2006/02/23/32062.html</guid><wfw:comment>http://www.tkk7.com/fortune/comments/32062.html</wfw:comment><comments>http://www.tkk7.com/fortune/archive/2006/02/23/32062.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/fortune/comments/commentRss/32062.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/fortune/services/trackbacks/32062.html</trackback:ping><description><![CDATA[<P>[http://www.javaalmanac.com] - Java开发者年鉴一书的在线版本. 要想快速查到某UJava技巧的用法及示例代? q是一个不错的d. <BR>[http://www.onjava.com] - O'Reilly的Java|站. 每周都有新文? <BR>[http://java.sun.com] - 官方的Java开发者网?- 每周都有新文章发? <BR>[http://www.developer.com/java] - 由Gamelan.com l护的Java技术文章网? <BR>[http://www.java.net] - Sun公司l护的一个JavaC֌|站. <BR>[http://www.builder.com] - Cnet的Builder.com|站 - 所有的技术文? 以JavaZ. <BR>[http://www.ibm.com/developerworks/java] - IBM的Developerworks技术网? q是其中的Java技术主? <BR>[http://www.javaworld.com] - 最早的一个Java站点. 每周更新Java技术文? <BR>[http://www.devx.com/java] - DevXl护的一个Java技术文章网? <BR>[http://www.fawcette.com/javapro] - JavaPro在线杂志|站. <BR>[http://www.sys-con.com/java] - Java Developers Journal的在U杂志网? <BR>[http://www.javadesktop.org] - 位于Java.net的一个Java桌面技术社区网? <BR>[http://www.theserverside.com] - q是一个讨论所有Java服务器端技术的|站. <BR>[http://www.jars.com] - 提供Java评论服务. 包括各种framework和应用程? <BR>[http://www.jguru.com] - 一个非常棒的采用Q&A形式的Java技术资源社? <BR>[http://www.javaranch.com] - 一个论坛,得到Java问题{案的地方,初学者的好去处?<BR>[http://www.ibiblio.org/javafaq/javafaq.html] - comp.lang.java的FAQ站点 - 攉了来自comp.lang.java新闻l的问题和答案的分类目录. <BR>http://java.sun.com/docs/books/tutorial/] - 来自SUN公司的官方Java指南 - 对于了解几乎所有的java技术特性非常有帮助. <BR>http://www.javablogs.com] - 互联|上最z跃的一个Java Blog|站. <BR>http://java.about.com/] - 来自About.com的Java新闻和技术文章网?<BR><BR>另外Q?A >www.theserverside.com</A></P> <P><A >www.apache.org</A></P> <P>http://sourceforge.net/ </P><img src ="http://www.tkk7.com/fortune/aggbug/32062.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/fortune/" target="_blank">fortune</a> 2006-02-23 09:51 <a href="http://www.tkk7.com/fortune/archive/2006/02/23/32062.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个小SWTE序http://www.tkk7.com/fortune/archive/2006/02/22/31952.htmlfortunefortuneWed, 22 Feb 2006 05:13:00 GMThttp://www.tkk7.com/fortune/archive/2006/02/22/31952.htmlhttp://www.tkk7.com/fortune/comments/31952.htmlhttp://www.tkk7.com/fortune/archive/2006/02/22/31952.html#Feedback0http://www.tkk7.com/fortune/comments/commentRss/31952.htmlhttp://www.tkk7.com/fortune/services/trackbacks/31952.html以下E序q行后生一个红色的球在窗口来回弹Q如在小球结束运动之前关闭窗口(shellQ则产生Q?BR>
Exception in thread "main" org.eclipse.swt.SWTException: Widget is disposed
 at org.eclipse.swt.SWT.error(SWT.java:2942)
 at org.eclipse.swt.SWT.error(SWT.java:2865)
 at org.eclipse.swt.SWT.error(SWT.java:2836)
 at org.eclipse.swt.widgets.Widget.error(Widget.java:395)
 at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:297)
 at org.eclipse.swt.widgets.Control.internal_new_GC(Control.java:1104)
 at org.eclipse.swt.graphics.GC.<init>(GC.java:132)
 at org.eclipse.swt.graphics.GC.<init>(GC.java:99)
 at ballThread.clean(BounceBall.java:115)
 at ballThread$2.run(BounceBall.java:135)
 at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
 at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
 at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3057)
 at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2716)
 at org.eclipse.swt.widgets.Display.release(Display.java:2765)
 at org.eclipse.swt.graphics.Device.dispose(Device.java:261)
 at BounceBall.main(BounceBall.java:58)

原因应该是仍然在使用对象时将该对象清除了D异常的生,应该怎样改动E序呢?Q思考中.........


import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.graphics.Color;

public class BounceBall {

 private Shell sShell = null;  //  @jve:decl-index=0:visual-constraint="10,10"
 private Canvas canvas = null;
 private Button startButton = null;
 ballThread bt = null;
 Display display = null;

 public BounceBall() {
  super();
  // TODO Auto-generated constructor stub
//  bt = new ballThread(canvas);
  display = Display.getDefault();
 }

 /**
  * This method initializes canvas 
  *
  */
 private void createCanvas() {
  canvas = new Canvas(sShell, SWT.NONE);
  canvas.setBackground(new Color(Display.getCurrent(), 0, 0, 255));
  canvas.setBounds(new org.eclipse.swt.graphics.Rectangle(26,14,527,242));
 }

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  /* Before this is run, be sure to set up the launch configuration (Arguments->VM Arguments)
   * for the correct SWT library path in order to run with the SWT dlls.
   * The dlls are located in the SWT plugin jar. 
   * For example, on Windows the Eclipse SWT 3.1 plugin jar is:
   *       installation_directory\plugins\org.eclipse.swt.win32_3.1.0.jar
   */
//  Display display = Display.getDefault();
  
  BounceBall thisClass = new BounceBall();
  thisClass.createSShell();
  thisClass.sShell.open();

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

 /**
  * This method initializes sShell
  */
 private void createSShell() {
  sShell = new Shell();
  sShell.setText("Shell");
  createCanvas();
  sShell.setSize(new org.eclipse.swt.graphics.Point(588,367));
  startButton = new Button(sShell, SWT.NONE);
  startButton.setBounds(new org.eclipse.swt.graphics.Rectangle(87,284,76,33));
  startButton.setText("Start");
  startButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
   public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
    //System.out.println("widgetSelected()"); // TODO Auto-generated Event stub widgetSelected()
    new ballThread(40,40,canvas).start();
    
   }
  });
 }

}


 class ballThread extends Thread {

  int x, y, xsize, ysize, addx, addy;
  Rectangle rc = null;
  GC gc = null;
  Canvas c = null;
  Color red = Display.getCurrent().getSystemColor(SWT.COLOR_RED);

  public ballThread(int x,int y,Canvas ca) {
   c = ca;
   this.x = x;
   this.y = y;
   xsize = 10;
   ysize = 10;
   addx = 1;
   addy = 2;
   rc = c.getBounds();
   
  }
  
  
  public void draw(int x, int y, int xsize, int ysize) {
   
   gc = new GC(c);
   gc.drawOval(x, y, xsize, ysize);
   gc.setBackground(red);
   gc.fillOval(x, y, xsize, ysize);
   gc.dispose();
  }

  public void clean() {
   gc = new GC(c);
   // Rectangle rt = canvas.getBounds();
   gc.drawRectangle(rc.x - 100, rc.y - 100, rc.width + 100,
     rc.height + 100);
   gc.fillRectangle(rc.x - 100, rc.y - 100, rc.width + 100,
     rc.height + 100);
   gc.dispose();
  }

  public void run() {
   for (int i = 1; i < 1500; i++) {
    try{
     
    Display.getDefault().asyncExec(new Thread () {
    public void run(){
    draw(x, y, xsize, ysize);}});
     Thread.sleep(10);
    
    Display.getDefault().asyncExec(new Thread () {
    public void run(){ 
    clean();}});
    } catch (InterruptedException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
    

    if (rc.contains(x, y)) {
     x += addx;
     y += addy;
    } else {
     

     if (x >= rc.width || x <= 26) {
      addx = -addx;

      x += addx;
      y += addy;
     } else if (y >= rc.height || y <= 14) {
      addy = -addy;

      x += addx;
      y += addy;
     }

    }

   }
  }

 }

惛_一个办法能够去除那些exceptionsQ就是在display.dispose()前加一句Thread.currentThread().stop();强制l止U程Q不q这个办法肯定是最垃圾的办?......



fortune 2006-02-22 13:13 发表评论
]]>
SWThttp://www.tkk7.com/fortune/archive/2006/02/22/31925.htmlfortunefortuneWed, 22 Feb 2006 02:59:00 GMThttp://www.tkk7.com/fortune/archive/2006/02/22/31925.htmlhttp://www.tkk7.com/fortune/comments/31925.htmlhttp://www.tkk7.com/fortune/archive/2006/02/22/31925.html#Feedback0http://www.tkk7.com/fortune/comments/commentRss/31925.htmlhttp://www.tkk7.com/fortune/services/trackbacks/31925.html1.创徏昄Q它表示SWT会话
2.创徏一个或多个ShellQ它表示应用E序的主H口
3.创徏Shell内部所需的Q何其它小部g
4.初始化小部g的大和必需的状态,为需要监听的部件注册监听器
5.打开ShellH口
6.q行事g调度循环直到发生退出情况ؓ?BR>7.清除昄

SWT提供的组Ӟ
1.昄QDisplayQ?BR> 理q_事g循环Q控制用L面线E和其它U程之间的通信Q除非是多线E否则不需要太多考虑display
2.shell
OSq_H口理器管理的一个“窗口”,辅助shell是作为另一个shell的子代创建的通常用作对话框或其它的瞬时窗?BR>3.输入lg
主要用来理q_事g循环和控制用L面线E和其它U程之间的通信Q处理字W串的输入与输出Q以及对应事件的发生?BR>Button   有普通按钮pushQcheck按钮Qradio按钮Qtoggle按钮
Text  可以输入文字 可指定单行,多行Q和滚动?BR>Combo
Slider
4.昄lgQ用于显C文字,囄{)
Label    昄文字或图?BR>Canvas
List   能够q行一览显C,可以从一览中选定一行或几行
Table   昄二维表格Q可以在列头指定列名
Tree
ProgressBar   昄q度?BR>5.Menu/工具栏组?BR>在窗口上配置Menu和工h
Menu
ToolBar   昄工具?BR>CoolBar   昄可以使用鼠标拖动的工h
6.容器lg
可以包含其它的Widget
Composite
Group
TabFolder   可以通过Tab换页
SashForm
7.对话框组?BR>MessageBox   昄message
FileDialog   指定文g
DirectoryDialog    指定路径
ColorDialog   指定颜色
FontDialog   指定字体
PrintDialog   指定打印?BR>8.布局理lg
FillLayout   填补I隙Q水qx垂直配置
FormLayout   参照其它H口q行布局
RowLayout    水^或垂直配|,可指定margin或widget之间的距?BR>GridLayout
StackLayout

布局
1.FillLayout 填充布局
是最单的布局Q将部件布局在单行或单列中,强制他们全部使用相同的大?BR>可以使用它对d栏或工具栏中的按钮进行布局
2.RowLayout 行布局
Q写不动了,休息先)












fortune 2006-02-22 10:59 发表评论
]]>
SWT多线E(1Q?/title><link>http://www.tkk7.com/fortune/archive/2006/02/22/31899.html</link><dc:creator>fortune</dc:creator><author>fortune</author><pubDate>Wed, 22 Feb 2006 01:10:00 GMT</pubDate><guid>http://www.tkk7.com/fortune/archive/2006/02/22/31899.html</guid><wfw:comment>http://www.tkk7.com/fortune/comments/31899.html</wfw:comment><comments>http://www.tkk7.com/fortune/archive/2006/02/22/31899.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/fortune/comments/commentRss/31899.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/fortune/services/trackbacks/31899.html</trackback:ping><description><![CDATA[<BR>在SWT中,通常存在一个被UCؓ"用户U程"的唯一U程Q只有在q个U程中才能调用对构g或某些图形API的访问操作。如果在非用LE中E序直接调用q些讉K操作Q那么SWTExcepiton异常会被抛出Qif (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);Q每一个在非用LE中出现的widget都要通过验看display.thread 是否{于Thread.currentThread()如果不相{就要抛出非法访问线E异常。但是SWT也在*.widget.DisplaycM提供了两个方法可以间接的在非用户U程的进行图形构件的讉K操作Q这是通过的syncExec(Runnable)和asyncExec(Runnable)q两个方法去实现的?BR><BR><FONT size=1>  </FONT><SPAN style="FONT-FAMILY: 宋体">对于</SPAN><SPAN lang=EN-US>Display</SPAN><SPAN style="FONT-FAMILY: 宋体">Q在同一个线E里Q不能申?/SPAN><SPAN lang=EN-US>2</SPAN><SPAN style="FONT-FAMILY: 宋体">?/SPAN><SPAN lang=EN-US>Display</SPAN><SPAN style="FONT-FAMILY: 宋体">实例。同LQ一?/SPAN><SPAN lang=EN-US>Display</SPAN><SPAN style="FONT-FAMILY: 宋体">实例也不能跨U程使用。也是_如果你要在另外一个线E中昄一个窗体,Q比如你要在d完成后弹Z个对话框Q,你必d外创Z?/SPAN><SPAN lang=EN-US>Display</SPAN><SPAN style="FONT-FAMILY: 宋体">实例。不然会D异常?</SPAN> <img src ="http://www.tkk7.com/fortune/aggbug/31899.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/fortune/" target="_blank">fortune</a> 2006-02-22 09:10 <a href="http://www.tkk7.com/fortune/archive/2006/02/22/31899.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> վ֩ģ壺 <a href="http://ranjihua.com" target="_blank">91һ߹ۿ </a>| <a href="http://xx16xx.com" target="_blank">Aһ</a>| <a href="http://miya863.com" target="_blank">޳avƬ߿Ƭ</a>| <a href="http://4466n.com" target="_blank">Ʒһ߹ۿ</a>| <a href="http://jiujiujingpin.com" target="_blank">߹ۿɫƬƵ</a>| <a href="http://changfafangzhi.com" target="_blank">aëƬa</a>| <a href="http://8888kkk.com" target="_blank">ƷһëƬ</a>| <a href="http://51xinshiji.com" target="_blank">޹Ů޹</a>| <a href="http://mangaou.com" target="_blank">޾ƷþþӰԺӰƬ</a>| <a href="http://gysysz.com" target="_blank">һ</a>| <a href="http://baoyutv777.com" target="_blank">ۺ</a>| <a href="http://zfjhw.com" target="_blank">ƵѲ</a>| <a href="http://xxyy66.com" target="_blank">վavƬ</a>| <a href="http://dyj696.com" target="_blank">99ѾƷƵ</a>| <a href="http://fenglufzjx.com" target="_blank">þerƷѹۿ8</a>| <a href="http://714747.com" target="_blank">Ůվ</a>| <a href="http://shcxsoft.com" target="_blank">ɫվwww</a>| <a href="http://xiaomaomi8.com" target="_blank">޹Ʒר</a>| <a href="http://9527paotui.com" target="_blank">ղһ</a>| <a href="http://junyehome.com" target="_blank">þþ޾ƷƵ</a>| <a href="http://znboxcdn107.com" target="_blank">޹պƵ</a>| <a href="http://6711wan.com" target="_blank">Ʒһ߹ۿ</a>| <a href="http://yidazn.com" target="_blank">www.޾Ʒ.com</a>| <a href="http://obtainfo.com" target="_blank">Avznlu</a>| <a href="http://bixnu.com" target="_blank">һƬѿ</a>| <a href="http://by22877.com" target="_blank">ڵëƬѿ</a>| <a href="http://941sese.com" target="_blank">Ƶ߹ۿѿƬ</a>| <a href="http://znboxcdn304.com" target="_blank">ܻƺܻƵվѵ</a>| <a href="http://zzhdrsqwx.com" target="_blank">69xxѹۿƵ</a>| <a href="http://jastrelax.com" target="_blank">ֳִִֺƵ</a>| <a href="http://shaonvfushi.com" target="_blank">ѹۿɫƵվbd</a>| <a href="http://by6174.com" target="_blank">޾Ʒ</a>| <a href="http://microston.com" target="_blank">ɫĻAV</a>| <a href="http://guhey.com" target="_blank">츾AV߲</a>| <a href="http://2002tw.com" target="_blank">ľþþƷ</a>| <a href="http://sds54.com" target="_blank">޾ƷVŷ޾ƷVպƷ</a>| <a href="http://miyatb.com" target="_blank">պ޴߶ȸ</a>| <a href="http://79909d.com" target="_blank">AVһ</a>| <a href="http://46339cc.com" target="_blank">þþþһƷ޹ۺAV</a>| <a href="http://hztkw.com" target="_blank">ձ</a>| <a href="http://sk7758.com" target="_blank">վƵA˫</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>