<repo_name>OOIT2020-2021-IIS-prva-godina/IIS_Grupa2<file_sep>/StartingProjectOOIT/src/geometry/Drawing.java
package geometry;

import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Drawing extends JPanel{
	
	public static void main (String[] args){
		
		JFrame frame= new JFrame("Drawings");
		frame.setSize(800, 600);
		frame.setVisible(true);
		
		Drawing draw=new Drawing();
		frame.getContentPane().add(draw);
	}

	@Override
	public void paint(Graphics g) {
		Point p = new Point(50,50);
		//p.draw(g);
		g.setColor(Color.RED);
		
		Line l1 = new Line(new Point (100,100), new Point (200,200));
		//l1.draw(g);
		
		Rectangle r1 = new Rectangle(l1.getEndPoint(), 100, 50);
		//r1.draw(g);
		
		Circle c1 = new Circle(new Point(500, 100), 80);
		//c1.draw(g);

		g.setColor(Color.GREEN);
		Donut d1 = new Donut(new Point(800, 100), 50, 25);
		//d1.draw(g);

		Rectangle k1 = new Rectangle(new Point(500, 500), 50, 50);
		//k1.draw(g);
		
		int innerR= (int)(k1.getHeight()*Math.sqrt(2)/2);
		Donut d2=new Donut(new Point(k1.getUpperLeftPoint().getX()+k1.getWidth()/2,k1.getUpperLeftPoint().getY()+k1.getWidth()/2), 
				80, innerR);
		//d2.draw(g);
		
		
		//Vezbe 8.
		//Zadatak 1.
		ArrayList<Shape> shapes=new ArrayList<Shape>();
		shapes.add(p);
		shapes.add(l1);
		shapes.add(c1);
		shapes.add(d1);
		shapes.add(k1);
		Iterator<Shape> it=shapes.iterator();
		while(it.hasNext()) {
			it.next().moveBy(10, 0);
		}
		
		//Zadatak 2.
		shapes.get(3).draw(g);

		//prvi nacin
		/*int arrayListLength=0;
		while(it.hasNext()) {
			arrayListLength++;
			it.next();
		}
		shapes.get(arrayListLength-1).draw(g);*/
		//drugi nacin
		shapes.get(shapes.size()-1).draw(g);
		
				
		/*jedan od nacina, ako zelimo da nacrtamo obrisani element
		 * Shape tempShape = shapes.get(1);
		shapes.remove(1);
		tempShape.draw(g);*/		
		//drugi nacin
		shapes.remove(1);
		//pomera se lista
		shapes.get(1).draw(g);

		shapes.get(3).draw(g);

		shapes.add(3, l1);
		
		it=shapes.iterator();
		while(it.hasNext()) {
			Shape pomocniS=it.next();
			if(pomocniS instanceof Circle || pomocniS instanceof Rectangle) {
				pomocniS.draw(g);
			}
		}
		
		//Zadatak 3.
		try {
			c1.setRadius(-10);
			System.out.println("Provera da li se vraca u try blok");
		}catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("Provera da li se nastavlja izvrsenje programa");
		
		
		//Zadatak 4.
		it=shapes.iterator();
		while(it.hasNext()) {
			Shape pomocniS=it.next();
			pomocniS.setSelected(true);
			pomocniS.draw(g);
		}
		
		//Zadatak 5.
		HashMap<String, Shape> hmShapes = new HashMap<String, Shape>();
		hmShapes.put("point", p);
		hmShapes.put("line", l1);
		System.out.println(hmShapes.get("line"));
	}
	
	

}
<file_sep>/StartingProjectOOIT/src/geometry/WBTest.java
package geometry;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;

public class WBTest extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					WBTest frame = new WBTest();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public WBTest() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JPanel panel = new JPanel();
		contentPane.add(panel, BorderLayout.CENTER);
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
		gbl_panel.rowHeights = new int[]{0, 0, 0, 0, 0};
		gbl_panel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		panel.setLayout(gbl_panel);
		
		JLabel lblNewLabel = new JLabel("New label");
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.gridx = 6;
		gbc_lblNewLabel.gridy = 3;
		panel.add(lblNewLabel, gbc_lblNewLabel);
		
		
	}

}
<file_sep>/StartingProjectOOIT/src/geometry/Rectangle.java
package geometry;

