Netbeans platformunda yapılan proje sayesinde kullanıcıdan alınan sayının okunmasını sağlamaktadır. Dist klasorü içindeki "JavaApplication3.jar" uzantılı dosya çalıştırılarak sistem bağımsız program çalıştırılabilir.
Program ile birlikte farklı iki GridLayout düzeni pencereye aktarılır.
Programın Tamamını Aşağıdaki Linkten İndirebilirsiniz
Linki Görebilmeniz İçin Üye Olmanız Gerekmektedir...
Üye Kayıt
Program Kodu:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication3;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
*
* @author Celal Atalar
*/
public class GridLayoutDuzen extends JFrame implements ActionListener{
private JButton buttons[];
private String names[]={"one","two","three","four","five","six"};
private GridLayout grid1,grid2;
private boolean toggle=true;
private Container pencere;
public GridLayoutDuzen()
{
super("GridLayout Olayı");
grid1=new GridLayout(2,3,5,5);
grid2=new GridLayout(3,2);
pencere=getContentPane();
pencere.setLayout(grid1);
buttons=new JButton[names.length];
for(int count=0;count<names.length;count++)
{
buttons[count]=new JButton(names[count]);
pencere.add(buttons[count]);
buttons[count].addActionListener(this);
}
setSize(350,500);
setVisible(true);
}
public void actionPerformed(ActionEvent event)
{
if(toggle==true)
pencere.setLayout(grid2);
else
pencere.setLayout(grid1);
toggle=!toggle;
pencere.validate();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
GridLayoutDuzen application=new GridLayoutDuzen();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}