Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. package vier;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5.  
  6. import javax.swing.*;
  7.  
  8. @SuppressWarnings("serial")
  9. public class MyFrame extends JFrame implements ActionListener {
  10. private JButton b1, b2;
  11. private JLabel l;
  12.  
  13. public MyFrame() {
  14. setLayout(new FlowLayout());
  15. setVisible(true);
  16. setDefaultCloseOperation(EXIT_ON_CLOSE);
  17. l = new JLabel("Maak Uw Keuze", JLabel.CENTER);
  18. l.setForeground(Color.black);
  19. l.setBackground(Color.white);
  20. l.setOpaque(true);
  21. l.setPreferredSize(new Dimension(180, 100));
  22. l.setFont(new Font("Times New Roman", Font.ITALIC, 20));
  23. add(l);
  24. b1 = new JButton("Open");
  25. add(b1);
  26. b1.addActionListener(this);
  27. b2 = new JButton("Gesloten");
  28. add(b2);
  29. b2.addActionListener(this);
  30. setSize(200, 180);
  31. }
  32.  
  33. public void actionPerformed(ActionEvent event) {
  34. if (event.getSource() == b1) {
  35. l.setText("Heden Open");
  36. l.setForeground(Color.blue);
  37. b1.setEnabled(false);
  38. b2.setEnabled(true);
  39. b2.requestFocus();
  40. }
  41. if (event.getSource() == b2) {
  42. l.setText("Morgen Gesloten");
  43. l.setForeground(Color.red);
  44. b2.setEnabled(false);
  45. b1.setEnabled(true);
  46. b1.requestFocus();
  47. }
  48. }
  49.  
  50. public static void main(String[] args) {
  51. new MyFrame();
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement