Tutorial
Log-in
|
Register
|
Main
:
Home
>
Tutorial
Top Menu
Show
:
Comments
Attachments
History
Print
:
Print
Print preview
Export as PDF
Export as RTF
Export as HTML
Export as XAR
Wiki code for
Tutorial
Hide Line numbers
1: #toc("" "" "true") 2: 3: 1.1 Installation 4: 5: * Download and extract the lwuimb-xxx.tar.gz file 6: * Put the lwuimb-xxx.jar, microbackend-*.jar and the "configuration" directory in your classpath 7: * Start coding or start the demo: 8: From the project root: 9: {code:java} 10: java -cp dist/microbackend.jar:dist/lwuimb-0.1-alpha1.jar:dist/lwuimb-demo.jar:configuration org.thenesis.lwuimb.demo.BaseDemo 11: {code} 12: 13: #info("Modify the configuration file in order to adapt it to your environment (see below). If you are in an environment supporting AWT, you can use the default configuration as is at first.") 14: 15: #info("See also the \"Build MicroBackend and/or native parts\" section") 16: 17: 1.1 Usage 18: 19: LWUIMB gives to developers the ability to choose the level of control on the underlying graphics layers. The implicit mode fits well with fast development, simple application or deployment on embedded platforms, while the explicit mode provides more control (useful for integration in an IDE for example) 20: 21: *Common code for all examples below:* 22: {code:java} 23: /** 24: * Create a LWUIT application 25: */ 26: public Form createLWUITApp(Object m) { 27: Form f = new Form("Main"); 28: TextArea ta = new TextArea("Sed ut perspiciatis unde omnis...", 5, 20); 29: f.addComponent(ta); 30: f.show(); 31: return f; 32: } 33: {code} 34: 35: 1.1.1 Implicit mode 36: 37: When running in implicit mode, LWUIMB starts the backend by searching in the system properties or the configuration file (in that order). 38: 39: It’s by far the easiest mode, but you have less control on the graphics backend than with the explicit mode. 40: 41: 1.1.1.1 System properties 42: 43: Just set the appropriate property in your code somewhere *before* initializing the LWUIT Display (i.e Display.init() method). 44: 45: {code:java} 46: System.setProperty("org.thenesis.microbackend.ui.backend", "AWT"); 47: 48: // ... 49: 50: // Create a LWUIT application 51: Display.init(null); 52: Form mainForm = createLWUITApp(); 53: {code} 54: 55: Alternatively you can set the property in the java command line: 56: 57: {code:java} 58: java -Dorg.thenesis.microbackend.ui.backend=AWT -cp microbackend-core.jar:microbackend-graphics.jar:lwuimb-xxx.jar -jar lwuimb-demo.jar 59: {code} 60: 61: #info("The available backend parameter values are in the configuration file (see below) 62: ") 63: 64: 1.1.1.1 Configuration file 65: 66: Open the LWUIMB configuration file (configuration/org/thenesis/lwuit/configuration/configuration.cfg) and modify the backend property: 67: 68: {code:none} 69: # Possible backend values: NULL, SDL, AWT, AWTGRABBER, SWT, X11, GTK, QT, FB 70: org.thenesis.microbackend.ui.backend:AWT 71: {code} 72: 73: Java code: 74: {code:java} 75: // Nothing special to do ! 76: // Create a LWUIT application 77: Display.init(null); 78: Form mainForm = createLWUITApp(); 79: {code} 80: 81: 1.1.1 Explicit Mode 82: 1.1.1.1 AWT 83: 84: You can pass any AWT Container to the Display.init() method. The container must have a valid size and should not contain any component yet. 85: 86: {code:java} 87: // Create an AWT Frame 88: Frame frame = new Frame(); 89: frame.setSize(320, 240); 90: 91: // Create a LWUIT application 92: Display.init(frame); 93: Form mainForm = createLWUITApp(); 94: 95: // Make the frame visible 96: frame.pack(); 97: frame.setVisible(true); 98: {code} 99: 100: 1.1.1.1 SWT 101: 102: You can pass a SWT Canvas to the Display.init() method. The canvas must have a valid size. 103: 104: {code} 105: // Create a SWT canvas 106: org.eclipse.swt.widgets.Display display = new org.eclipse.swt.widgets.Display(); 107: Shell shell = new Shell(display); 108: shell.setText(""); 109: Canvas canvas = new Canvas(shell, SWT.NONE); 110: canvas.setSize(w, h); 111: 112: // Create a LWUIT application 113: Display.init(canvas); 114: Form mainForm = createLWUITApp(); 115: 116: // Show the SWT canvas and start the loop event 117: canvas.forceFocus(); 118: shell.pack(); 119: shell.open(); 120: while (!shell.isDisposed()) { 121: if (!display.readAndDispatch()) 122: display.sleep(); 123: } 124: display.dispose(); 125: {code} 126: 127: 1.1.1.1 UIBackend 128: 129: If you have special needs which don’t fit in the provided backends, you can implement quite easily your own backend. 130: 131: You just have to implement the org.thenesis.microbackend.UIBackend interface. 132: 133: {code:java} 134: // Create an custom UIBackend 135: UIBackend customBackend = new MyCustomBackend(); 136: 137: // Create a LWUIT application 138: Display.init(customBackend); 139: Form mainForm = createLWUITApp(); 140: {code} 141: 142: 1.1 Advanced instructions 143: 144: 1.1.1 Building MicroBackend and/or native parts 145: 146: If you want to use other backends than AWT or SWT, like the native ones (SDL, X11, GTK, QT, FB), or (re)build MicroBackend from the sources, you have to complete some other steps. 147: 148: Grab the MIDPath sources (MicroBackend is a subproject of MIDPath currently) 149: 150: {code} 151: # svn export https://midpath.svn.sourceforge.net/svnroot/midpath/trunk 152: # export MIDPATH_HOME=$(pwd)/trunk 153: {code} 154: 155: Build the sources with the appropriate options (type ./build.sh --help for a list of options). To build the Linux Framebuffer native part: 156: 157: {code} 158: # cd $MIDPATH_HOME 159: # chmod u+x build.sh 160: # ./build.sh --fb 161: {code} 162: 163: Grab the .so files and microbackend.jar from the dist directory and add it to your LWUIT project. 164: 165: #info("Set the java.library.path variable in your command line to point to the .so directory, or set the LD_LIBRARY_PATH environment variable") 166: 167: #info("For SDL, also grab sdljava-cldc.jar") 168: 169: 1.1.1 Building LWUIMB from the sources 170: 171: Go in the distribution root and type: 172: 173: {code} 174: # svn export svn://svn.evolvis.org/svnroot/lwuimb/trunk lwuimb 175: # cd lwuimb 176: # chmod u+x build.sh 177: # ./build.sh 178: {code} 179: 180: You may have to change some paths in the build script to fit your environment. Alternatively, you can use command line options to do the same (type ./build.sh --help for a list of options). 181: 182: For example, to use a custom J2SE class library: 183: 184: {code} 185: ./build.sh --with-j2se-jar=/path/to/my/j2se-classes.jar 186: {code} 187: 188: 189: 190:
Search
LWUIMB
Home
News
Tutorial
Download
SVN
Design
FAQ
Screenshots
Mailing list
IRC
Thenesis
Home
Project hosting