Pages

This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Jumat, 11 Mei 2012

Love One Another

Love one another, but make not a bond of love. Let it rather be a moving sea between the shores of your souls. Fill each other's cup, but drink not from one cup. Give one another of your bread, but eat not from the same loaf. Sing and dance together and be joyous, but let each one of you be alone. Even as the strings of a lute are alone though they quiver with the same music. Give your hearts, but not into each other's keeping. For only the hand of life can contain your hearts. And stand together, yet not too near together. For the pillars of the temple stand apart. And the oak tree and the cypress grow not in each other's shadow.

Kamis, 26 April 2012

Merubah Icon pada Aplikasi Swing Java

Memulai Coding

// SebelumGanti.java
import javax.swing.JFrame; 
import javax.swing.SwingUtilities;


class SebelumGanti 
             { private static void gantiIcon() { 
                     JFrame.setDefaultLookAndFeelDecorated(true); JFrame f = new JFrame("Icon Belum Terganti");
               f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(400, 400); f.setVisible(true); } 

public static void main(String[] args) { 
               SwingUtilities.invokeLater(new Runnable() { public void run() { gantiIcon(); } }); } }



Dibawah ini kode program untuk mengganti icon


// SesudahGanti.java
import javax.swing.JFrame;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;
import java.awt.Toolkit;

public class SesudahGanti {
  private static void gantiIcon() {

// ini membuat frame tampilan yang sama di semua sistem operasi
   JFrame.setDefaultLookAndFeelDecorated(true);

   // membuat objek frame yang mempunyai judul
   JFrame f = new JFrame("Icon Sudah Terganti");

   // cara pertama untuk merubah icon pada swing
   ImageIcon gambar = new ImageIcon("bomb.png");
   f.setIconImage(gambar.getImage());

   // cara kedua untuk merubah icon pada swing
   f.setIconImage(Toolkit.getDefaultToolkit().getImage("bomb.png"));
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   f.setSize(400, 400);
   f.setVisible(true);
 }

  public static void main(String[] args) {
 // aplikasi swing ditempatkan di thread yang berbeda
 SwingUtilities.invokeLater(new Runnable() {
   public void run() {
  gantiIcon();
   } });
 }
  }

* icon sudah terganti 


Read more: http://blog.fastncheap.com/merubah-icon-pada-aplikasi-swing-java/#ixzz1t8rRXZwM

Project 5 Java Swing Makeover (Form Mahasiswa)


/*
 * TableMahasiswa.java
 *
 * Created on 15 Maret 2008, 0:05
 */
package sample;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author  usu
 */
public class TableMahasiswa extends javax.swing.JFrame {

    private DefaultTableModel model;

    /** Creates new form TableMahasiswa */
    public TableMahasiswa() {

        model = new DefaultTableModel();

        initComponents();

        setGlassPane(glasspane);
        glasspane.showPanel(tambahMahasiswa1, tambahMahasiswa1.getMinimumSize());

        tambahMahasiswa1.getTombolTambah().addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                model.addMahasiswa(tambahMahasiswa1.getMahasiswa());
                glasspane.setVisible(false);
            }
        });

        for (int i = 0; i < table.getColumnCount(); i++) {
            table.getColumnModel().getColumn(i).setCellRenderer(new RenderMahasiswa());
        }
      
        for (int i = 0; i < 100; i++) {
            model.addMahasiswa(new Mahasiswa("Eko Kurniawan Khannedy", "10106031", "IF-1"));
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                        
    private void initComponents() {

        table = new javax.swing.JTable();
        viewPort1 = new sample.ViewPort();
        glasspane = new pelajaran14.GlassPanePanel();
        tambahMahasiswa1 = new sample.TambahMahasiswa();
        panelEfect1 = new pelajaran3.PanelEfect();
        jScrollPane1 = new javax.swing.JScrollPane();
        jLabel1 = new javax.swing.JLabel();
        buttonTambah = new sample.Button();

        table.setAutoCreateRowSorter(true);
        table.setModel(model);
        table.setOpaque(false);

        viewPort1.setView(table);

        javax.swing.GroupLayout glasspaneLayout = new javax.swing.GroupLayout(glasspane);
        glasspane.setLayout(glasspaneLayout);
        glasspaneLayout.setHorizontalGroup(
            glasspaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        glasspaneLayout.setVerticalGroup(
            glasspaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jScrollPane1.setOpaque(false);
        jScrollPane1.setViewport(viewPort1);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("TABEL MAHASISWA");

        buttonTambah.setText("Tambah Mahasiswa");
        buttonTambah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonTambahActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelEfect1Layout = new javax.swing.GroupLayout(panelEfect1);
        panelEfect1.setLayout(panelEfect1Layout);
        panelEfect1Layout.setHorizontalGroup(
            panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelEfect1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 544, Short.MAX_VALUE)
                    .addComponent(jLabel1)
                    .addComponent(buttonTambah, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        panelEfect1Layout.setVerticalGroup(
            panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelEfect1Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonTambah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(21, 21, 21))
        );

        getContentPane().add(panelEfect1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>                      

private void buttonTambahActionPerformed(java.awt.event.ActionEvent evt) {                                            
// TODO add your handling code here:
    glasspane.setVisible(true);
}                                          

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(TableMahasiswa.class.getName()).log(Level.SEVERE, null, ex);
                } catch (InstantiationException ex) {
                    Logger.getLogger(TableMahasiswa.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IllegalAccessException ex) {
                    Logger.getLogger(TableMahasiswa.class.getName()).log(Level.SEVERE, null, ex);
                } catch (UnsupportedLookAndFeelException ex) {
                    Logger.getLogger(TableMahasiswa.class.getName()).log(Level.SEVERE, null, ex);
                } finally {
                    new TableMahasiswa().setVisible(true);
                }
            }
        });
    }

    // Variables declaration - do not modify                    
    private sample.Button buttonTambah;
    private pelajaran14.GlassPanePanel glasspane;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private pelajaran3.PanelEfect panelEfect1;
    private javax.swing.JTable table;
    private sample.TambahMahasiswa tambahMahasiswa1;
    private sample.ViewPort viewPort1;
    // End of variables declaration                  

    private static class DefaultTableModel extends javax.swing.table.DefaultTableModel {

        public DefaultTableModel() {
            super();
            addColumn("NIM");
            addColumn("NAMA");
            addColumn("KELAS");
        }

        public void addMahasiswa(Mahasiswa mhs) {
            addRow(new Object[]{
                        mhs.getNim(), mhs.getNama(), mhs.getKelas()
                    });
        }
    }
}

