Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.applet.*;
- import java.awt.Dimension;
- public class TryPaint extends Applet implements ActionListener
- {
- private int Width;
- private int Height;
- private int sizeSet;
- TextField docWidth;
- TextField docHeight;
- Button okButton;
- public void init()
- {
- docWidth = new TextField("", 15);
- docHeight = new TextField("", 15);
- setLayout(new FlowLayout());
- okButton = new Button("Create new document");
- add(okButton);
- add(docWidth);
- add(docHeight);
- okButton.addActionListener(this);
- }
- public void actionPerformed(ActionEvent evt)
- {
- if (evt.getSource() == okButton) {
- repaint();
- }
- }
- public void paint(Graphics g)
- {
- this.Width = Integer.parseInt(docWidth.getText());
- this.Height = Integer.parseInt(docHeight.getText());
- this.setSize(new Dimension(this.Width, this.Height));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment