Header Ads

Parsing parameter | Java Netbeans

Berawal dari ingin tau bagaimana caranya supaya kita nginput text dari Frame1 tapi munculnya di Frame yang lain. Akhirnya dapet juga yang ginian, belum sesuai sama keinginan sieh. Tapi setidaknya udah ada bayangan. hehe


Berikut penampakannya....



Berikut Source Codenya....

>> Parent.java

import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
 *
 * @author Jie
 */
public class Parent extends javax.swing.JFrame {

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

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                             Child frm = new Child(this, true);
    //Isi JLabel
    frm.getjLabel1().setText(JTextField.getText());
    frm.setVisible(true);        // TODO add your handling code here:
    }                                       

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

    // Variables declaration - do not modify                    
    private javax.swing.JTextField JTextField;
    private javax.swing.JButton jButton1;
    // End of variables declaration             
}

>> Child.java

import javax.swing.JLabel;

/**
 *
 * @author Jie
 */
public class Child extends javax.swing.JDialog {

    /** Creates new form Child */
    public Child(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
   

    public JLabel getjLabel1(){
    return jLabel1;
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Child dialog = new Child(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }


    // Variables declaration - do not modify                    
    private javax.swing.JLabel jLabel1;
    // End of variables declaration                  
}

>> Pusing ya?? hehe... Sebenernya inti Source Codenya ada disini kok....



Masih pusing juga?? Yawda dehhh download aja Projectnya dimari.... ^^

parsing.rar


No comments

Powered by Blogger.