Tampilkan postingan dengan label Java Moklet. Tampilkan semua postingan
Tampilkan postingan dengan label Java Moklet. Tampilkan semua postingan

Kamis, 08 Maret 2012

Konsep Dasar Stream I/O

Tipe-Tipe Stream yang Umum Digunakan :
stream karakter dan byte. Kita hanya mengulang perbedaan mendasar antara
keduanya. Stream byte adalah abstraksi file atau alat untuk data biner sedangkan
stream karakter adalah untuk karakter Unicode.
Class InputStream adalah abstraksi class root untuk semua input stream byte sedangkan
class OutputStream adalah class root abstraksi dari semua output stream byte. Untuk
stream karakter, superclasss yang sesuai dari semua class-class secara berturut-turut
adalah class Reader dan the Writer. Kedua class-class ini adalah abstraksi class-class
untuk membaca dan menulis stream karakter.
Stream juga dikategorikan berdasarkan apakah mereka digunakan untuk membaca atau
menulis stream.
Contoh Stream/IO :
import java.io.*;
class CopyFile {
void copy(String input, String output) {
FileReader reader;
FileWriter writer;
int data;
try {
reader = new FileReader(input);
writer = new FileWriter(output);
while ((data = reader.read()) != -1) {
writer.write(data);
}
reader.close();
writer.close();
} catch (IOException ie) {
ie.printStackTrace();
}
}
public static void main(String args[]) {
String inputFile = args[0];
String outputFile = args[1];
CopyFile cf = new CopyFile();
cf.copy(inputFile, outputFile);
}
}

Simple project with SWT and Swing :)

            Program SWT:
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
 
public class HelloWorld 
{
   public static void main (String[] args) 
  {
      Display display = new Display();
      Shell shell = new Shell(display);
      Label label = new Label(shell, SWT.NONE);
      label.setText("Hello World");
      label.pack();
      shell.pack();
      shell.open();
      while (!shell.isDisposed()) 
      {
         if (!display.readAndDispatch()) display.sleep();
      }
      display.dispose();
   }
}
            Program Swing:
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
 
public class SwingExample implements Runnable {
    @Override
    public void run() {
        // Create the window
        JFrame f = new JFrame ("Hello, World!");
        // Sets the behaviour for when the window is closed
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // add a label and a button
        f.getContentPane().add(new JLabel("Hello, world!"));
        f.getContentPane().add(new JButton("Press me!"));
        // arrange the components inside the window
        f.pack();
        //By default, the window is not visible. Make it visible.
        f.setVisible(true);
    }
 
    public static void main(String[] args) {
        SwingExample se = new SwingExample();
        // Schedules the application to be run at the correct time in the event queue.
        SwingUtilities.invokeLater(se);
    }
}       

SWT, AWT, Java Swing

             Standard Widget Toolkit (SWT) is a graphical widget toolkit for use with the Java platform. It was originally developed by IBM and is now maintained by the Eclipse Foundation in tandem with the Eclipse IDE. It is an alternative to the Abstract Window Toolkit (AWT) and Swing Java GUI toolkits provided by Sun Microsystems as part of the Java Platform, Standard Edition. To display GUI elements, the SWT implementation accesses the native GUI libraries of the operating system using JNI (Java Native Interface) in a manner that is similar to those programs written using operating system-specific APIs. Programs that call SWT are portable, but the implementation of the toolkit, despite part of it being written in Java, is unique for each platform.
The toolkit is licensed under the Eclipse Public License, an open source license approved by the Open Source Initiative.

             Abstract Window Toolkit (AWT) is Java's original platform-independent windowing, graphics, and user-interface widget toolkit. The AWT is now part of the Java Foundation Classes (JFC) — the standard API for providing a graphical user interface (GUI) for a Java program.
AWT is also the GUI toolkit for a number of Java ME profiles. For example, Connected Device Configuration profiles require Java runtimes on mobile telephones to support AWT.

            Swing is the primary Java GUI widget toolkit. It is part of Oracle's Java Foundation Classes (JFC) — an API for providing a graphical user interface (GUI) for Java programs.
