Download presentation
Presentation is loading. Please wait.
Published byRowan Izard Modified over 10 years ago
1
J2ME Melih Sakarya Java Teknolojileri Derneği
2
JVM JAVA Kullanılan yerler Windows-Linux-Unix-Solaris PDA lar Smart Cardlar Cep Telefonları Appletler Local Applicationlar LEGO Java Tv
3
KONFİGÜRASYON VE PROFİLLER CLDC (Connected Limited Device Configuration) CDC (Connected Device Configuration)
4
CLCD Konfigirasyonu KVM 512 KB tan ufak hafızası ve sınırlı ağ bağlantısı olan cihazlar için tasarlanmıştır java.io java.lang java.lang.ref java.util javax.microedition.io
5
CDC Konfigürasyonu CVM (Compact Virtual Machine) CLDC den daha fazla hafıza ve işlemci gücüne sahip cihazlarda kullanılır java.io java.lang java.lang.ref java.lang.reflect java.math java.net java.security java.security.cert java.text java.util java.util.jar java.util.zip javax.microedition.io
6
(MIDP) Mobile Information Device Profile MIDP 1.0 MIDP 2.0
7
MIDP 1.0 java.io java.lang java.util javax.microedition.io javax.microedition.lcdui javax.microedition.midlet javax.microedition.rms
8
MIDP 2.0 java.io java.lang java.util javax.microedition.io javax.microedition.lcdui.game javax.microedition.media javax.microedition.media.control javax.microedition.midlet javax.microedition.pki javax.microedition.rms
9
J2ME ve IDE ler http://java.sun.com/j2me/ http://www.netbeans.org http://wwws.sun.com/software/sundev/previous/st udio4u1/buy/ http://wwws.sun.com/software/sundev/previous/st udio4u1/buy/ http://www.eclipse.org/ http://eclipseme.sourceforge.net/
10
J2WTK Kurulumu http://java.sun.com/products/j2mewtoolkit/download-2_2.html
11
Midlet Yapısı public void startApp(){ } protected void pauseApp(){ } protected void destroyApp(boolean boolean0){ }
12
Örnek Midlet import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class OrnekMidlet extends MIDlet{ protected void startApp(){} protected void pauseApp(){} protected void destroyApp(boolean boolean0){} }
13
Örnek Midlet import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class MerhabaDunya extends MIDlet{ protected void startApp(){ TextBox box=new TextBox("Merhaba","MerhabaDünya",100,TextField.ANY); Display.getDisplay(this).setCurrent(box); } protected void pauseApp(){} protected void destroyApp(boolean boolean0){} }
14
LCDUI Limited Connected User Interface Display.getDisplay(this)
15
Display.getDisplay(this).setCurrent(nesne)
16
TextBox box=new TextBox("hello","Hello MIDlet",100,TextField.ANY); Display.getDisplay(this).setCurrent(box);
17
Form Nesneleri Form form= new Form("Giris"); TextField user= new TextField("Username:","",20,TextField.ANY); TextField pass= new TextField("Password:","",20,TextField.PASSWORD); ChoiceGroup cinsiyet=new ChoiceGroup("Cinsiyet", ChoiceGroup.EXCLUSIVE); cinsiyet.append("Bay",null);cinsiyet.append("Bayan",null); DateField tarih=new DateField("Dogum Tarihi",DateField.DATE); form.append(tarih);form.append(cinsiyet);form.append(user);form.append(pass);display.setCurrent(form);
18
Command import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class formUygulamasi extends MIDlet implements CommandListener{ Form form; Form form; Command cikis; Command cikis; Command kaydet; Command kaydet; public void startApp() { public void startApp() { form= new Form("Kayit Formu"); form= new Form("Kayit Formu"); TextField ad= new TextField("Adiniz:","",20,TextField.ANY); TextField ad= new TextField("Adiniz:","",20,TextField.ANY); cikis= new Command ("Cikis",Command.EXIT,2); cikis= new Command ("Cikis",Command.EXIT,2); kaydet= new Command("Kaydet",Command.OK,1); kaydet= new Command("Kaydet",Command.OK,1); form.addCommand(cikis); form.addCommand(cikis); form.addCommand(kaydet); form.addCommand(kaydet); form.append(ad); form.append(ad); Display.getDisplay(this).setCurrent(form); Display.getDisplay(this).setCurrent(form); } public void pauseApp() { public void pauseApp() { } public void destroyApp(boolean unconditional) { public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable s) { public void commandAction(Command c, Displayable s) { if (c == kaydet) { if (c == kaydet) { //islemler //islemler } }}
19
Alert Alert uyari = new Alert("Uyari", "Bos Alan Birakmayiniz", null, null); uyari.setTimeout(Alert.FOREVER);Display.getDisplay(this).setCurrent(uyari);
20
RMS (Record Management System) //Yaziyoruz //Yaziyoruz RecordStore rs=RecordStore.openRecordStore("telefon", true); RecordStore rs=RecordStore.openRecordStore("telefon", true); String[] liste={"Melih","Altug","Murat","Burak","Ozan","Mustafa"}; String[] liste={"Melih","Altug","Murat","Burak","Ozan","Mustafa"}; byte[] record; byte[] record; for (int i=0;i<liste.length;i++){ for (int i=0;i<liste.length;i++){ record=liste[i].getBytes(); record=liste[i].getBytes(); rs.addRecord(record,0, record.length); rs.addRecord(record,0, record.length); }
21
RMS (Record Management System) //okuyoruz byte[] recData= new byte[100]; byte[] recData= new byte[100]; int dataLen; int dataLen; for(int i=1;i<rs.getNumRecords();i++){ for(int i=1;i<rs.getNumRecords();i++){ rs.getRecord(i,recData,0); rs.getRecord(i,recData,0); dataLen = rs.getRecord(i,recData,0); dataLen = rs.getRecord(i,recData,0); String str=new String(recData,0,dataLen); String str=new String(recData,0,dataLen); try{ try{ System.out.println("icerik "+i+":"+str); System.out.println("icerik "+i+":"+str); } catch(Exception e){ catch(Exception e){ System.out.println(e.toString()); System.out.println(e.toString()); }
22
RMS (Record Management System) //kapatiyoruz //kapatiyoruz rs.closeRecordStore(); rs.closeRecordStore();
23
RMS (Record Management System) try{ RecordStore.deleteRecordStore("telefon"); RecordStore.deleteRecordStore("telefon"); } catch(Exception e){ catch(Exception e){ }
24
Sunucuya Baglanma Socket Baglantısı Http Baglantisi InputConnection OutputConnection DatagramConnection StreamConnection HttpConnection
25
HttpConnection HttpConnection baglanti= (HttpConnection)Connector.open("http://localhost:8080/test/index.jsp"); InputStream is=baglanti.openInputStream(); InputStream is=baglanti.openInputStream(); int ch; int ch; StringBuffer haber= new StringBuffer(); StringBuffer haber= new StringBuffer(); while((ch=is.read())!=-1){ while((ch=is.read())!=-1){ haber.append( (char)ch ); haber.append( (char)ch ); } is.close(); is.close(); baglanti.close(); baglanti.close();
26
Canvas import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class CanvasTest extends MIDlet{ public void startApp(){ public void startApp(){ TestCanvas canvas=new TestCanvas(); TestCanvas canvas=new TestCanvas(); Display.getDisplay(this).setCurrent(canvas); Display.getDisplay(this).setCurrent(canvas); } public void pauseApp(){} public void pauseApp(){} public void destroyApp(boolean unconditional){} public void destroyApp(boolean unconditional){} public class TestCanvas extends Canvas{ public class TestCanvas extends Canvas{ public void paint(Graphics g){ public void paint(Graphics g){ g.setColor(255,255,255); g.setColor(255,255,255); g.fillRect(0,0,getWidth(),getHeight()); g.fillRect(0,0,getWidth(),getHeight()); g.setColor(0,0,0); g.setColor(0,0,0); g.drawRect(10,10,50,50); g.drawRect(10,10,50,50); } }}
27
Media Api InputStream is =getClass().getResourceAsStram(“/audio.wav”); Player player= Manager.createPlayer(is, “audio/X-wav”); player.start();
28
Game Api javax.microedition.lcdui.game GameCanvas : Canvas class'ından extend olan bir oyun canvası. Layer: Bir orjini birde genişlik ve yüksekliği olan dikdörtgensel bir bölge tanımlamak için kullanılan bir class. LayerManager: Birden fazla Layer nesnelerini yönetmek için kullanılan bir class Sprite: Bir image'ı olan oyun nesneleri için kullanılan class. Animasyon, Döndürme gibi özellikleri bulunmakta. TiledLayer: Birden fazla hücresi olan bir layer nesnesi. Bu hücrelere image koyulabiliyor. Bu şeklilde aynı image'lardan bir çok TiledLayer nesnesi yaratılabiliyor.
31
Game Api if((getKeyStates()&LEFT_PRESSED)!=0){x--;} else if((getKeyStates()&RIGHT_PRESSED)!=0) {x++; }else if((getKeyStates()&UP_PRESSED)!=0){ y--; }else if((getKeyStates()&DOWN_PRESSED)!=0){ y++;} Graphics g=getGraphics(); clear(g);g.drawImage(image,x,y,Graphics.LEFT|Graphics.TOP);flushGraphics();
32
JAD Dosyası MIDlet-1: HelloMIDlet,, hello.HelloMIDlet MIDlet-2: Seminer,, hello.Seminer MIDlet-Jar-Size: 4484 MIDlet-Jar-URL: Melih.jar MIDlet-Name: Melih MIDlet-Vendor: Vendor MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.0 MicroEdition-Profile: MIDP-1.0
33
Örnek Wap Sayfası <wml> Midlet Download Et </a></card></wml>
34
Mimetype Tanımları.jar application/java-archive.jad text/vnd.sun.j2me.app-descriptor
35
SORULAR ???
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.