Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. package eg.edu.alexu.csd.oop.calculator.paint;
  2.  
  3. import java.awt.Color;
  4. import java.awt.EventQueue;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.util.LinkedList;
  8. import javax.swing.JButton;
  9. import javax.swing.JFrame;
  10.  
  11. public class Paint {
  12. private final LinkedList<Shape> shapes = new LinkedList<Shape>();
  13. private JFrame frame;
  14.  
  15. Paint() {
  16. prepareGUI();
  17. }
  18.  
  19. class onClick implements ActionListener {
  20. @Override
  21. public void actionPerformed(ActionEvent e) {
  22. JButton btn = (JButton) e.getSource();
  23. String s = btn.getText();
  24. if (s == "Line") {
  25. shapes.add(new Line());
  26. }
  27. }
  28. }
  29.  
  30. private void prepareGUI() {
  31. frame = new JFrame("Frame");
  32. frame.setBounds(100, 100, 800, 800);
  33. frame.getContentPane().setBackground(Color.white);
  34. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  35. frame.getContentPane().setLayout(null);
  36. JButton btn = new JButton("Line");
  37. // btn.addActionListener(new onClick());
  38. btn.setBounds(10, 10, 70, 38);
  39. frame.add(btn);
  40. }
  41.  
  42. public static void main(String[] args) {
  43. EventQueue.invokeLater(new Runnable() {
  44. public void run() {
  45. try {
  46. Paint p = new Paint();
  47. p.frame.setVisible(true);
  48. } catch (Exception e) {
  49. e.printStackTrace();
  50. }
  51. }
  52. });
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement