Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- @SuppressWarnings("serial")
- public class Schiff extends Frame implements ActionListener, WindowListener {
- Button b1;
- Button b2;
- Button b3;
- Button b4;
- Label l1;
- Label l2;
- TextField t1;
- public Schiff() {
- this.setLayout( new GridLayout( 3, 3 ) );
- this.addWindowListener( this );
- b1 = new Button( "Hallo Welt" );
- b2 = new Button( "Wie geht es dir" );
- b3 = new Button( "mir ist langweilig" );
- b4 = new Button( "Aendere Aufschrift" );
- l1 = new Label( "Horst hans Peter" );
- l2 = new Label( "Juergen Hans Detlef" );
- t1 = new TextField( 10 );
- this.add( b1 );
- this.add( b2 );
- this.add( b3 );
- this.add( b4 );
- this.add( l1 );
- this.add( l2 );
- this.add( t1 );
- b1.addActionListener( this );
- b2.addActionListener( this );
- b3.addActionListener( this );
- b4.addActionListener( this );
- this.setSize( 650, 400 );
- //this.setLayout( new FlowLayout() );
- this.setVisible( true );
- }
- public void aendereAufschrift( String s ) {
- b1.setLabel( s );
- b2.setLabel( s );
- b3.setLabel( s );
- l1.setText( s );
- l2.setText( s );
- }
- public void actionPerformed(ActionEvent e) {
- if( e.getSource() == b1 ) {
- b1.setVisible( false );
- }
- if( e.getSource() == b2 ) {
- b2.setVisible( false );
- }
- if( e.getSource() == b3 ) {
- b3.setVisible( false );
- System.exit( 0 );
- }
- if( e.getSource() == b4 ) {
- this.aendereAufschrift( t1.getText() );
- }
- }
- public void windowActivated(WindowEvent e) {
- }
- public void windowClosed(WindowEvent e) {
- System.exit( 0 );
- }
- public void windowClosing(WindowEvent e) {
- System.exit( 0 );
- }
- public void windowDeactivated(WindowEvent e) {
- }
- public void windowDeiconified(WindowEvent e) {
- }
- public void windowIconified(WindowEvent e) {
- }
- public void windowOpened(WindowEvent e) {
- }
- }
Add Comment
Please, Sign In to add comment