在pivot專案(由官網取得)中撰寫如下bxml檔案,用來設計UI。
<!--ui.bxml--> <Window title="Labels" maximized="true" xmlns:bxml="http://pivot.apache.org/bxml" xmlns="org.apache.pivot.wtk"> <BoxPane styles="{padding:4, verticalAlignment:'center'}"> <ImageView image="/clock.png"/> <Label text="現在的時間是?" styles="{font:'PMingLiU bold 24'}"/> </BoxPane> </Window>
============範例展示=================================================
============範例展示=================================================
java原始碼如下:
//NewClass.java import org.apache.pivot.beans.BXMLSerializer; import org.apache.pivot.collections.Map; import org.apache.pivot.wtk.Application; import org.apache.pivot.wtk.DesktopApplicationContext; import org.apache.pivot.wtk.Display; import org.apache.pivot.wtk.Window; public class NewClass implements Application { private Window window = null; public static void main(String[] args) { DesktopApplicationContext.main(NewClass.class, args); } @Override public void startup(Display display, Map<String, String> properties) throws Exception { BXMLSerializer bxmlSerializer = new BXMLSerializer(); window = (Window) bxmlSerializer.readObject(NewClass.class, "ui.bxml"); window.open(display); } @Override public boolean shutdown(boolean optional) { if (window != null) { window.close(); } return false; } @Override public void suspend() { } @Override public void resume() { } }
No comments:
Post a Comment