Belajardengan.com merupakan domain blog lama dari delajardengan.blogspot.com. Mohon kritik dan sarannya untuk perkembangan blog ini.
email: blog.tkx.pnp@gmail.com

Link Untuk Belajar

♠ Posted by Unknown in

Link Untuk Belajar

http://msdn.microsoft.com/en-us/library/zd5e2z84.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1

Windows Phone || Contoh Simple Binding List

♠ Posted by Unknown in

Contoh Simple Binding List Windows Phone

MainPage.xaml
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Button Command="{Binding Tambah}" Content="Button" HorizontalAlignment="Left" Margin="336,-126,0,0" VerticalAlignment="Top"/>
            <ListBox ItemsSource="{Binding L_classnama}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Width="400" Background="Goldenrod" Margin="0,0,0,5">
                            <!-- Binding Source Gambar -->
                            <Image Margin="20,0,0,0" Height="60" Width="60" Source="{Binding Gambar}"></Image>
                            <!-- Binding TextBlock -->
                            <TextBlock Text="{Binding Nama}" TextWrapping="Wrap" FontSize="30" Style="{StaticResource PhoneTextExtraLargeStyle}" FontFamily="Comic Sans MS"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>

MainPage.xaml.cs

public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            DataContext = new MAinPageViewModle();
        }
    }


MAinPageViewModle

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
namespace Bi
{
    class MAinPageViewModle : Microsoft.Practices.Prism.ViewModel.NotificationObject
    {
        public List<ClassNama> L_classnama{get;set;}
        private Microsoft.Practices.Prism.Commands.DelegateCommand _tambah;
        void TambahAction() {
            L_classnama = new List<ClassNama>();
            L_classnama.Add(new ClassNama() { Nama = "xxxx", Gambar = "unduhan.jpg" });
            L_classnama.Add(new ClassNama() { Nama = "xx", Gambar = "unduhan.jpg" });
            L_classnama.Add(new ClassNama() { Nama = "xxx", Gambar = "unduhan.jpg" });
            Console.WriteLine("asssssssssssssssssssssssssssss");
            RaisePropertyChanged("");
        }
        public Microsoft.Practices.Prism.Commands.DelegateCommand Tambah
        {
            get { return _tambah; }
        }
        public MAinPageViewModle(){
            _tambah = new Microsoft.Practices.Prism.Commands.DelegateCommand(TambahAction);
            L_classnama = new List<ClassNama>();
            L_classnama.Add(new ClassNama() { Nama = "asdasdas" ,Gambar="unduhan.jpg"});
            L_classnama.Add(new ClassNama() { Nama = "asdasdas", Gambar = "unduhan.jpg" });
            L_classnama.Add(new ClassNama() { Nama = "asdasdas", Gambar = "unduhan.jpg" });
            L_classnama.Add(new ClassNama() { Nama = "asdasdas", Gambar = "unduhan.jpg" });
            L_classnama.Add(new ClassNama() { Nama = "asdasdas", Gambar = "unduhan.jpg" });
            L_classnama.Add(new ClassNama() { Nama = "asdasdas", Gambar = "unduhan.jpg" });
        }
    }  
}
 
ClassNama

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Bi
{
    class ClassNama  : Microsoft.Practices.Prism.ViewModel.NotificationObject
    {
        private string _nama;
        private string _gambar;
        public string Nama { get { return _nama; } set { _nama = value; RaisePropertyChanged(""); } }
        public string Gambar { get { return _gambar; } set { _gambar = value; RaisePropertyChanged(""); } }
    }
}





Dapatkan nama file dari url C#

♠ Posted by Unknown in

Dapatkan nama file dari url C#

public string GetFileName {             
            get{
                string URL = "http://vendyxiao.com/wp-content/uploads/2011/09/facebook_icon.png";
                _getNameFile = URL.Substring(URL.LastIndexOf("/") + 1, (URL.Length - URL.LastIndexOf("/") - 1));
                return _getNameFile;
            }
            set {
                _getNameFile = value;
            }
        }

Windows Phone || Save Image from Url

♠ Posted by Unknown in

Save Image from Url


using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using SaveImageHttptoIso2.Resources;
using System.Windows.Media.Imaging;
using System.IO;
using System.IO.IsolatedStorage;
using System.Threading;
using Microsoft.Xna.Framework.Media;
using System.Windows.Resources;

namespace SaveImageHttptoIso2
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            Uri uri = new Uri("http://www.english.cam.ac.uk/pop/images/google_icon.png", UriKind.Absolute);
            xxx.Source = new BitmapImage(uri);

            var webClient = new WebClient();
            webClient.OpenReadCompleted += WebClientOpenReadCompleted;
            webClient.OpenReadAsync(new Uri("http://www.english.cam.ac.uk/pop/images/google_icon.png", UriKind.Absolute));
        }

        void WebClientOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            const string tempJpeg = "TempJPEG.jpg";
            var streamResourceInfo = new StreamResourceInfo(e.Result, null);

            var userStoreForApplication = IsolatedStorageFile.GetUserStoreForApplication();
            if (userStoreForApplication.FileExists(tempJpeg))
            {
                userStoreForApplication.DeleteFile(tempJpeg);
            }

            var isolatedStorageFileStream = userStoreForApplication.CreateFile(tempJpeg);

            var bitmapImage = new BitmapImage { CreateOptions = BitmapCreateOptions.None };
            bitmapImage.SetSource(streamResourceInfo.Stream);

            var writeableBitmap = new WriteableBitmap(bitmapImage);
            writeableBitmap.SaveJpeg(isolatedStorageFileStream, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight, 0, 85);

            
    }
}

Simple Binding Image Windows Phone Isolatedstorage

♠ Posted by Unknown in

Simple Binding Image Windows Phone Isolatedstorage


MainPage.xaml

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <TextBox HorizontalAlignment="Left" Height="72" Margin="10,10,-10,0" TextWrapping="Wrap" Text="{Binding Nama, Mode=TwoWay}" VerticalAlignment="Top" Width="456"/>
            <TextBox HorizontalAlignment="Left" Height="72" Margin="10,82,-10,0" TextWrapping="Wrap" Text="{Binding Password, Mode=TwoWay}" VerticalAlignment="Top" Width="456"/>
            <Button Command="{Binding Save, Mode=TwoWay}" Content="Button" HorizontalAlignment="Left" Margin="158,178,0,0" VerticalAlignment="Top"/>
            <Button Content="Netxt" HorizontalAlignment="Left" Margin="187,311,0,0" VerticalAlignment="Top" Click="Button_Click_1"/>
        </Grid>

---
Page1.xaml

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <TextBlock HorizontalAlignment="Left" Margin="73,40,0,0" TextWrapping="Wrap" Text="{Binding Iso, Mode=OneTime}" VerticalAlignment="Top" Width="275"/>
            <Image Source="{Binding ThumbImage}" HorizontalAlignment="Left" Height="100" Margin="182,176,0,0" VerticalAlignment="Top" Width="100"/>
        </Grid>

---

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.IO.IsolatedStorage;
using System.Windows.Media.Imaging;
using System.IO;
using System.Windows.Resources;
using System.Windows;
namespace lainPageIso
{
    class MainViewModel : INotifyPropertyChanged
    {
        private string _nama, _password;

        private System.Windows.Input.ICommand _save;
 
        public MainViewModel(){
            this._save = new DelegateCommand(this.SaveAction);
        }

        public string Nama {
            get { return _nama; }
            set { _nama = value; RaisePropertyChanged(""); }
        }

        public string Password
        {
            get { return _password; }
            set { _password = value; RaisePropertyChanged(""); }
        }

        public void SaveAction(object p) {

            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
            StreamWriter streamWriter = null;
            if (!isf.FileExists("coba.txt"))
            {
                isf.CreateFile("coba.txt");
            }
            else {
                streamWriter = new StreamWriter(new IsolatedStorageFileStream("coba.txt",FileMode.Open,isf));
             
            }
            streamWriter.WriteLine(_nama+""+_password);
            streamWriter.Close();
            saveImage();
            RaisePropertyChanged("");
        }

        public System.Windows.Input.ICommand Save {
            get {
                return _save;
            }
        }

        void saveImage() {
            String tempJPEG = "logo.jpg";

            // Create virtual store and file stream. Check for duplicate tempJPEG files.
            using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (myIsolatedStorage.FileExists(tempJPEG))
                {
                    myIsolatedStorage.DeleteFile(tempJPEG);
                }

                IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile(tempJPEG);

                StreamResourceInfo sri = null;
                Uri uri = new Uri(tempJPEG, UriKind.Relative);
                sri = Application.GetResourceStream(uri);

                BitmapImage bitmap = new BitmapImage();
                bitmap.SetSource(sri.Stream);
                WriteableBitmap wb = new WriteableBitmap(bitmap);

                // Encode WriteableBitmap object to a JPEG stream.
                Extensions.SaveJpeg(wb, fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);

                //wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
                fileStream.Close();
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}

---

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.IsolatedStorage;
using System.Windows.Media.Imaging;
using System.IO;
using System.ComponentModel;

namespace lainPageIso
{
    class Page1ViewModel : INotifyPropertyChanged
    {
        IsolatedStorageFile get = IsolatedStorageFile.GetUserStoreForApplication(); 
        string x   ="";