Project 4 Java Swing Makeover (Form Login)


/*
 * FormLogIn.java
 *
 * Created on 12 Maret 2008, 19:26
 */

package sample;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author  usu
 */
public class FormLogIn extends javax.swing.JFrame {

    /** Creates new form FormLogIn */
    public FormLogIn() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                        
    private void initComponents() {

        panelEfect = new pelajaran3.PanelEfect();
        label1 = new sample.Label();
        textField1 = new sample.TextField();
        password1 = new sample.Password();
        button1 = new sample.Button();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Form Log In");

        label1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sample/myofficelogo.png"))); // NOI18N

        textField1.setText("USERNAME");

        password1.setText("PASSWORD");

        button1.setText("LOGIN");

        javax.swing.GroupLayout panelEfectLayout = new javax.swing.GroupLayout(panelEfect);
        panelEfect.setLayout(panelEfectLayout);
        panelEfectLayout.setHorizontalGroup(
            panelEfectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelEfectLayout.createSequentialGroup()
                .addGap(185, 185, 185)
                .addGroup(panelEfectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(label1, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(textField1, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(password1, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
                    .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(186, 186, 186))
        );
        panelEfectLayout.setVerticalGroup(
            panelEfectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelEfectLayout.createSequentialGroup()
                .addGap(51, 51, 51)
                .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(password1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(44, Short.MAX_VALUE))
        );

        getContentPane().add(panelEfect, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>                      

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(FormLogIn.class.getName()).log(Level.SEVERE, null, ex);
                } catch (InstantiationException ex) {
                    Logger.getLogger(FormLogIn.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IllegalAccessException ex) {
                    Logger.getLogger(FormLogIn.class.getName()).log(Level.SEVERE, null, ex);
                } catch (UnsupportedLookAndFeelException ex) {
                    Logger.getLogger(FormLogIn.class.getName()).log(Level.SEVERE, null, ex);
                }
                new FormLogIn().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                  
    private sample.Button button1;
    private sample.Label label1;
    private pelajaran3.PanelEfect panelEfect;
    private sample.Password password1;
    private sample.TextField textField1;
    // End of variables declaration                

}

Project 3 Java Swing Makeover (Form Identitas)


/*
 * FormMenu.java
 *
 * Created on 12 Maret 2008, 20:08
 */

package sample;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author  usu
 */
public class FormIdentitas extends javax.swing.JFrame {

    /** Creates new form FormMenu */
    public FormIdentitas() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                        
    private void initComponents() {

        panelEfect1 = new pelajaran3.PanelEfect();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        textField1 = new sample.TextField();
        textField2 = new sample.TextField();
        textField3 = new sample.TextField();
        textField4 = new sample.TextField();
        jPanel2 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        textField5 = new sample.TextField();
        password1 = new sample.Password();
        button1 = new sample.Button();
        button2 = new sample.Button();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Form Input Identitas");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 255, 255), 1, true), "Data Identitas", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        jPanel1.setOpaque(false);

        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("NAMA");

        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("EMAIL");

        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("WEBSITE");

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("ALAMAT");

        textField1.setForeground(new java.awt.Color(255, 255, 255));
        textField1.setHorizontalAlignment(javax.swing.JTextField.LEADING);
        textField1.setText("Eko Kurniawan Khannedy");

        textField2.setForeground(new java.awt.Color(255, 255, 255));
        textField2.setHorizontalAlignment(javax.swing.JTextField.LEADING);
        textField2.setText("echo.khannedy@gmail.com");

        textField3.setForeground(new java.awt.Color(255, 255, 255));
        textField3.setHorizontalAlignment(javax.swing.JTextField.LEADING);
        textField3.setText("http://eecchhoo.wordpress.com/");

        textField4.setForeground(new java.awt.Color(255, 255, 255));
        textField4.setHorizontalAlignment(javax.swing.JTextField.LEADING);
        textField4.setText("Kalijati, Subang");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addGap(27, 27, 27)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(textField4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
                    .addComponent(textField3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
                    .addComponent(textField2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
                    .addComponent(textField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(textField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(textField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(textField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 255, 255), 1, true), "Data Identitas", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        jPanel2.setOpaque(false);

        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("USER");

        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("PASSWORD");

        textField5.setForeground(new java.awt.Color(255, 255, 255));
        textField5.setHorizontalAlignment(javax.swing.JTextField.LEADING);
        textField5.setText("echo");

        password1.setHorizontalAlignment(javax.swing.JTextField.LEADING);
        password1.setText("nesiaoktiana");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(password1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textField5, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(textField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(password1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        button1.setText("SUBMIT");

        button2.setText("RESET");

        javax.swing.GroupLayout panelEfect1Layout = new javax.swing.GroupLayout(panelEfect1);
        panelEfect1.setLayout(panelEfect1Layout);
        panelEfect1Layout.setHorizontalGroup(
            panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelEfect1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 522, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelEfect1Layout.createSequentialGroup()
                        .addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        panelEfect1Layout.setVerticalGroup(
            panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelEfect1Layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(30, Short.MAX_VALUE))
        );

        getContentPane().add(panelEfect1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>                      

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(FormIdentitas.class.getName()).log(Level.SEVERE, null, ex);
                } catch (InstantiationException ex) {
                    Logger.getLogger(FormIdentitas.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IllegalAccessException ex) {
                    Logger.getLogger(FormIdentitas.class.getName()).log(Level.SEVERE, null, ex);
                } catch (UnsupportedLookAndFeelException ex) {
                    Logger.getLogger(FormIdentitas.class.getName()).log(Level.SEVERE, null, ex);
                }
                new FormIdentitas().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                    
    private sample.Button button1;
    private sample.Button button2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private pelajaran3.PanelEfect panelEfect1;
    private sample.Password password1;
    private sample.TextField textField1;
    private sample.TextField textField2;
    private sample.TextField textField3;
    private sample.TextField textField4;
    private sample.TextField textField5;
    // End of variables declaration                  

}

Project Java Swing Makeover (Font Browser)


/*
 * FontBrowser.java
 *
 * Created on 14 Maret 2008, 20:23
 */
package sample;

import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author  usu
 */
public class FontBrowser extends javax.swing.JFrame {

    private DefaultListModel modelFont;
    private DefaultListModel modelStyle;
    private DefaultListModel modelSize;

    /** Creates new form FontBrowser */
    public FontBrowser() {
        modelFont = new DefaultListModel();
        for (String f : GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()) {
            modelFont.addElement(f);
        }

        modelStyle = new DefaultListModel();
        for (String s : ListRender.getStyleFont()) {
            modelStyle.addElement(s);
        }

        modelSize = new DefaultListModel();
        for (int i = 1; i <= 100; i++) {
            modelSize.addElement(i);
        }

        initComponents();

        listFont.setModel(modelFont);
        listFont.setCellRenderer(new ListRender.RenderFont());

        listStyle.setModel(modelStyle);
        listStyle.setCellRenderer(new ListRender.RenderStyle());

        listSize.setModel(modelSize);
        listSize.setCellRenderer(new ListRender.RenderSize());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                        
    private void initComponents() {

        listFont = new javax.swing.JList();
        listStyle = new javax.swing.JList();
        listSize = new javax.swing.JList();
        viewPort21 = new sample.ViewPort2();
        viewPort22 = new sample.ViewPort2();
        viewPort23 = new sample.ViewPort2();
        panelEfect1 = new pelajaran3.PanelEfect();
        jScrollPane1 = new javax.swing.JScrollPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        jScrollPane3 = new javax.swing.JScrollPane();
        labelPreview = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        listFont.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                listFontValueChanged(evt);
            }
        });

        listStyle.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                listStyleValueChanged(evt);
            }
        });

        listSize.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                listSizeValueChanged(evt);
            }
        });

        viewPort21.setView(listFont);

        viewPort22.setView(listStyle);

        viewPort23.setView(listSize);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Font Browser");

        jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jScrollPane1.setOpaque(false);
        jScrollPane1.setViewport(viewPort21);

        jScrollPane2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jScrollPane2.setOpaque(false);
        jScrollPane2.setViewport(viewPort22);

        jScrollPane3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jScrollPane3.setOpaque(false);
        jScrollPane3.setViewport(viewPort23);

        labelPreview.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelPreview.setText("Font Browser By USU");
        labelPreview.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Font Browser By Usu");

        javax.swing.GroupLayout panelEfect1Layout = new javax.swing.GroupLayout(panelEfect1);
        panelEfect1.setLayout(panelEfect1Layout);
        panelEfect1Layout.setHorizontalGroup(
            panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelEfect1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelPreview, javax.swing.GroupLayout.DEFAULT_SIZE, 513, Short.MAX_VALUE)
                    .addGroup(panelEfect1Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 235, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel2))
                .addContainerGap())
        );
        panelEfect1Layout.setVerticalGroup(
            panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelEfect1Layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelEfect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(labelPreview, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        getContentPane().add(panelEfect1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>                      

private void listFontValueChanged(javax.swing.event.ListSelectionEvent evt) {                                    
// TODO add your handling code here:
    if (listFont.getSelectedIndex() < 0) {
        return;
    }
    String family = listFont.getSelectedValue().toString();
    Font f = new Font(family, labelPreview.getFont().getStyle(), labelPreview.getFont().getSize());
    labelPreview.setFont(f);
}                                  

private void listStyleValueChanged(javax.swing.event.ListSelectionEvent evt) {                                    
// TODO add your handling code here:
    if (listStyle.getSelectedIndex() < 0) {
        return;
    }
    String style = listStyle.getSelectedValue().toString();
    if (style.equals("BOLD")) {
        labelPreview.setFont(labelPreview.getFont().deriveFont(Font.BOLD));
    } else if (style.equals("PLAIN")) {
        labelPreview.setFont(labelPreview.getFont().deriveFont(Font.PLAIN));
    } else if (style.equals("ITALIC")) {
        labelPreview.setFont(labelPreview.getFont().deriveFont(Font.ITALIC));
    } else {
        labelPreview.setFont(labelPreview.getFont().deriveFont(Font.BOLD + Font.ITALIC));
    }
}                                    

private void listSizeValueChanged(javax.swing.event.ListSelectionEvent evt) {                                    
// TODO add your handling code here:
    if (listSize.getSelectedIndex() < 0) {
        return;
    }
    float size = Float.valueOf(listSize.getSelectedValue().toString()).floatValue();
    labelPreview.setFont(labelPreview.getFont().deriveFont(size));
}                                  

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(FontBrowser.class.getName()).log(Level.SEVERE, null, ex);
                } catch (InstantiationException ex) {
                    Logger.getLogger(FontBrowser.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IllegalAccessException ex) {
                    Logger.getLogger(FontBrowser.class.getName()).log(Level.SEVERE, null, ex);
                } catch (UnsupportedLookAndFeelException ex) {
                    Logger.getLogger(FontBrowser.class.getName()).log(Level.SEVERE, null, ex);
                }
                new FontBrowser().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                  
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JLabel labelPreview;
    private javax.swing.JList listFont;
    private javax.swing.JList listSize;
    private javax.swing.JList listStyle;
    private pelajaran3.PanelEfect panelEfect1;
    private sample.ViewPort2 viewPort21;
    private sample.ViewPort2 viewPort22;
    private sample.ViewPort2 viewPort23;
    // End of variables declaration                
}

Rabu, 25 April 2012

Pengertian Java Swing Makeover


           Swing Java adalah salah satu pemrograman berbasis GUI(Graphical User Interface) di Java. Sesungguhnya di Java terdapat dua macam pemrograman berbasis GUI(Graphical User Interface) yaitu : AWT dan Swing.

           Namun dalam perkembangannya AWT sudah tidak dianjurkan untuk digunakan dikarenakan faktor keamanan. Banyak sekali fitur yang terdapat di Swing, namun dalam kesempatan ini kita hanya akan mengganti icon saja.


           Walaupun Swing jarang di gunakan di aplikasi desktop base, karena kebanyakan developer lebih memilih menggunakan VB, Delphi ataupun .NET yang lebih ringan dan tidak makan banyak resource memory karena sifatnya yang native.
Namun penggunaan java bisa untuk lintas platform sehingga kita tidak perlu membuat aplikasi dua kali.




Twitter Delicious Facebook Digg Stumbleupon Favorites More