Kladdy

Untitled

Mar 12th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4. import java.applet.*;
  5. import java.awt.Dimension;
  6.  
  7.  
  8.  
  9. public class TryPaint extends Applet implements ActionListener
  10. {
  11.  
  12.     private int Width;
  13.     private int Height;
  14.     private int sizeSet;
  15.    
  16.     TextField docWidth;
  17.      TextField docHeight;
  18.      Button okButton;
  19.  
  20.      public void init()  
  21.      {
  22.          docWidth = new TextField("", 15);
  23.  
  24.          docHeight = new TextField("", 15);
  25.           setLayout(new FlowLayout());
  26.           okButton = new Button("Create new document");
  27.  
  28.  
  29.           add(okButton);
  30.  
  31.           add(docWidth);
  32.           add(docHeight);
  33.          
  34.           okButton.addActionListener(this);
  35.  
  36.          }
  37.  
  38.  
  39.  
  40.  
  41.         public void actionPerformed(ActionEvent evt)  
  42.          {
  43.  
  44.               if (evt.getSource() == okButton) {
  45.                     repaint();
  46.          
  47.               }
  48.  
  49.               }
  50.          
  51.              
  52.               public void paint(Graphics g)
  53.             {
  54.                   this.Width = Integer.parseInt(docWidth.getText());
  55.                   this.Height = Integer.parseInt(docHeight.getText());
  56.                  
  57.                   this.setSize(new Dimension(this.Width, this.Height));
  58.        
  59.          
  60.      }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment