¿ìËÙÒµÎñͨµÀ

Eclipse¿ª·¢¾­µä½Ì³ÌÖ®Õ¹ÏÖ×é¼þ - ±à³ÌÈëÃÅÍø

×÷Õß ØýÃû¼¼Êõ À´Ô´ NET±à³Ì ä¯ÀÀ ·¢²¼Ê±¼ä 2012-06-17
menu.setLocation (point); menu.setVisible(true); } } }); //ÉèÖù¤¾ßÏîµÄÊ ¼þ****** Listener selectionListener = new Listener() { public void handleEvent(Event event) { ToolItem item = (ToolItem) event.widget; System.out.println(item.getText() + " is selected"); if ((item.getStyle() & SWT.RADIO) != 0 || (item.getStyle() & SWT.CHECK) != 0) System.out.println("Selection status: " + item.getSelection()); } }; itemPush.addListener(SWT.Selection, selectionListener); itemCheck.addListener(SWT.Selection, selectionListener); itemRadio1.addListener(SWT.Selection, selectionListener); itemRadio2.addListener(SWT.Selection, selectionListener); itemDropDown.addListener(SWT.Selection, selectionListener); toolBar.pack(); shell.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle clientArea = shell.getClientArea(); toolBar.setSize(toolBar.computeSize (clientArea.width, SWT.DEFAULT)); } }); shell.setSize(400, 100); shell.open(); while (!shell.isDisposed()) { if (! display.readAndDispatch()) { display.sleep(); } } display.dispose(); } public static void main(String[] args) { new ToolBarExample(); } }

Eclipse¿ª·¢¾­µä½Ì³ÌÖ®Õ¹ÏÖ×é¼þ(3)

ʱ¼ä:2011-04-11 °¢¸Ê

³ÌÐòÌí¼ÓÁ˹¤¾ßÀ¸£¬²¢ÔÚ¹¤¾ßÀ¸ÖÐÌí¼Ó ÁËÏàÓ¦µÄ¹¤¾ßÏ¹¤¾ßÏîÖÐÌí¼ÓÁËÏàÓ¦µÄʼþÏìÓ¦»úÖÆ£¬³ÌÐòÔËÐÐЧ¹ûÈçͼ2Ëùʾ¡£

Eclipse¿ª·¢¾­µä½Ì³ÌÖ®Õ¹ÏÖ×é¼þ - ±à³ÌÈëÃÅÍø

ͼ2 ¹¤¾ßÀ¸×é¼þ

±¾Ê¾ÀýÏÔʾÁ˹¤¾ßÀ¸ºÍ²Ëµ¥À¸µÄÅäºÏʹÓ㬲˵¥¶¯Ì¬É趨ÏÔʾµÄλÖà ¡£

¹¤¾ßÀ¸×é¼þCoolBarºÍCoolItem

CoolBarÊÇÁíÍâÒ»ÖÖÐÎʽµÄ¹¤¾ßÀ¸£¬ËüÄܹ» µ÷ÕûCoolItemµÄλÖã¬Ã¿Ò»¸öCoolItem¿ÉÒÔÉ趨Ïà¹ØµÄ×é¼þ£¨Ò²¿ÉÒÔÊÇÁíÒ»¸ö¹¤¾ßÀ¸£©£¬´´ ½¨CoolBarµÄ²½ÖèÈçÏ£º

1. ´´½¨CoolBar¶ÔÏ󣬲¢Ö¸¶¨´´½¨µÄÑùʽ£¬ÀýÈç “CoolBar composite = new CoolBar (parent, SWT.NONE);”¡£

2. ´´½¨ CoolItem¶ÔÏ󣬲¢Ö¸¶¨´´½¨Ñùʽ£¬ÀýÈç“CoolItem item = new CoolItem(composite, SWT.NONE);”¡£

3. ÉèÖÃCoolItemµÄControl¶ÔÏó£¬ÀýÈç “item.setControl(tb);”¡£

CoolBarÏ൱ÓÚÒ»¸öÃæ°åÈÝÆ÷£¬CoolItemÊÇ ÈÝÆ÷ÖеÄÿһÏCoolItemÄÜÉèÖÃÏàÓ¦µÄ×é¼þ×÷Ϊ´ËÏîµÄ×ÓÈÝÆ÷£¨Ò²¿ÉÒÔÊÇÆäËû×é¼þ£©¡£Îª Á˸üºÃµØÕÆÎÕCoolBar×é¼þ£¬ÏÂÃæͨ¹ýÒ»¸öʵÀýÑÝʾÈçºÎ´´½¨CoolBar×é¼þ£¬´úÂëÈçÀý³Ì3Ëùʾ ¡£

Àý³Ì3 CoolBarExample.java

public class CoolBarExample extends ApplicationWindow { public CoolBarExample() { super(null); } protected Control createContents(Composite parent) { getShell ().setText("CoolBar Test"); String asCoolItemSection[] = { "File", "Formatting", "Search" }; //Ìí¼Ó CoolBar CoolBar composite = new CoolBar(parent, SWT.NONE); for (int idxCoolItem = 0; idxCoolItem < 3; ++idxCoolItem) { CoolItem item = new CoolItem(composite, SWT.NONE); //Ìí¼****é¼þ ToolBar tb = new ToolBar (composite, SWT.FLAT); for (int idxItem = 0; idxItem < 3; ++idxItem) { ToolItem ti = new ToolItem(tb, SWT.NONE); ti .setText (asCoolItemSection[idxCoolItem] + " Item #" + idxItem); } Point p = tb.computeSize(SWT.DEFAULT, SWT.DEFAULT); tb.setSize(p); Point p2 = item.computeSize(p.x, p.y); //ÉèÖÃΪһ¸öCoolItemµÄ¿ØÖÆÀà item.setControl(tb); item.setSize(p2); } return

ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!

·ÖÏíµ½£º ¸ü¶à

Copyright ©1999-2011 ÏÃÃÅÁèÖڿƼ¼ÓÐÏÞ¹«Ë¾ ÏÃÃÅÓÅͨ»¥Áª¿Æ¼¼¿ª·¢ÓÐÏÞ¹«Ë¾ All rights reserved

µØÖ·(ADD)£ºÏÃÃÅÈí¼þÔ°¶þÆÚÍûº£Â·63ºÅ701E£¨¶«ÄÏÈÚͨÅÔ£© Óʱà(ZIP)£º361008

µç»°£º0592-5908028 ´«Õ棺0592-5908039 ×ÉѯÐÅÏ䣺web@lingzhong.cn ×ÉѯOICQ£º173723134

¡¶ÖлªÈËÃñ¹²ºÍ¹úÔöÖµµçÐÅÒµÎñ¾­ÓªÐí¿ÉÖ¤¡·ÃöB2-20100024  ICP±¸°¸:ÃöICP±¸05037997ºÅ