Swing was developed to provide a more sophisticated set of GUI components than the earlier Abstract Window Toolkit (AWT). Swing provides a native look and feel that emulates the look and feel of several platforms, and also supports a pluggable look and feel that allows applications to have a look and feel unrelated to the underlying platform. It has more powerful and flexible components than AWT. In addition to familiar components such as buttons, check box and labels, Swing provides several advanced components such as tabbed panel, scroll panes, trees, tables and lists.
Unlike AWT components, Swing components are not implemented by platform-specific code. Instead they are written entirely in Java and therefore are platform-independent. The term "lightweight" is used to describe such an element. The Hierarchy:

       


              Jadi, kalo penjelasan singkatnya, AWT itu toolkit GUI standar independen yang dipunyai java, misalnya textarea, button, checkbox, label, textfield. Si AWT ini juga bisa buat MobileApps dengan profil Java tertentu. Kalo SWT itu hampir sama kaya AWT, tapi dengan pengembang yang berbeda, terus kalo SWT itu Open Source, kalo AWT itu nggak, terus juga Libraries beda,kalo ini pake JNI, dan juga hanya bisa untuk suatu spesifik program dan Swing itu versi paling canggih dan kompleks dari JFC, jadi tinggal tambah pengertian SWT dan QWT, trus tambahin kompleks dan canggih :D
Contoh program ada di posting selanjutnya :)

Java Foundation Classes (JFC)

            The Java Foundation Classes (JFC) are a graphical framework for building portable title "Java (programming language)" Java-based graphical user interfaces (GUIs). JFC consists of the Abstract Window Toolkit (AWT), Swing and Java 2D. Together, they provide a consistent user interface for Java programs, regardless whether the underlying user interface system is Windows, Mac OS X or Linux.

           
             AWT existed before JFC. AWT was heavily criticized for being little more than a wrapper around the native graphical capabilities of the host platform. That meant that the standard widgets in the AWT relied on those capabilities of the native widgets, requiring the developer to also be aware of the differences between host platforms.
An alternative graphics library called the Internet Foundation Classes was developed in more platform-independent code by Netscape.
At the same time, another graphics library, called Application Foundation Classes (AFC), was developed independently by Microsoft. It was made to be easier to extend the graphic components, but was primarily aimed for use with the Microsoft Java Virtual Machine.
On April 2, 1997, Sun Microsystems and Netscape announced their intention to combine IFC with other technologies to form the "Java Foundation Classes". The "Java Foundation Classes" were later renamed "Swing", adding the capability for a pluggable look and feel of the widgets. This allowed Swing programs to maintain a platform-independent code base, but mimic the look of a native application. The release of JFC made IFC obsolete, and dropped interest for Microsoft's AFC.

            Jadi, intinya si JFC ini adalah framework GUI punya JAVA yg terdiri dari Abstract Window Toolkit (AWT), Swing, Java 2D, dan Standard Window Toolkit (SWT), dan itu nggak tergantung sama OS, entah linux, windows atau MAC. Tentang SWT, AWT dan Swing akan ada di posting selanjutnya :D


Minggu, 24 Juli 2011

Variabel Java

Seperti yang kita semua tau kalo tiap bahasa pemrograman pasti punya jenis-jenis variabel masing-masing, nah Java memiliki beberapa jenis variabel yang dapat dikelompokkan sebagai berikut :

* Instance Variables (tidak statis). Dalam bahasa pemrograman berorientasi objek, objek menyimpan variabel yang tidak dideklarasikan dengan kata kunci static dalam kategori non-statis, atau dapat berubah-ubah. Suatu kelas dapat dijelmakan ke dalam beberapa objek. Nilai yang terkandung dalam variabel tak-statis ini berbeda untuk setiap objeknya.

* Class Variables (statis). Variabel ini merupakan bagian integral dari suatu kelas, dan tidak ada satu objek pun yang dapat menyatakan kepemilikan atas variabel ini. Variabel yang dideklarasikan sebagai statis digunakan bersama oleh semua objek. Variabel ini lebih bersifat global yang nilainya sama untuk setiap objek pada kelas yang bersangkutan.

* Local Variables. Variabel ini didefinisikan di dalam suatu metoda (method) atau dalam suatu prosedur. Variabel ini bersifat lokal karena hanya dapat diakses oleh metoda atau prosedur tersebut.

* Paramater atau argum

Sabtu, 23 Juli 2011

Trailer Mbois filem java vs microsoft .net framework

        Seperti yang kita tau bahwa java adalh sebuah bahasa pmrograman yang simpel dan mudah, tetapi ada juga kekurangan yang kita ketahui bersama, sehingga bersaing dengan microsoft .net framework yang sangat penting untuk aplikasi-aplikasi yang ada di windows, dan OS yang terkenal mnurutku skarang ini ya windows...
 Maka dari itu  microsoft .net framework sangat penting dan bisa bersaing dengan java. Nah, dari cerita berikut, aku punya trailer filem yang menceritakan tentang java vs microsoft .net framework, dan yang satu lagi adalah trailer filem tentang microsoft office 2010. Donload ya.... http://www.smileycodes.info

Yang ini buat java vs .net


yang ini buat office 2010 nya... :D

Jumat, 22 Juli 2011

Java, Apa itu??

      Java adalah bahasa pemrograman yang dapat dijalankan di berbagai komputer termasuk telepon genggam. Bahasa ini awalnya dibuat oleh James Gosling saat masih bergabung di Sun Microsystems saat ini merupakan bagian dari Oracle dan dirilis tahun 1995. Bahasa ini banyak mengadopsi sintaksis yang terdapat pada C dan C++ namun dengan sintaksis model objek yang lebih sederhana serta dukungan rutin-rutin aras bawah yang minimal. Aplikasi-aplikasi berbasis java umumnya dikompilasi ke dalam p-code (bytecode) dan dapat dijalankan pada berbagai Mesin Virtual Java (JVM). Java merupakan bahasa pemrograman yang bersifat umum/non-spesifik (general purpose), dan secara khusus didisain untuk memanfaatkan dependensi implementasi seminimal mungkin. Karena fungsionalitasnya yang memungkinkan aplikasi java mampu berjalan di beberapa platform sistem operasi yang berbeda, java dikenal pula dengan slogannya, "Tulis sekali, jalankan di mana pun". Saat ini java merupakan bahasa pemrograman yang paling populer digunakan, dan secara luas dimanfaatkan dalam pengembangan berbagai jenis perangkat lunak aplikasi ataupun aplikasi berbasis web.

Sejarah perkembangan Java

   Bahasa pemrograman Java pertama lahir dari The Green Project, yang berjalan selama 18 bulan, dari awal tahun 1991 hingga musim panas 1992. Proyek tersebut belum menggunakan versi yang dinamakan Oak. Proyek ini dimotori oleh Patrick Naughton, Mike Sheridan, James Gosling dan Bill Joy, beserta sembilan pemrogram lainnya dari Sun Microsystems. Salah satu hasil proyek ini adalah maskot Duke yang dibuat oleh Joe Palrang.
Pertemuan proyek berlangsung di sebuah gedung perkantoran Sand Hill Road di Menlo Park. Sekitar musim panas 1992 proyek ini ditutup dengan menghasilkan sebuah program Java Oak pertama, yang ditujukan sebagai pengendali sebuah peralatan dengan teknologi layar sentuh (touch screen), seperti pada PDA sekarang ini. Teknologi baru ini dinamai "*7" (Star Seven).
Setelah era Star Seven selesai, sebuah anak perusahaan Tv kabel tertarik ditambah beberapa orang dari proyek The Green Project. Mereka memusatkan kegiatannya pada sebuah ruangan kanto