Guest User

Untitled

a guest
May 27th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import java.util.*;
  5.  
  6. public class shit {
  7. public static void main(String[] args){
  8. SwingUtilities.invokeLater(new Runnable() {
  9. public void run(){
  10. JFrame frame = new JFrame("Bitchin!");
  11. frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  12. frame.setLayout(new FlowLayout());
  13.  
  14. JButton btn = new JButton("Hello, bitches!");
  15. final JLabel lbl = new JLabel("Hello, bitches!");
  16. final Random gen = new Random();
  17. lbl.setOpaque(true);
  18. ActionListener actionListener = new ActionListener(){
  19. public void actionPerformed(ActionEvent e){
  20. Color randomColor = Color.getHSBColor(gen.nextFloat()*360,1.0f, 1f);
  21. lbl.setBackground(randomColor);
  22. }
  23. };
  24. btn.addActionListener(actionListener);
  25. frame.add(lbl);
  26. frame.add(btn);
  27. frame.pack();
  28. frame.setVisible(true);
  29. }
  30. });
  31. return;
  32. };
  33. }
Add Comment
Please, Sign In to add comment