Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts
Thursday, September 1, 2011

Belajar Java Swing

Contoh Program Java GUI dengan menggunakan paket Swing Lihat Code Dibawah ini

import javax.swing.*;      

public class HelloWorldSwing {
  
    private static void createAndShowGUI() {
        //Ini Untuk Set judul Window nya
        JFrame frame = new JFrame("Mocco Gawe Pintar");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Isi Dari Label nya "http://alambebaz.blogspot.com" label.
        JLabel label = new JLabel("By http://alambebaz.blogspot.com ");
        frame.getContentPane().add(label);
       

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
             }
        });
    }
}




 Tampilan dari Program diatas kira kira seperti screnshot berikut ini: