Rabu, 10 November 2010

java class panggil

import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;


public class TestForm extends JFrame {
    JButton btnPanggil = new JButton("Panggil Form lain");
    
    public TestForm() {
   btnPanggil.setMnemonic('P');
     btnPanggil.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent e) {
        Form_kedua b = new Form_kedua(); 
        b.show();
        }
       
        });
     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     this.getContentPane().setLayout(null);
     this.setTitle("Test Memanggil Form lain");
     btnPanggil.setBounds(new Rectangle(90,10,250,20));
     this.getContentPane().add(btnPanggil,null);
     this.setSize(500,200);
     Dimension layar = Toolkit.getDefaultToolkit().getScreenSize();
     int L = (layar.width - this.getSize().width) / 2;
     int T = (layar.height - this.getSize().height) / 2;
     this.setLocation(L,T);
     this.setResizable(false);
     this.setVisible(true);
  }
  
    public static void main(String[] args) {
     TestForm form_satu_awal = new TestForm();
    }
    
}

Tidak ada komentar:

Posting Komentar