        public Page1ViewModel() {
            if (get.FileExists("coba.txt"))
            {
                try
                {
                    StreamReader read = new StreamReader(new IsolatedStorageFileStream("coba.txt", FileMode.Open, get));
                    x = read.ReadLine();
                    read.Close();
                }
                catch (Exception ex)
                {
                }

            }
            if (get.FileExists("logo.jpg"))
            {
                x += " image ada";
            }
        }
        public string Iso {         
            
            get { return x; } 
        }

        void readImage() {
            BitmapImage bi = new BitmapImage();

            using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("logo.jpg", FileMode.Open, FileAccess.Read))
                {
                    //bi.SetSource(fileStream);
                    //img.Width = bi.PixelWidth;
                }
            }
            //this.img.Source = bi;
        }

        private string _thumbFileName;
        public string ThumbFileName
        {
            get
            {
                return _thumbFileName;
            }
            set
            {
                _thumbFileName = value;
                RaisePropertyChanged("ThumbFileName");
                RaisePropertyChanged("ThumbImage");
            }
        }

        public BitmapImage ThumbImage
        {
            get
            {
                BitmapImage image = new BitmapImage();
                IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
                string isoFilename = ThumbFileName;
                var stream = isoStore.OpenFile("logo.jpg", System.IO.FileMode.Open);
                image.SetSource(stream);
                return image;
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}






Windows Phone || INotifyPropertyChanged

♠ Posted by Unknown in

INotifyPropertyChanged


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Collections.ObjectModel;
namespace PhoneApp2
{
    class DataBinding2 : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private int _nama,_a,_b,_c;
        public int Nama {
            get {
                return _nama;
            }
            set {
                _nama = value;
                _nama = _nama * 5;
                berubah("Nama");
            }
        }

        public int A {
            get
            {
                return _a;
            }
            set
            {
                _a = value;
                berubah("");
            }
        }

        public int B
        {
            get
            {
                return _b;
            }
            set
            {
                _b = value;
                berubah("");
            }
        }

        public int C
        {
            get
            {
                return _c=_a+_b;
            }
            set
            {
                _c = value;
                berubah("");
            }
        }
        void berubah(string a) {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(a));
            }
        }
    }
}



------------------


<phone:PhoneApplicationPage
    x:Class="PhoneApp2.Page1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Button Content="Button" HorizontalAlignment="Left" Margin="153,31,0,0" VerticalAlignment="Top" />
            <TextBox Text="{Binding Nama}" HorizontalAlignment="Left" Height="72" Margin="0,133,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="456"/>
            <TextBox HorizontalAlignment="Left" Height="72" Margin="0,205,0,0" TextWrapping="Wrap" Text="{Binding A, Mode=TwoWay}" VerticalAlignment="Top" Width="456"/>
            <TextBox HorizontalAlignment="Left" Height="72" Margin="0,265,0,0" TextWrapping="Wrap" Text="{Binding B, Mode=TwoWay}" VerticalAlignment="Top" Width="456"/>
            <TextBox HorizontalAlignment="Left" Height="72" Margin="0,342,0,0" TextWrapping="Wrap" Text="{Binding C, Mode=TwoWay}" VerticalAlignment="Top" Width="456"/>
        </Grid>
        <Button Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top"/>
    </Grid>

</phone:PhoneApplicationPage>




Film akhir tahun Indonesia

♠ Posted by Unknown in

5 CM

Ane telah baca novelnya, dan sekarang jadi penasaran banget gimana filmnya. . .pengen nonton.. pemeranya:
  • DENNY SUMARGO as ARIAL
  • HERJUNOT ALI as ZAFRAN
  • IGOR "SAYKOJI" as IAN
  • RALINE SHAH as RIANI
  • RALINE SHAH as RIANI



HABIBIE DAN AINUN

Siapa sangka buku dari novel ini telah terjual lebih dari 150.000 kopi.. dan sekarang udah jadi Film..


UDP Touch Screen J2Me canvas

♠ Posted by Unknown in

/*
 * 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);
    }
}