♠ Posted by Unknown in J2Me at 3:09 PM
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package m;
import java.io.IOException;
import java.io.InterruptedIOException;
import javax.microedition.io.Connector;
import javax.microedition.io.Datagram;
import javax.microedition.io.DatagramConnection;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import send.Sender;
/**
*
* @author ASUS
*/
public class CanvasPanerusSalendroxD extends Canvas implements Runnable{
Image imageSelthem;
Image tt;
int xPoint = -100; //initial value is outside the display frame for the first paint
int yPoint = -100;
String message = "",ips="",ports="";
String userActive="";
String chanel="";
int xx,yy;
//Sender s;
public CanvasPanerusSalendroxD(String ip,String port,String user,String kanal) {
try {
Thread a=new Thread(this);
userActive=user;
chanel=kanal;
ports=port;
ips=ip;
a.start();
} catch (Exception e) {
////System.out.println(e);
}
}
protected void paint(Graphics g) {
//throw new UnsupportedOperationException("Not supported yet.");
g.setColor(0xFFFFFF);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
if(this.getHeight() < 300){
tampilanKecil(g);
}else{
tampilanBesar(g);
}
System.out.println("");
}
void tampilanBesar(Graphics g){
try {
imageSelthem = Image.createImage("/image/panerusxD.png");
tt=Image.createImage("/image/tt.png");
} catch (IOException ex) {
ex.printStackTrace();
}
xx=(this.getWidth()/2-imageSelthem.getWidth()/2);
yy=(this.getHeight()/2-imageSelthem.getHeight()/2);
g.drawImage(imageSelthem,xx,yy, Graphics.TOP|Graphics.LEFT);
g.drawString(message, xPoint, yPoint, Graphics.BASELINE | Graphics.HCENTER);
}
void tampilanKecil(Graphics g){
try {
imageSelthem = Image.createImage("/image/d_kenong.png");
tt=Image.createImage("/image/tt.png");
} catch (IOException ex) {
ex.printStackTrace();
}
int xx=(this.getWidth()/2-imageSelthem.getWidth()/2);
int yy=(this.getHeight()/2-imageSelthem.getHeight()/2);
g.drawImage(imageSelthem,xx,yy, Graphics.TOP|Graphics.LEFT);
}
protected void pointerPressed(int x, int y) {
xPoint = x;
yPoint = y;
if(xPoint>=xx+80 && xPoint<=(xx+217)&&(yPoint>=yy+26)&&(yPoint<=yy+79)){ //1
pesan=("#P#"+userActive+"#1014#"+chanel+"#");
}
else if(xPoint>=xx+80 && xPoint<=(xx+217)&&(yPoint>=yy+99)&&(yPoint<=yy+152)){ //2
pesan=("#P#"+userActive+"#1034#"+chanel+"#");
}
else if(xPoint>=xx+80 && xPoint<=(xx+217)&&(yPoint>=yy+170)&&(yPoint<=yy+220)){ //3
pesan=("#P#"+userActive+"#1054#"+chanel+"#");
}
else if(xPoint>=xx+80 && xPoint<=(xx+217)&&(yPoint>=yy+237)&&(yPoint<=yy+283)){ //4
pesan=("#P#"+userActive+"#1064#"+chanel+"#");
}
else if(xPoint>=xx+80 && xPoint<=(xx+217)&&(yPoint>=yy+300)&&(yPoint<=yy+345)){ //5
pesan=("#P#"+userActive+"#1084#"+chanel+"#");
}
else if(xPoint>=xx+80 && xPoint<=(xx+217)&&(yPoint>=yy+365)&&(yPoint<=yy+410)){ //6
pesan=("#P#"+userActive+"#1104#"+chanel+"#");
}
else if(xPoint>=xx+80 && xPoint<=(xx+217)&&(yPoint>=yy+427)&&(yPoint<=yy+472)){ //7
pesan=("#P#"+userActive+"#1124#"+chanel+"#");
}
//----------------------------#
//-------------------
else if(xPoint>=xx+254 && xPoint<=(xx+305)&&(yPoint>=yy+67)&&(yPoint<=yy+113)){ //1
pesan=("#P#"+userActive+"#1024#"+chanel+"#");
}
else if(xPoint>=xx+254 && xPoint<=(xx+305)&&(yPoint>=yy+139)&&(yPoint<=yy+184)){ //2
pesan=("#P#"+userActive+"#1044#"+chanel+"#");
}
else if(xPoint>=xx+254 && xPoint<=(xx+305)&&(yPoint>=yy+268)&&(yPoint<=yy+311)){ //3
pesan=("#P#"+userActive+"#1074#"+chanel+"#");
}
else if(xPoint>=xx+254 && xPoint<=(xx+305)&&(yPoint>=yy+329)&&(yPoint<=yy+374)){ //4
pesan=("#P#"+userActive+"#1094#"+chanel+"#");
}
else if(xPoint>=xx+254 && xPoint<=(xx+305)&&(yPoint>=yy+391)&&(yPoint<=yy+437)){ //5
pesan=("#P#"+userActive+"#1114#"+chanel+"#");
}
}
protected void keyPressed(int keyCode) {
if(getKeyName(keyCode).equals("1")){
pesan=("#P#"+userActive+"#1014#"+chanel+"#");
}
if(getKeyName(keyCode).equals("2")){
pesan=("#P#"+userActive+"#1123#"+chanel+"#");
}
if(getKeyName(keyCode).equals("3")){
pesan=("#P#"+userActive+"#1083#"+chanel+"#");
}
if(getKeyName(keyCode).equals("4")){
pesan=("#P#"+userActive+"#1063#"+chanel+"#");
}
if(getKeyName(keyCode).equals("5")){
pesan=("#P#"+userActive+"#1053#"+chanel+"#");
}
if(getKeyName(keyCode).equals("6")){
pesan=("#P#"+userActive+"#1015#"+chanel+"#");
}
}
protected void keyReleased(int keyCode) {
if(getKeyName(keyCode).equals("1")){
pesan=("#P#"+userActive+"#0014#"+chanel+"#");
}
if(getKeyName(keyCode).equals("2")){
pesan=("#P#"+userActive+"#0123#"+chanel+"#");
}
if(getKeyName(keyCode).equals("3")){
pesan=("#P#"+userActive+"#0083#"+chanel+"#");
}
if(getKeyName(keyCode).equals("4")){
pesan=("#P#"+userActive+"#0063#"+chanel+"#");
}
if(getKeyName(keyCode).equals("5")){
pesan=("#P#"+userActive+"#0053#"+chanel+"#");
}
if(getKeyName(keyCode).equals("6")){
pesan=("#P#"+userActive+"#0015#"+chanel+"#");
}
}
public void Login(){
sendMessage("#U#"+userActive+"#"+chanel+"#");
}
public void Logout(){
sendMessage("#L#"+userActive+"#"+chanel+"#");
}
public void aathreadOff(){
sendMessage("#L#"+userActive+"#"+chanel+"#");
if (Thread.currentThread().isAlive()) {
tndThread=false;
}
}
public void sendMessage(String m) {
try {
DatagramConnection dgc = null;
dgc = (DatagramConnection) Connector.open("datagram://"+ips+":"+ports+"");
String datastring = m;
byte[] buf = datastring.getBytes();
Datagram dg = dgc.newDatagram(buf,datastring.length());
//dg.setAddress("datagram://192.32.80.192:9001");
dgc.send(dg);
dgc.close();
dd=false;
}
catch(IllegalArgumentException e3) {
//System.out.println(e3);
}
catch(InterruptedIOException e1) {
//System.out.println(e1);
}
catch(IOException e) {
//System.out.println(e);
}
System.out.println("kirim thread BonangPelogx");
}
String pesan="";
boolean dd=false,
tndThread=true;
public void run() {
while (true) {
if (dd == false) {
if (pesan.equals("")) {
dd = true;
sendMessage("#P#" + userActive + "#0010#" + chanel + "#");
pesan = "";
} else if (!pesan.equals("")) {
dd = true;
sendMessage(pesan);
pesan = "";
}
}
try {
Thread.sleep(30);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
if (tndThread==false) {
break;
}
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package m;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import send.Sender;
/**
* @author ASUS
*/
public class Midlet2 extends MIDlet implements CommandListener {
private SplashTimerCanvas ttCanvas;
private SuccesCanvas scCanvas;
private Display display;
private Timer timer;
private TimerTask timerTask;
private Command cmExit; // Command to exit the MIDlet
private Command cmLogin;
private Command cmBack;
private Command cmConeck;
Form f;
TextField tf_nama, tf_ip, tf_port,tf_chanel;
private ChoiceGroup cgAlatmusik, cgLaras;
public void startApp() {
display = Display.getDisplay(this);
//display.setCurrent(new CanvasSelthem());
ttCanvas = new SplashTimerCanvas(this);
display.setCurrent(ttCanvas);
try {
Image images[] =
{Image.createImage("/image/kSaron.png"), Image.createImage("/image/kSaron.png"),
Image.createImage("/image/kKempul.png"), Image.createImage("/image/kKempul.png"),
Image.createImage("/image/kKempul.png"), Image.createImage("/image/kKempul.png"),
Image.createImage("/image/kKempul.png"), Image.createImage("/image/kKempul.png"),
Image.createImage("/image/kKempul.png")};
String options[] = {"Saron Pelog", "Saron Salendro", "Kenong", "Jenglong"
, "Rincik", "Peking", "Bonang Pelog", "Bonang Salendro", "Panerus Salendro"
};
String options2[] = {"Pentatonik", "Diatonik"};
cgLaras = new ChoiceGroup("Pilih alat musik:", Choice.EXCLUSIVE, options2, null);
cgAlatmusik = new ChoiceGroup("Pilih alat musik:", Choice.EXCLUSIVE, options, images);
} catch (IOException ex) {
ex.printStackTrace();
}
f = new Form("Pengaturan Koneksi");
cmExit = new Command("Exit", Command.EXIT, 1);
cmLogin = new Command("Login", Command.SCREEN, 2);
tf_nama = new TextField("Nama User", "user", 30, 0);
tf_ip = new TextField("Ip server", "192.168.100.100", 30, 0);
tf_port = new TextField("Port", "11000", 30, 0);
tf_chanel = new TextField("Chanel", "1", 30, 0);
f.append(tf_nama);
f.append(tf_ip);
f.append(tf_port);
f.append(tf_chanel);
f.append(cgLaras);
f.append(cgAlatmusik);
f.addCommand(cmLogin);
f.addCommand(cmExit);
f.setCommandListener(this);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
void stopTimer() {
timer.cancel();
timerTask.cancel();
}
void startTimer() {
timer = new Timer();
scCanvas = new SuccesCanvas(this);
timerTask = new TimerTask() {
public void run() {
// display.setCurrent(scCanvas);
display.setCurrent(f);
}
};
// Jalankan timerTask setelah 3 detik
timer.schedule(timerTask, 3000);
}
public void commandAction(Command c, Displayable d) {
if (c == cmExit) {
destroyApp(false);
notifyDestroyed();
}
if (c == cmLogin) {
if(cgLaras.isSelected(0)){
//choicePentatonik();
choiceDiatonik();
}else{
choiceDiatonik2();
}
}
}
void choiceDiatonik() {
if (cgAlatmusik.getSelectedIndex() == 0) {//jika saron Pelog
final CanvasSaron14_1Tunggalx cs = new CanvasSaron14_1Tunggalx(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
if (cgAlatmusik.getSelectedIndex() == 1) {//jika saron Salendro
final CanvasSaron7x cs= new CanvasSaron7x(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 2){ //kenong
final CanvasKenongx cs = new CanvasKenongx(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 3){ //jenglong
final CanvasJengglong3X cs = new CanvasJengglong3X(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 4){ //rincik
final CanvasRincikx cs = new CanvasRincikx(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 5){ //bonang pelog
final CanvasPekingx cs = new CanvasPekingx(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 6){ //bonang pelog
final CanvasBonangPelogx cs = new CanvasBonangPelogx(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 7){ //bonang salendro
final CanvasBonangSalendrox cs = new CanvasBonangSalendrox(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 8){ //bonang salendro
final CanvasPanerusSalendrox cs = new CanvasPanerusSalendrox(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
}
void choiceDiatonik2() {
if (cgAlatmusik.getSelectedIndex() == 0) {//jika saron Pelog
final CanvasSaron14_1Tunggalx1D cs = new CanvasSaron14_1Tunggalx1D(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
if (cgAlatmusik.getSelectedIndex() == 1) {//jika saron Pelog
final CanvasSaron7xD cs= new CanvasSaron7xD(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 2){ //kenong
final CanvasKenong7xD cs = new CanvasKenong7xD(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 3){ //jenglong
final CanvasJengglong4XD cs = new CanvasJengglong4XD(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 4){ //rincik
final CanvasRincik12xD cs = new CanvasRincik12xD(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 5){ //bonang pelog
final CanvasPekingxD cs = new CanvasPekingxD(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 6){ //bonang pelog
final CanvasBonangPelogxD cs = new CanvasBonangPelogxD(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 7){ //bonang salendro
final CanvasBonangSalendroxD cs = new CanvasBonangSalendroxD(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
else if(cgAlatmusik.getSelectedIndex() == 8){ //bonang salendro
final CanvasPanerusSalendroxD cs = new CanvasPanerusSalendroxD(tf_ip.getString(), tf_port.getString(), tf_nama.getString(), tf_chanel.getString());
cmBack = new Command("Back", Command.BACK, 0);
cmConeck = new Command("Connect", Command.SCREEN, 0);
cs.addCommand(cmBack);
cs.addCommand(cmConeck);
cs.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable s) {
if (c == cmBack) { cs.aathreadOff();
display.setCurrent(f);
}
if (c == cmConeck) {
if (cmConeck.getLabel().equals("Stop")) {
cs.Logout();
cs.removeCommand(cmConeck);
cmConeck = new Command("Start", Command.BACK, 0);
cs.addCommand(cmConeck);
} else {
cs.Login();
cs.removeCommand(cmConeck);
cmConeck = new Command("Stop", Command.BACK, 0);
cs.addCommand(cmConeck);
}
}
}
});
display.setCurrent(cs);
}
}
public boolean equals(Object obj) {
return super.equals(obj);
}
public void back() {
display.setCurrent(f);
}
}
0 komentar:
Post a Comment