Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package vier;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- @SuppressWarnings("serial")
- public class MyFrame extends JFrame implements ActionListener {
- private JButton b1, b2;
- private JLabel l;
- public MyFrame() {
- setLayout(new FlowLayout());
- setVisible(true);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- l = new JLabel("Maak Uw Keuze", JLabel.CENTER);
- l.setForeground(Color.black);
- l.setBackground(Color.white);
- l.setOpaque(true);
- l.setPreferredSize(new Dimension(180, 100));
- l.setFont(new Font("Times New Roman", Font.ITALIC, 20));
- add(l);
- b1 = new JButton("Open");
- add(b1);
- b1.addActionListener(this);
- b2 = new JButton("Gesloten");
- add(b2);
- b2.addActionListener(this);
- setSize(200, 180);
- }
- public void actionPerformed(ActionEvent event) {
- if (event.getSource() == b1) {
- l.setText("Heden Open");
- l.setForeground(Color.blue);
- b1.setEnabled(false);
- b2.setEnabled(true);
- b2.requestFocus();
- }
- if (event.getSource() == b2) {
- l.setText("Morgen Gesloten");
- l.setForeground(Color.red);
- b2.setEnabled(false);
- b1.setEnabled(true);
- b1.requestFocus();
- }
- }
- public static void main(String[] args) {
- new MyFrame();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement