Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package eg.edu.alexu.csd.oop.calculator.paint;
- import java.awt.Color;
- import java.awt.EventQueue;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.util.LinkedList;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- public class Paint {
- private final LinkedList<Shape> shapes = new LinkedList<Shape>();
- private JFrame frame;
- Paint() {
- prepareGUI();
- }
- class onClick implements ActionListener {
- @Override
- public void actionPerformed(ActionEvent e) {
- JButton btn = (JButton) e.getSource();
- String s = btn.getText();
- if (s == "Line") {
- shapes.add(new Line());
- }
- }
- }
- private void prepareGUI() {
- frame = new JFrame("Frame");
- frame.setBounds(100, 100, 800, 800);
- frame.getContentPane().setBackground(Color.white);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().setLayout(null);
- JButton btn = new JButton("Line");
- // btn.addActionListener(new onClick());
- btn.setBounds(10, 10, 70, 38);
- frame.add(btn);
- }
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Paint p = new Paint();
- p.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement