Skip to content

Instantly share code, notes, and snippets.

@Pompeu
Created September 10, 2014 19:45
Show Gist options
  • Save Pompeu/d99680688945312d8f1f to your computer and use it in GitHub Desktop.
Save Pompeu/d99680688945312d8f1f to your computer and use it in GitHub Desktop.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bntcolorchoise;
import java.awt.Color;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
/**
*
* @author pompeu
*/
public class BntColorChoise extends JFrame {
private final JButton btnAbrir = new JButton("Abrir");
private final JColorChooser pegarCor = new JColorChooser(Color.BLACK);
public BntColorChoise() {
super("Bnt color Choice");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(800,600);
setVisible(true);
setLayout(new GridBagLayout());
add(btnAbrir);
add(pegarCor);
btnAbrir.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
btnAbrir.setBackground(pegarCor.getColor());
}
});
}
public static void main(String[] args) {
new BntColorChoise();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment