All pastes #994552 Raw Edit

distro.java

public text v1 · immutable
#994552 ·published 2008-04-23 14:06 UTC
rendered paste body
package linux;



import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;



public class distro extends MIDlet implements CommandListener {
    private static final Command keluar = new Command("Keluar", Command.EXIT, 1);
    private static final Command kembalidebian = new Command("Back to debian", Command.BACK, 1);
    private static final Command kembali = new Command("Kembali", Command.BACK, 1);
    
    private Display tampilkan;
    private List pilihan;
    

    private boolean firstTime;
    private List turunan_distro_slackware;
    private List turunan_distro_debian;
    private List turunan_distro_debian_knoppix;
    private List turunan_distro_debian_ubuntu;
    
    Display tampilkano;
    public BacaFile baca;
    
    
    public distro () {
        tampilkan = Display.getDisplay(this);
        
        
        //baca = new BacaFile(this, tampilkano);
                
        String[] turunan_slackware = { "Slax","Vector", "Zenwalk"};
        // the string elements will have no images
        Image[] icon = null;


        turunan_distro_slackware = new List("Pilih Turunan Disto dari debian", Choice.IMPLICIT, turunan_slackware, icon);
        turunan_distro_slackware.addCommand(kembali);
        turunan_distro_slackware.addCommand(keluar);
        turunan_distro_slackware.setCommandListener(this);
        
        String[] turunan_debian = { "Knoppix","Ubuntu", "Kbuntu"};
        // the string elements will have no images
   

        turunan_distro_debian = new List("Pilih Turunan Disto dari debian", Choice.IMPLICIT, turunan_debian, icon);
        turunan_distro_debian.addCommand(kembali);
        turunan_distro_debian.addCommand(keluar);
        turunan_distro_debian.setCommandListener(this);
        

        
String[] turunan_debian_knoppix = { "Kanotix", "Gnoppix" };

        turunan_distro_debian_knoppix = new List("Pilih turunan dari knoppix", Choice.IMPLICIT, turunan_debian_knoppix, icon);
        turunan_distro_debian_knoppix.addCommand(kembalidebian);
        turunan_distro_debian_knoppix.addCommand(keluar);
        turunan_distro_debian_knoppix.setCommandListener(this);
        
        
        
             
String[] turunan_debian_ubuntu = { "de2ui", "blankon" };

        turunan_distro_debian_ubuntu = new List("Pilih turunan dari ubuntu", Choice.IMPLICIT, turunan_debian_ubuntu, icon);
        turunan_distro_debian_ubuntu.addCommand(kembalidebian);
        turunan_distro_debian_ubuntu.addCommand(keluar);
        turunan_distro_debian_ubuntu.setCommandListener(this);
        
        
        
        

	firstTime = true;
    }

 
    
    
    
    
    protected void startApp() {
        if (firstTime) {
            // these are the images and strings for the choices.
            Image[] gambar_icon = null;
            Image[] gambar_icon1 = null;
            try {
                // load the duke image to place in the image array
                Image icon = Image.createImage("/gambar/Icon.png");

                // these are the images and strings for the choices.
                gambar_icon = new Image[] { icon, icon, icon, icon };
            } catch (java.io.IOException err) {
                // ignore the image loading failure the application can recover.
            }

            String[] distro = { "Slackware", "Debian", "Red Hat", "Gento" };
            pilihan = new List("Pilih Turunan Dsitro", Choice.IMPLICIT, distro, gambar_icon);
            pilihan.addCommand(keluar);
            pilihan.setCommandListener(this);
            tampilkan.setCurrent(pilihan);
                              
            firstTime = false;
            
            
        }
        
  
            
       
    }

    protected void destroyApp(boolean unconditional) {
    }

    protected void pauseApp() {
    }

    public void commandAction(Command c, Displayable d) {
        
 /**
  * sub kelas dari pilihan utama
  */
        if (d.equals(pilihan)) {
            // in the main list
            if (c == List.SELECT_COMMAND) {
                if (d.equals(pilihan)) {
                    switch (((List)d).getSelectedIndex()) {
                    case 0:
                        
                        tampilkan.setCurrent(turunan_distro_slackware);
                                             
                        break;

                    case 1:
                        tampilkan.setCurrent(turunan_distro_debian);
                                               
                        
                        break;
                      
                   
                
                    }
                }
            }
        } 
                
        /**
         * sub kelas dari menu kedua
         */
                                if (d.equals(turunan_distro_debian)) {
                                 // in the main list
                                if (c == List.SELECT_COMMAND) {
                                if (d.equals(turunan_distro_debian)) {
                                switch (((List)d).getSelectedIndex()) {
                                case 0:
                        
                                tampilkan.setCurrent(turunan_distro_debian_knoppix);
                                //tampilkano.setCurrent(baca);                
                                    break;

                                case 1:
                                        
                                tampilkan.setCurrent(turunan_distro_debian_ubuntu);
                                    break;
                
                                            }
                                        }
                                    }
                                } 
        
           
                            
        
        
       if (c == kembalidebian) {
                tampilkan.setCurrent(turunan_distro_debian);
            }
        
        else {
            // in one of the sub-lists
            if (c == kembali) {
                tampilkan.setCurrent(pilihan);
            }
            
            
        }

        if (c == keluar) {
            destroyApp(false);
            notifyDestroyed();
        }
        

        
    }




}