AÇIKLAMA
Renk paletinden renk seçimi yapılarak javada üretilen bir pencerenin arka planının seçilen renk ile boyanmasına dair bir örnek teşkil eder.NetBeans platformunda geliştirlen proje sayesinde dist klasörü içindeki "RenkGoster.jar" dosyası direk çalıştırılabilir.
Projenin Tamamını Aşağıdaki Linkten İndirebilirsiniz.
Program Kodu:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package renkgoster;
import java.awt.*;
import java.awt.event.ActionEvent;
import javax.swing.*;
import java.awt.event.ActionListener;
/**
*
* @author NEO
*/
public class RenkGoster extends JFrame{
private JButton Button1=new JButton("Rengi Değiştir");
private Color renk=Color.BLUE;
Container konteyner=getContentPane();
public RenkGoster()
{
konteyner.setLayout(new FlowLayout());
Button1.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
renk=JColorChooser.showDialog(RenkGoster.this, "RENK SEÇ",renk);
if(renk==null)
renk=Color.BLUE;
konteyner.setBackground(renk);
}
});
konteyner.add(Button1);
setSize(350,400) ;
setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
RenkGoster renk=new RenkGoster();
renk.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
| Yorumlar |
|
Powered by !JoomlaComment 3.26

