Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import java.util.*;
- public class shit {
- public static void main(String[] args){
- SwingUtilities.invokeLater(new Runnable() {
- public void run(){
- JFrame frame = new JFrame("Bitchin!");
- frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- frame.setLayout(new FlowLayout());
- JButton btn = new JButton("Hello, bitches!");
- final JLabel lbl = new JLabel("Hello, bitches!");
- final Random gen = new Random();
- lbl.setOpaque(true);
- ActionListener actionListener = new ActionListener(){
- public void actionPerformed(ActionEvent e){
- Color randomColor = Color.getHSBColor(gen.nextFloat()*360,1.0f, 1f);
- lbl.setBackground(randomColor);
- }
- };
- btn.addActionListener(actionListener);
- frame.add(lbl);
- frame.add(btn);
- frame.pack();
- frame.setVisible(true);
- }
- });
- return;
- };
- }
Add Comment
Please, Sign In to add comment