import java.awt.Color;
import java.awt.Graphics;

public class Rectangle extends Shape {

	private Point upperLeftPoint;
	private int width;
	private int height;

	public Rectangle() {
	}

	public Rectangle(Point upperLeftPoint, int width, int height) {
		this.upperLeftPoint = upperLeftPoint;
		this.width = width;
		this.height = height;
	}

	public Rectangle(Point upperLeftPoint, int width, int height, boolean selected) {
		this(upperLeftPoint, width, height);

		setSelected(selected);
		// menja se prilikom dodavanja Shape
		// this.selected = selected;
	}

	public int area() {
		return this.width * this.height;
	}

	public int circumference() {
		return 2 * this.width + 2 * this.height;
	}

	public boolean equals(Object obj) {

		if (obj instanceof Rectangle) {

			Rectangle pomocna = (Rectangle) obj;
			if (this.upperLeftPoint.equals(pomocna.upperLeftPoint) && this.width == pomocna.width
					&& this.height == pomocna.height)
				return true;
			else
				return false;
		} else
			return false;

	}

	public boolean contains(int x, int y) {
		if (x >= upperLeftPoint.getX() && x <= upperLeftPoint.getX() + width && y >= upperLeftPoint.getY()
				&& y <= upperLeftPoint.getY() + height)
			return true;
		return false;
	}

	public boolean contains(Point p) {
		if (p.getX() >= upperLeftPoint.getX() && p.getX() <= upperLeftPoint.getX() + width
				&& p.getY() >= upperLeftPoint.getY() && p.getY() <= upperLeftPoint.getY() + height)
			return true;
		return false;
	}

	@Override
	public void draw(Graphics g) {
		g.drawRect(upperLeftPoint.getX(), upperLeftPoint.getY(), width, height);
		
		if(selected) {
			g.setColor(Color.blue);
			g.drawRect(upperLeftPoint.getX() - 2, upperLeftPoint.getY() - 2, 4, 4);
			g.drawRect(upperLeftPoint.getX() + width - 2, upperLeftPoint.getY() - 2, 4, 4);
			g.drawRect(upperLeftPoint.getX() - 2, upperLeftPoint.getY() + height - 2, 4, 4);
			g.drawRect(upperLeftPoint.getX() + width  - 2, upperLeftPoint.getY() + height - 2, 4, 4);
		}
	}

	@Override
	public void moveTo(int x, int y) {
		upperLeftPoint.moveTo(x, y);

	}

	@Override
	public void moveBy(int x, int y) {
		upperLeftPoint.moveBy(x, y);

	}

	@Override
	public int compareTo(Object o) {

		if(o instanceof Rectangle) {
			return this.area()-((Rectangle)o).area();
		}
		return 0;
	}

	public Point getUpperLeftPoint() {
		return upperLeftPoint;
	}

	public void setUpperLeftPoint(Point upperLeftPoint) {
		this.upperLeftPoint = upperLeftPoint;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public String toString() {
		return "Upper left point: " + upperLeftPoint + ", width =" + width + ", height =" + height;
	}

}
<file_sep>/StartingProjectOOIT/src/vezbe11/FrmIgrac.java
package vezbe11;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import gui.DlgTest;

import javax.swing.JLabel;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.JToggleButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JScrollPane;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JCheckBox;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;

public class FrmIgrac extends JFrame {

	private JPanel contentPane;
	private final ButtonGroup buttonGroup = new ButtonGroup();
	private DefaultListModel<String> dlmIgraci=new DefaultListModel<String>();
	private JLabel lblMatic;
	private JLabel lblIvanovic;
	private JLabel lblKolarov;
	private JTextField txtUnetiIgrac;


	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					FrmIgrac frame = new FrmIgrac();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public FrmIgrac() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 550, 400);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		contentPane.setBackground(new Color(220, 20, 60));
		setTitle("Igraci");
		
		JPanel pnlCenter = new JPanel();
		pnlCenter.setBackground(Color.YELLOW);
		pnlCenter.setSize(150,100);
		contentPane.add(pnlCenter, BorderLayout.CENTER);
		GridBagLayout gbl_pnlCenter = new GridBagLayout();
		gbl_pnlCenter.columnWidths = new int[]{116, 0, 0, 0};
		gbl_pnlCenter.rowHeights = new int[]{0, 0, 32, 0, 0, 0, 0};
		gbl_pnlCenter.columnWeights = new double[]{0.0, 1.0, 1.0, Double.MIN_VALUE};
		gbl_pnlCenter.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
		pnlCenter.setLayout(gbl_pnlCenter);
		
		lblKolarov = new JLabel("<NAME>");
		GridBagConstraints gbc_lblKolarov = new GridBagConstraints();
		gbc_lblKolarov.anchor = GridBagConstraints.EAST;
		gbc_lblKolarov.insets = new Insets(0, 0, 5, 5);
		gbc_lblKolarov.gridx = 0;
		gbc_lblKolarov.gridy = 0;
		pnlCenter.add(lblKolarov, gbc_lblKolarov);
		
		JToggleButton tglbtnKolarov = new JToggleButton("Kolarov");
		tglbtnKolarov.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dlmIgraci.addElement(lblKolarov.getText());
				if (tglbtnKolarov.isSelected()) {
					lblIvanovic.setForeground(Color.black);
					lblKolarov.setForeground(Color.blue);
					lblMatic.setForeground(Color.black);
				}
			}
		});
		buttonGroup.add(tglbtnKolarov);
		GridBagConstraints gbc_tglbtnKolarov = new GridBagConstraints();
		gbc_tglbtnKolarov.insets = new Insets(0, 0, 5, 5);
		gbc_tglbtnKolarov.gridx = 1;
		gbc_tglbtnKolarov.gridy = 0;
		pnlCenter.add(tglbtnKolarov, gbc_tglbtnKolarov);
		tglbtnKolarov.setPreferredSize(new Dimension(100,25));
		
		lblMatic = new JLabel("Nemanja Matic");
		GridBagConstraints gbc_lblMatic = new GridBagConstraints();
		gbc_lblMatic.anchor = GridBagConstraints.EAST;
		gbc_lblMatic.insets = new Insets(0, 0, 5, 5);
		gbc_lblMatic.gridx = 0;
		gbc_lblMatic.gridy = 1;
		pnlCenter.add(lblMatic, gbc_lblMatic);
		
		JToggleButton tglbtnMatic = new JToggleButton("Matic");
		tglbtnMatic.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dlmIgraci.addElement(lblMatic.getText());
				if (tglbtnMatic.isSelected()) {
					lblIvanovic.setForeground(Color.black);
					lblKolarov.setForeground(Color.black);
					lblMatic.setForeground(Color.blue);
				}
			}
		});
		buttonGroup.add(tglbtnMatic);
		GridBagConstraints gbc_tglbtnMatic = new GridBagConstraints();
		gbc_tglbtnMatic.insets = new Insets(0, 0, 5, 5);
		gbc_tglbtnMatic.gridx = 1;
		gbc_tglbtnMatic.gridy = 1;
		pnlCenter.add(tglbtnMatic, gbc_tglbtnMatic);
		tglbtnMatic.setPreferredSize(new Dimension(100,25));
		
		lblIvanovic = new JLabel("<NAME>");
		GridBagConstraints gbc_lblIvanovic = new GridBagConstraints();
		gbc_lblIvanovic.anchor = GridBagConstraints.EAST;
		gbc_lblIvanovic.insets = new Insets(0, 0, 5, 5);
		gbc_lblIvanovic.gridx = 0;
		gbc_lblIvanovic.gridy = 2;
		pnlCenter.add(lblIvanovic, gbc_lblIvanovic);
		
		JToggleButton tglbtnIvanovic = new JToggleButton("Ivanovic");
		tglbtnIvanovic.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dlmIgraci.addElement(lblIvanovic.getText());
				
				if (tglbtnIvanovic.isSelected()) {
					lblIvanovic.setForeground(Color.blue);
					lblKolarov.setForeground(Color.black);
					lblMatic.setForeground(Color.black);
				}
			}
		});
		buttonGroup.add(tglbtnIvanovic);
		GridBagConstraints gbc_tglbtnIvanovic = new GridBagConstraints();
		gbc_tglbtnIvanovic.insets = new Insets(0, 0, 5, 5);
		gbc_tglbtnIvanovic.gridx = 1;
		gbc_tglbtnIvanovic.gridy = 2;
		pnlCenter.add(tglbtnIvanovic, gbc_tglbtnIvanovic);
		tglbtnIvanovic.setPreferredSize(new Dimension(100,25));
		
		JCheckBox chckbxUnesiIgraca = new JCheckBox("Unesi igraca");
		chckbxUnesiIgraca.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if (chckbxUnesiIgraca.isSelected()) {
					txtUnetiIgrac.setEnabled(true);
				}else {
					txtUnetiIgrac.setText("");
					txtUnetiIgrac.setEnabled(false);
				}
			}
		});
		chckbxUnesiIgraca.setBackground(new Color(255, 255, 0));
		GridBagConstraints gbc_chckbxUnesiIgraca = new GridBagConstraints();
		gbc_chckbxUnesiIgraca.anchor = GridBagConstraints.EAST;
		gbc_chckbxUnesiIgraca.insets = new Insets(0, 0, 5, 5);
		gbc_chckbxUnesiIgraca.gridx = 0;
		gbc_chckbxUnesiIgraca.gridy = 3;
		pnlCenter.add(chckbxUnesiIgraca, gbc_chckbxUnesiIgraca);
		
		txtUnetiIgrac = new JTextField();
		txtUnetiIgrac.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				if(e.getKeyCode() == KeyEvent.VK_ENTER) {
					dlmIgraci.addElement(txtUnetiIgrac.getText());
					txtUnetiIgrac.setText("");
				}
			}
		});
		txtUnetiIgrac.setEnabled(false);
		GridBagConstraints gbc_txtUnetiIgrac = new GridBagConstraints();
		gbc_txtUnetiIgrac.insets = new Insets(0, 0, 5, 5);
		gbc_txtUnetiIgrac.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtUnetiIgrac.gridx = 1;
		gbc_txtUnetiIgrac.gridy = 3;
		pnlCenter.add(txtUnetiIgrac, gbc_txtUnetiIgrac);
		txtUnetiIgrac.setColumns(10);
		
		JLabel lblIgraci = new JLabel("Igraci:");
		GridBagConstraints gbc_lblIgraci = new GridBagConstraints();
		gbc_lblIgraci.anchor = GridBagConstraints.EAST;
		gbc_lblIgraci.insets = new Insets(0, 0, 5, 5);
		gbc_lblIgraci.gridx = 0;
		gbc_lblIgraci.gridy = 4;
		pnlCenter.add(lblIgraci, gbc_lblIgraci);
		
		JComboBox<String> cbxIgraci = new JComboBox<String> ();
		cbxIgraci.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dlmIgraci.addElement(cbxIgraci.getSelectedItem().toString());
			}
		});
		cbxIgraci.setModel(new DefaultComboBoxModel<String> (new String[] {"Kolarov", "Matic", "Ivanovic", "Nikolic", "Peric", "Markovic"}));
		GridBagConstraints gbc_cbxIgraci = new GridBagConstraints();
		gbc_cbxIgraci.insets = new Insets(0, 0, 5, 5);
		gbc_cbxIgraci.fill = GridBagConstraints.HORIZONTAL;
		gbc_cbxIgraci.gridx = 1;
		gbc_cbxIgraci.gridy = 4;
		pnlCenter.add(cbxIgraci, gbc_cbxIgraci);
		
		JScrollPane scrollPane = new JScrollPane();
		GridBagConstraints gbc_scrollPane = new GridBagConstraints();
		gbc_scrollPane.fill = GridBagConstraints.BOTH;
		gbc_scrollPane.gridx = 2;
		gbc_scrollPane.gridy = 5;
		pnlCenter.add(scrollPane, gbc_scrollPane);
		
		JList<String> lstIgraci = new JList<String>();
		scrollPane.setViewportView(lstIgraci);
		lstIgraci.setModel(dlmIgraci);
		
		JPanel pnlNorth = new JPanel();
		pnlNorth.setBackground(new Color(220, 20, 60));
		contentPane.add(pnlNorth, BorderLayout.NORTH);
		
		JLabel lblNaslov = new JLabel("Forma za unos igraca");
		pnlNorth.add(lblNaslov);
		lblNaslov.setForeground(Color.white);
		
		JPanel pnlSouth = new JPanel();
		pnlSouth.setBackground(new Color(220, 20, 60));
		contentPane.add(pnlSouth, BorderLayout.SOUTH);
		
		JButton btnDodajIgraca = new JButton("Dodaj igraca");
		btnDodajIgraca.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				DlgIgrac dlgIgrac=new DlgIgrac(); 
				dlgIgrac.setVisible(true);
				
				if(dlgIgrac.isOk) {
					dlmIgraci.addElement(dlgIgrac.txtIme.getText()+" "+dlgIgrac.txtPrezime.getText());
				}
			}
		});
		pnlSouth.add(btnDodajIgraca);
		
		JButton btnModifikujIgraca = new JButton("Modifikuj igraca");
		btnModifikujIgraca.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				DlgIgrac dlgIzmena = new DlgIgrac();
				try {
					String[] split = dlmIgraci.getElementAt(lstIgraci.getSelectedIndex()).toString().split(" ");
					dlgIzmena.txtIme.setText(split[0]);
					dlgIzmena.txtPrezime.setText(split[1]);
					dlgIzmena.setVisible(true);
					if (dlgIzmena.isOk) {
						int index = lstIgraci.getSelectedIndex();
						dlmIgraci.removeElementAt(index);
						dlmIgraci.add(index,dlgIzmena.txtIme.getText() + " " + dlgIzmena.txtPrezime.getText());		
				
					}
				}  catch (Exception ex) {
					JOptionPane.showMessageDialog(null, "Morate selektovati igraca kojem je uneto i ime i prezime");
				}
			}
		});
		pnlSouth.add(btnModifikujIgraca);
		
	}

}
<file_sep>/StartingProjectOOIT/src/gui/FrmTest.java
package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.GridBagLayout;
import javax.swing.JToggleButton;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JList;
import javax.swing.JOptionPane;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import java.awt.FlowLayout;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTextField;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class FrmTest extends JFrame {

	private JPanel contentPane;
	private final ButtonGroup prvaButtonGrupa = new ButtonGroup();
	private DefaultListModel<String> dlmBoje = new DefaultListModel<String>();
	private JLabel lblCrvena;
	private JLabel lblPlava;
	private JLabel lblZuta;
	private JTextField txtUnesiBoju;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					FrmTest frame = new FrmTest();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public FrmTest() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 639, 417);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);

		// centralni panel
		JPanel pnlCenter = new JPanel();
		contentPane.add(pnlCenter, BorderLayout.CENTER);
		GridBagLayout gbl_pnlCenter = new GridBagLayout();
		gbl_pnlCenter.columnWidths = new int[] { 0, 0, 0, 0, 0, 0 };
		gbl_pnlCenter.rowHeights = new int[] { 33, 0, 0, 0, 0, 0, 0 };
		gbl_pnlCenter.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
		gbl_pnlCenter.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
		pnlCenter.setLayout(gbl_pnlCenter);

		JToggleButton tglbtnCrvena = new JToggleButton("Crvena boja");
		tglbtnCrvena.setPreferredSize(new Dimension(120, 25));
		tglbtnCrvena.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dlmBoje.addElement(lblCrvena.getText());

				if (tglbtnCrvena.isSelected()) {
					lblZuta.setForeground(Color.black);
					lblPlava.setForeground(Color.black);
					lblCrvena.setForeground(Color.red);
				}
			}
		});

		JLabel lblIzaberiBoju = new JLabel("Izaberi boju:");
		GridBagConstraints gbc_lblIzaberiBoju = new GridBagConstraints();
		gbc_lblIzaberiBoju.anchor = GridBagConstraints.EAST;
		gbc_lblIzaberiBoju.insets = new Insets(0, 0, 5, 5);
		gbc_lblIzaberiBoju.gridx = 3;
		gbc_lblIzaberiBoju.gridy = 0;
		pnlCenter.add(lblIzaberiBoju, gbc_lblIzaberiBoju);

		JComboBox<String> cbxIzaberiBoju = new JComboBox<String>();
		cbxIzaberiBoju.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dlmBoje.addElement(cbxIzaberiBoju.getSelectedItem().toString());

				switch (cbxIzaberiBoju.getSelectedItem().toString()) {
				case "Zelena":
					lblIzaberiBoju.setForeground(Color.green);
					break;
				case "Narandzasta":
					lblIzaberiBoju.setForeground(Color.orange);
					break;
				case "Ljubicasta":
					lblIzaberiBoju.setForeground(Color.magenta);
					break;
				}
			}
		});
		cbxIzaberiBoju
				.setModel(new DefaultComboBoxModel<String>(new String[] { "Zelena", "Narandzasta", "Ljubicasta" }));
		GridBagConstraints gbc_cbxIzaberiBoju = new GridBagConstraints();
		gbc_cbxIzaberiBoju.insets = new Insets(0, 0, 5, 0);
		gbc_cbxIzaberiBoju.fill = GridBagConstraints.HORIZONTAL;
		gbc_cbxIzaberiBoju.gridx = 4;
		gbc_cbxIzaberiBoju.gridy = 0;
		pnlCenter.add(cbxIzaberiBoju, gbc_cbxIzaberiBoju);
		
		JLabel lblUnesiBoju = new JLabel("Unesi boju:");
		GridBagConstraints gbc_lblUnesiBoju = new GridBagConstraints();
		gbc_lblUnesiBoju.anchor = GridBagConstraints.EAST;
		gbc_lblUnesiBoju.insets = new Insets(0, 0, 5, 5);
		gbc_lblUnesiBoju.gridx = 3;
		gbc_lblUnesiBoju.gridy = 1;
		pnlCenter.add(lblUnesiBoju, gbc_lblUnesiBoju);
		
		txtUnesiBoju = new JTextField();
		txtUnesiBoju.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				if(e.getKeyCode()==KeyEvent.VK_ENTER) {
					dlmBoje.addElement(txtUnesiBoju.getText());
					txtUnesiBoju.setText("");
				}
			}
		});
		GridBagConstraints gbc_txtUnesiBoju = new GridBagConstraints();
		gbc_txtUnesiBoju.insets = new Insets(0, 0, 5, 0);
		gbc_txtUnesiBoju.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtUnesiBoju.gridx = 4;
		gbc_txtUnesiBoju.gridy = 1;
		pnlCenter.add(txtUnesiBoju, gbc_txtUnesiBoju);
		txtUnesiBoju.setColumns(10);

		prvaButtonGrupa.add(tglbtnCrvena);
		GridBagConstraints gbc_tglbtnCrvena = new GridBagConstraints();
		gbc_tglbtnCrvena.insets = new Insets(0, 0, 5, 5);
		gbc_tglbtnCrvena.gridx = 0;
		gbc_tglbtnCrvena.gridy = 2;
		pnlCenter.add(tglbtnCrvena, gbc_tglbtnCrvena);

		lblCrvena = new JLabel("Crvena");
		GridBagConstraints gbc_lblCrvena = new GridBagConstraints();
		gbc_lblCrvena.anchor = GridBagConstraints.WEST;
		gbc_lblCrvena.insets = new Insets(0, 0, 5, 5);
		gbc_lblCrvena.gridx = 1;
		gbc_lblCrvena.gridy = 2;
		pnlCenter.add(lblCrvena, gbc_lblCrvena);

		JToggleButton tglbtnPlava = new JToggleButton("Plava boja");
		tglbtnPlava.setPreferredSize(new Dimension(120, 25));
		tglbtnPlava.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dlmBoje.addElement(lblPlava.getText());

				if (tglbtnPlava.isSelected()) {
					lblZuta.setForeground(Color.black);
					lblPlava.setForeground(Color.red);
					lblCrvena.setForeground(Color.black);
				}
			}
		});

		prvaButtonGrupa.add(tglbtnPlava);
		GridBagConstraints gbc_tglbtnPlava = new GridBagConstraints();
		gbc_tglbtnPlava.insets = new Insets(0, 0, 5, 5);
		gbc_tglbtnPlava.gridx = 0;
		gbc_tglbtnPlava.gridy = 3;
		pnlCenter.add(tglbtnPlava, gbc_tglbtnPlava);

		lblPlava = new JLabel("Plava");
		GridBagConstraints gbc_lblPlava = new GridBagConstraints();
		gbc_lblPlava.anchor = GridBagConstraints.WEST;
		gbc_lblPlava.insets = new Insets(0, 0, 5, 5);
		gbc_lblPlava.gridx = 1;
		gbc_lblPlava.gridy = 3;
		pnlCenter.add(lblPlava, gbc_lblPlava);

		JToggleButton tglbtnZuta = new JToggleButton("Zuta boja");
		tglbtnZuta.setPreferredSize(new Dimension(120, 25));
		tglbtnZuta.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dlmBoje.addElement(lblZuta.getText());

				if (tglbtnZuta.isSelected()) {
					lblZuta.setForeground(Color.red);
					lblPlava.setForeground(Color.black);
					lblCrvena.setForeground(Color.black);
				}
			}
		});
		prvaButtonGrupa.add(tglbtnZuta);
		GridBagConstraints gbc_tglbtnZuta = new GridBagConstraints();
		gbc_tglbtnZuta.insets = new Insets(0, 0, 5, 5);
		gbc_tglbtnZuta.gridx = 0;
		gbc_tglbtnZuta.gridy = 4;
		pnlCenter.add(tglbtnZuta, gbc_tglbtnZuta);

		lblZuta = new JLabel("Zuta");
		GridBagConstraints gbc_lblZuta = new GridBagConstraints();
		gbc_lblZuta.insets = new Insets(0, 0, 5, 5);
		gbc_lblZuta.anchor = GridBagConstraints.WEST;
		gbc_lblZuta.gridx = 1;
		gbc_lblZuta.gridy = 4;
		pnlCenter.add(lblZuta, gbc_lblZuta);

		// scroll i lista
		JScrollPane scrollPaneBoje = new JScrollPane();
		GridBagConstraints gbc_scrollPaneBoje = new GridBagConstraints();
		gbc_scrollPaneBoje.fill = GridBagConstraints.BOTH;
		gbc_scrollPaneBoje.gridx = 4;
		gbc_scrollPaneBoje.gridy = 5;
		pnlCenter.add(scrollPaneBoje, gbc_scrollPaneBoje);

		JList lstBoje = new JList();
		scrollPaneBoje.setViewportView(lstBoje);
		lstBoje.setModel(dlmBoje);

		// gornji panel
		JPanel pnlSouth = new JPanel();
		contentPane.add(pnlSouth, BorderLayout.SOUTH);

		JButton btnIspis = new JButton("Klikni me");
		btnIspis.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(null, "Ovo je antistres dugme :)", "Poruka",
						JOptionPane.INFORMATION_MESSAGE);
			}
		});
		pnlSouth.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		pnlSouth.add(btnIspis);
		
		JButton btnDodajBoju = new JButton("RGB");
		btnDodajBoju.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				DlgTest dlgUnos=new DlgTest();
				dlgUnos.setVisible(true);
				
				if(dlgUnos.isOk) {
					dlmBoje.addElement(dlgUnos.txtCrvena.getText()+" "+dlgUnos.txtZelena.getText()+" "+dlgUnos.txtPlava.getText());
					pnlCenter.setBackground(new Color(Integer.parseInt(dlgUnos.txtCrvena.getText()),
							Integer.parseInt(dlgUnos.txtZelena.getText()), Integer.parseInt(dlgUnos.txtPlava.getText())));
					
				}
			}
		});
		pnlSouth.add(btnDodajBoju);
		
		JButton btnPromeniRGB = new JButton("Promeni RGB");
		btnPromeniRGB.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				DlgTest dlgPromena=new DlgTest();
				
				try {
				String[] split = dlmBoje.getElementAt(lstBoje.getSelectedIndex()).split(" ");
				dlgPromena.txtCrvena.setText(split[0]);
				dlgPromena.txtZelena.setText(split[1]);
				dlgPromena.txtPlava.setText(split[2]);
				dlgPromena.setVisible(true);
				
				if(dlgPromena.isOk) {
					dlmBoje.removeElementAt(lstBoje.getSelectedIndex());
					dlmBoje.addElement(dlgPromena.txtCrvena.getText()+" "+dlgPromena.txtZelena.getText()+" "+dlgPromena.txtPlava.getText());
					pnlCenter.setBackground(new Color(Integer.parseInt(dlgPromena.txtCrvena.getText()),
							Integer.parseInt(dlgPromena.txtZelena.getText()), Integer.parseInt(dlgPromena.txtPlava.getText())));
					
				}
				
				}catch(Exception ex) {
					JOptionPane.showMessageDialog(null, "Morate selektovati adekvatnu boju");
				}
				
				
			}
		});
		pnlSouth.add(btnPromeniRGB);

		// donji panel
		JPanel pnlNorth = new JPanel();
		contentPane.add(pnlNorth, BorderLayout.NORTH);
		pnlNorth.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

		JLabel lblNaziv = new JLabel("Zadatak 1");
		lblNaziv.setHorizontalAlignment(SwingConstants.CENTER);
		pnlNorth.add(lblNaziv);
		pnlNorth.setBackground(Color.green);
	}

}
<file_sep>/StartingProjectOOIT/src/geometry/Circle.java
package geometry;

