import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Semester extends MIDlet{
Display display;
MainCanvas mainCanvas;
List list;
Command cmExit;
Ticker tic ;
Image image;
public Semester(){
cmExit = new Command ("Keluar",Command.EXIT,1);
display = Display.getDisplay(this);
tic = new Ticker("POLITEKNIK NEGERI SWIJAYA PALEMBANG");
list = new List("POLSRI", List.IMPLICIT);
list.setTicker(tic);
display.setCurrent (list);
}
public void startApp1 () {
}
public void startApp(){
mainCanvas = new MainCanvas (this, display);
display.setCurrent(mainCanvas);
}
public void pauseApp () {
}
public void destroyApp (boolean unconditional) {
}
public void commandAction (Command c, Displayable s){
}
public void exitMIDlet(){
destroyApp(true);
notifyDestroyed();
}
};
maincanvas.java
import javax.microedition.lcdui.*;
class MainCanvas
extends Canvas implements CommandListener{
private Display display;
private Semester midlet;
private Command cmExit;
private Image image;
private List list;
private Ticker tic;
public MainCanvas(Semester midlet, Display display){
this.midlet = midlet;
this.display = display;
try{
image = Image.createImage("/images.jpg");
}catch (java.io.IOException e){
}
cmExit = new Command ("Keluar",Command.EXIT,1);
addCommand (cmExit);
setCommandListener(this);
}
protected void paint (Graphics g){
g.drawImage (image, 0, 35, Graphics.TOP | Graphics.LEFT);
g.setColor (255, 0, 0);
g.setFont (Font.getFont(Font.FACE_PROPORTIONAL,
Font.STYLE_BOLD,Font.SIZE_LARGE));
g.drawString("Alamat : Jl Srijaya Negara Bukit", 10,220,
Graphics.TOP | Graphics.LEFT);
g.setColor (255, 0, 0);
g.setFont (Font.getFont(Font.FACE_PROPORTIONAL,
Font.STYLE_BOLD,Font.SIZE_LARGE));
g.drawString(" Besar Palembang 30139", 25, 235,
Graphics.TOP | Graphics.LEFT);
g.setColor (255, 0, 0);
g.setFont (Font.getFont(Font.FACE_PROPORTIONAL,
Font.STYLE_BOLD,Font.SIZE_LARGE));
g.drawString("Web : http://www.polsri.ac.id", 10,250,
Graphics.TOP | Graphics.LEFT);
g.setColor (255, 0, 0);
g.setFont (Font.getFont(Font.FACE_PROPORTIONAL,
Font.STYLE_BOLD,Font.SIZE_LARGE));
g.drawString("Telpon : +620711353414", 20,265,
Graphics.TOP | Graphics.LEFT);
}
public void commandAction(Command c, Displayable s){
if(c == cmExit){
midlet.exitMIDlet();
}
}
}
Hasil
Tidak ada komentar:
Posting Komentar