import java.awt.Color;
import java.awt.Graphics;

public class Circle extends Shape{

	protected Point center;
	private int radius;
	
	public Circle() {

	}

	public Circle(Point center, int radius) {
		this.center = center;
		this.radius = radius;
	}

	public Circle(Point center, int radius, boolean selected) {
		this(center, radius);
		
		setSelected(selected);
		//menja se prilikom dodavanja Shape
		//this.selected = selected;
	}
	
	public double area() {
		return this.radius * this.radius * Math.PI;
	}

	public double circumference() {
		return 2 * this.radius * Math.PI;
	}
	
	public boolean equals(Object obj) {
		if (obj instanceof Circle) {
			Circle pomocni = (Circle) obj;
			if (this.center.equals(pomocni.center) &&
					this.radius == pomocni.radius) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	}
	
	public boolean contains (int x, int y) {
		return center.distance(x, y) <= radius;
	}
	
	public boolean contains (Point p) {
		return center.distance(p.getX(), p.getY()) <= radius;
	}
	
	

	@Override
	public void draw(Graphics g) {
		g.drawOval(center.getX()-radius,center.getY()-radius, radius*2, radius*2);
		
		if (selected) {
			g.setColor(Color.BLUE);
			g.drawRect(center.getX() - 2, center.getY() - 2, 4, 4);
			g.drawRect(center.getX() - radius - 2, center.getY() - 2, 4, 4);
			g.drawRect(center.getX() + radius - 2, center.getY() - 2, 4, 4);
			g.drawRect(center.getX() - 2, center.getY() - radius - 2, 4, 4);
			g.drawRect(center.getX() - 2, center.getY() + radius - 2, 4, 4);
		}
	}
	
	@Override
	public void moveTo(int x, int y) {
		center.moveTo(x, y);
		
	}

	@Override
	public void moveBy(int x, int y) {
		center.moveBy(x, y);
		
	}
	
	@Override
	public int compareTo(Object o) {

		if(o instanceof Circle) {
			return (int)(this.area()-((Circle)o).area());
		}
		return 0;
	}

	public Point getCenter() {
		return center;
	}

	public void setCenter(Point center) {
		this.center = center;
	}

	public int getRadius() {
		return radius;
	}

	public void setRadius(int radius) throws Exception{
		if(radius<0) {
			throw new Exception("Vrednost poluprecnika mora biti veci od 0");
		}
		System.out.println("Provera da li se ova naredba izvrsava ukoliko dodje do izuzetka");
		this.radius = radius;
	}

	
	public String toString() {
		// Center=(x,y), radius= radius
		return "Center=" + center + ", radius=" + radius;
	}

}
