Commits

Anders Lehmann committed 2182fd5

changed name of view code DatePanel. Added EmployeePanel and stubs for HourlyEmployee with test.

Comments (0)

Files changed (5)

src/employees/HourlyEmployee.java

+package employees;
+
+public class HourlyEmployee extends Employee {
+
+	@Override
+	public double earnings() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+}

src/employees/test/HourlyEmployeeTest.java

+package employees.test;
+
+
+import org.junit.Before;
+
+import employees.HourlyEmployee;
+
+public class HourlyEmployeeTest {
+	HourlyEmployee dut;
+	@Before
+	public void setUp() throws Exception {
+		this.dut = new HourlyEmployee();
+	}
+
+}

src/view/DatePanel.java

+package view;
+
+import java.awt.Color;
+import java.awt.GridBagLayout;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import java.awt.GridBagConstraints;
+import javax.swing.JTextField;
+
+import util.Date;
+import util.InvalidDateException;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.Dimension;
+
+public class DatePanel extends JPanel implements ActionListener {
+
+	private static final long serialVersionUID = 1L;
+	private JLabel Day = null;
+	private JLabel Month = null;
+	private JLabel Year = null;
+	private JTextField DayVal = null;
+	private JTextField MonthVal = null;
+	private JTextField YearVal = null;
+	private int day;
+	private int month;
+	private int year;
+	private JLabel ErrorMessage = null;
+
+	public static void main(String[] args){
+		JFrame mainFrame = new JFrame();
+		mainFrame.add(new DatePanel());
+		mainFrame.setSize(300, 200);
+		mainFrame.setVisible(true);
+	}
+	/**
+	 * This is the default constructor
+	 */
+	public DatePanel() {
+		super();
+		initialize();
+	}
+
+	/**
+	 * This method initializes this
+	 * 
+	 * @return void
+	 */
+	private void initialize() {
+		GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
+		gridBagConstraints5.gridx = 1;
+		gridBagConstraints5.gridy = 0;
+		ErrorMessage = new JLabel();
+		ErrorMessage.setForeground(Color.red);
+		ErrorMessage.setText("");
+		GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
+		gridBagConstraints3.fill = GridBagConstraints.VERTICAL;
+		gridBagConstraints3.gridy = 3;
+		gridBagConstraints3.weightx = 1.0;
+		gridBagConstraints3.gridx = 1;
+		GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
+		gridBagConstraints21.fill = GridBagConstraints.VERTICAL;
+		gridBagConstraints21.gridy = 2;
+		gridBagConstraints21.weightx = 1.0;
+		gridBagConstraints21.gridx = 1;
+		GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
+		gridBagConstraints11.fill = GridBagConstraints.VERTICAL;
+		gridBagConstraints11.gridy = 1;
+		gridBagConstraints11.weightx = 1.0;
+		gridBagConstraints11.gridx = 1;
+		GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
+		gridBagConstraints2.gridx = 0;
+		gridBagConstraints2.gridy = 3;
+		Year = new JLabel();
+		Year.setText("�r");
+		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
+		gridBagConstraints1.gridx = 0;
+		gridBagConstraints1.gridy = 2;
+		Month = new JLabel();
+		Month.setText("M�ned");
+		GridBagConstraints gridBagConstraints = new GridBagConstraints();
+		gridBagConstraints.gridx = 0;
+		gridBagConstraints.gridy = 1;
+		Day = new JLabel();
+		Day.setText("Dag");
+		this.setSize(234, 150);
+		this.setLayout(new GridBagLayout());
+		this.add(Day, gridBagConstraints);
+		this.add(Month, gridBagConstraints1);
+		this.add(Year, gridBagConstraints2);
+		this.add(getDayVal(), gridBagConstraints11);
+		this.add(getMonthVal(), gridBagConstraints21);
+		this.add(getYearVal(), gridBagConstraints3);
+		this.add(ErrorMessage, gridBagConstraints5);
+	}
+
+	/**
+	 * This method initializes DayVal	
+	 * 	
+	 * @return javax.swing.JTextField	
+	 */
+	private JTextField getDayVal() {
+		if (DayVal == null) {
+			DayVal = new JTextField();
+			DayVal.setColumns(3);
+			DayVal.addActionListener(this);
+		}
+		return DayVal;
+	}
+
+	/**
+	 * This method initializes MonthVal	
+	 * 	
+	 * @return javax.swing.JTextField	
+	 */
+	private JTextField getMonthVal() {
+		if (MonthVal == null) {
+			MonthVal = new JTextField();
+			MonthVal.setColumns(3);
+			MonthVal.addActionListener(this);
+		}
+		return MonthVal;
+	}
+
+	/**
+	 * This method initializes YearVal	
+	 * 	
+	 * @return javax.swing.JTextField	
+	 */
+	private JTextField getYearVal() {
+		if (YearVal == null) {
+			YearVal = new JTextField();
+			//YearVal.setActionCommand("");
+			YearVal.setColumns(5);
+			YearVal.addActionListener(this);
+		}
+		return YearVal;
+	}
+	public Date getDate(){
+		
+		Date date=null;
+		try {
+			date = new Date(day,month,year);
+		} catch (InvalidDateException e) {
+			// TODO Auto-generated catch block
+			System.out.println(e.getMessage());
+			ErrorMessage.setText(e.getMessage());
+		}
+		return date; 
+		
+	}
+	@Override
+	public void actionPerformed(ActionEvent evt) {
+		// TODO Auto-generated method stub
+		ErrorMessage.setText("");
+		System.out.println("action : "+evt.getActionCommand());
+		int tmp = 0 ;
+		try{
+			tmp = Integer.parseInt(evt.getActionCommand());
+
+			if (evt.getSource() == DayVal){
+				day = tmp;
+			}
+			if (evt.getSource() == MonthVal){
+				month = tmp;
+			}
+			if (evt.getSource() == YearVal){
+				year = tmp;
+			}
+			getDate();
+		}catch (NumberFormatException e) {
+			ErrorMessage.setText("Must be a number");
+		}		
+	}
+
+}  //  @jve:decl-index=0:visual-constraint="9,9"

src/view/DateView.java

-package view;
-
-import java.awt.Color;
-import java.awt.GridBagLayout;
-
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JLabel;
-import java.awt.GridBagConstraints;
-import javax.swing.JTextField;
-
-import util.Date;
-import util.InvalidDateException;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.Dimension;
-
-public class DateView extends JPanel implements ActionListener {
-
-	private static final long serialVersionUID = 1L;
-	private JLabel Day = null;
-	private JLabel Month = null;
-	private JLabel Year = null;
-	private JTextField DayVal = null;
-	private JTextField MonthVal = null;
-	private JTextField YearVal = null;
-	private int day;
-	private int month;
-	private int year;
-	private JLabel ErrorMessage = null;
-
-	public static void main(String[] args){
-		JFrame mainFrame = new JFrame();
-		mainFrame.add(new DateView());
-		mainFrame.setSize(300, 200);
-		mainFrame.setVisible(true);
-	}
-	/**
-	 * This is the default constructor
-	 */
-	public DateView() {
-		super();
-		initialize();
-	}
-
-	/**
-	 * This method initializes this
-	 * 
-	 * @return void
-	 */
-	private void initialize() {
-		GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
-		gridBagConstraints5.gridx = 1;
-		gridBagConstraints5.gridy = 0;
-		ErrorMessage = new JLabel();
-		ErrorMessage.setForeground(Color.red);
-		ErrorMessage.setText("");
-		GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
-		gridBagConstraints3.fill = GridBagConstraints.VERTICAL;
-		gridBagConstraints3.gridy = 3;
-		gridBagConstraints3.weightx = 1.0;
-		gridBagConstraints3.gridx = 1;
-		GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
-		gridBagConstraints21.fill = GridBagConstraints.VERTICAL;
-		gridBagConstraints21.gridy = 2;
-		gridBagConstraints21.weightx = 1.0;
-		gridBagConstraints21.gridx = 1;
-		GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
-		gridBagConstraints11.fill = GridBagConstraints.VERTICAL;
-		gridBagConstraints11.gridy = 1;
-		gridBagConstraints11.weightx = 1.0;
-		gridBagConstraints11.gridx = 1;
-		GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
-		gridBagConstraints2.gridx = 0;
-		gridBagConstraints2.gridy = 3;
-		Year = new JLabel();
-		Year.setText("�r");
-		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
-		gridBagConstraints1.gridx = 0;
-		gridBagConstraints1.gridy = 2;
-		Month = new JLabel();
-		Month.setText("M�ned");
-		GridBagConstraints gridBagConstraints = new GridBagConstraints();
-		gridBagConstraints.gridx = 0;
-		gridBagConstraints.gridy = 1;
-		Day = new JLabel();
-		Day.setText("Dag");
-		this.setSize(234, 150);
-		this.setLayout(new GridBagLayout());
-		this.add(Day, gridBagConstraints);
-		this.add(Month, gridBagConstraints1);
-		this.add(Year, gridBagConstraints2);
-		this.add(getDayVal(), gridBagConstraints11);
-		this.add(getMonthVal(), gridBagConstraints21);
-		this.add(getYearVal(), gridBagConstraints3);
-		this.add(ErrorMessage, gridBagConstraints5);
-	}
-
-	/**
-	 * This method initializes DayVal	
-	 * 	
-	 * @return javax.swing.JTextField	
-	 */
-	private JTextField getDayVal() {
-		if (DayVal == null) {
-			DayVal = new JTextField();
-			DayVal.setColumns(3);
-			DayVal.addActionListener(this);
-		}
-		return DayVal;
-	}
-
-	/**
-	 * This method initializes MonthVal	
-	 * 	
-	 * @return javax.swing.JTextField	
-	 */
-	private JTextField getMonthVal() {
-		if (MonthVal == null) {
-			MonthVal = new JTextField();
-			MonthVal.setColumns(3);
-			MonthVal.addActionListener(this);
-		}
-		return MonthVal;
-	}
-
-	/**
-	 * This method initializes YearVal	
-	 * 	
-	 * @return javax.swing.JTextField	
-	 */
-	private JTextField getYearVal() {
-		if (YearVal == null) {
-			YearVal = new JTextField();
-			//YearVal.setActionCommand("");
-			YearVal.setColumns(5);
-			YearVal.addActionListener(this);
-		}
-		return YearVal;
-	}
-	public Date getDate(){
-		
-		Date date=null;
-		try {
-			date = new Date(day,month,year);
-		} catch (InvalidDateException e) {
-			// TODO Auto-generated catch block
-			System.out.println(e.getMessage());
-			ErrorMessage.setText(e.getMessage());
-		}
-		return date; 
-		
-	}
-	@Override
-	public void actionPerformed(ActionEvent evt) {
-		// TODO Auto-generated method stub
-		ErrorMessage.setText("");
-		System.out.println("action : "+evt.getActionCommand());
-		int tmp = 0 ;
-		try{
-			tmp = Integer.parseInt(evt.getActionCommand());
-
-			if (evt.getSource() == DayVal){
-				day = tmp;
-			}
-			if (evt.getSource() == MonthVal){
-				month = tmp;
-			}
-			if (evt.getSource() == YearVal){
-				year = tmp;
-			}
-			getDate();
-		}catch (NumberFormatException e) {
-			ErrorMessage.setText("Must be a number");
-		}		
-	}
-
-}  //  @jve:decl-index=0:visual-constraint="9,9"

src/view/EmployePanel.java

+package view;
+
+import java.awt.Component;
+import java.awt.GridBagLayout;
+import javax.swing.JPanel;
+import javax.swing.JLabel;
+import java.awt.GridBagConstraints;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JTextField;
+import javax.swing.JSplitPane;
+import java.awt.Dimension;
+import javax.swing.JButton;
+import javax.swing.BoxLayout;
+
+public class EmployePanel extends JPanel implements ActionListener {
+
+	private static final long serialVersionUID = 1L;
+	private JLabel FirstNameLabel = null;
+	private JLabel LastNameLabel = null;
+	private JLabel SSNLabel = null;
+	private JTextField FirstNameVal = null;
+	private JTextField LastNameVal = null;
+	private JTextField SSNVal = null;
+	private DatePanel birthdate;
+	private JPanel namePanel = null;
+	/**
+	 * This is the default constructor
+	 */
+	public EmployePanel() {
+		super();
+		initialize();
+	}
+
+	/**
+	 * This method initializes this
+	 * 
+	 * @return void
+	 */
+	private void initialize() {
+		GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
+		gridBagConstraints5.fill = GridBagConstraints.VERTICAL;
+		gridBagConstraints5.gridy = 2;
+		gridBagConstraints5.weightx = 1.0;
+		gridBagConstraints5.gridx = 1;
+		GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
+		gridBagConstraints4.fill = GridBagConstraints.VERTICAL;
+		gridBagConstraints4.gridy = 1;
+		gridBagConstraints4.weightx = 1.0;
+		gridBagConstraints4.gridx = 1;
+		GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
+		gridBagConstraints3.fill = GridBagConstraints.VERTICAL;
+		gridBagConstraints3.gridy = 0;
+		gridBagConstraints3.weightx = 1.0;
+		gridBagConstraints3.gridx = 1;
+		GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
+		gridBagConstraints2.gridx = 0;
+		gridBagConstraints2.gridy = 2;
+		SSNLabel = new JLabel();
+		SSNLabel.setText("Social Security Number");
+		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
+		gridBagConstraints1.gridx = 0;
+		gridBagConstraints1.gridy = 1;
+		LastNameLabel = new JLabel();
+		LastNameLabel.setText("Lastname");
+		GridBagConstraints gridBagConstraints = new GridBagConstraints();
+		gridBagConstraints.gridx = 0;
+		gridBagConstraints.gridy = 0;
+		FirstNameLabel = new JLabel();
+		FirstNameLabel.setText("Firstname");
+		namePanel = new JPanel();
+		namePanel.setLayout(new GridBagLayout());
+		namePanel.setSize(300, 200);
+		namePanel.setLayout(new GridBagLayout());
+		namePanel.add(FirstNameLabel, gridBagConstraints);
+		namePanel.add(LastNameLabel, gridBagConstraints1);
+		namePanel.add(SSNLabel, gridBagConstraints2);
+		namePanel.add(getFirstNameVal(), gridBagConstraints3);
+		namePanel.add(getLastNameVal(), gridBagConstraints4);
+		namePanel.add(getSSNVal(), gridBagConstraints5);
+		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+		this.setSize(500, 200);
+		this.add(namePanel, null);
+		this.add(getBirthDate(), null);
+	}
+
+	private Component getBirthDate() {
+		if (birthdate == null){
+			birthdate = new DatePanel();
+			
+		}
+		return birthdate;
+	}
+
+	/**
+	 * This method initializes FirstNameVal	
+	 * 	
+	 * @return javax.swing.JTextField	
+	 */
+	private JTextField getFirstNameVal() {
+		if (FirstNameVal == null) {
+			FirstNameVal = new JTextField();
+			FirstNameVal.setColumns(15);
+			FirstNameVal.addActionListener(this);
+		}
+		return FirstNameVal;
+	}
+
+	/**
+	 * This method initializes LastNameVal	
+	 * 	
+	 * @return javax.swing.JTextField	
+	 */
+	private JTextField getLastNameVal() {
+		if (LastNameVal == null) {
+			LastNameVal = new JTextField();
+			LastNameVal.setColumns(15);
+			LastNameVal.addActionListener(this);
+		}
+		return LastNameVal;
+	}
+
+	/**
+	 * This method initializes SSNVal	
+	 * 	
+	 * @return javax.swing.JTextField	
+	 */
+	private JTextField getSSNVal() {
+		if (SSNVal == null) {
+			SSNVal = new JTextField();
+			SSNVal.setColumns(15);
+			SSNVal.addActionListener(this);
+		}
+		return SSNVal;
+	}
+
+	@Override
+	public void actionPerformed(ActionEvent e) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	/**
+	 * This method initializes jPanel	
+	 * 	
+	 * @return javax.swing.JPanel	
+	 */
+	
+
+}  //  @jve:decl-index=0:visual-constraint="73,14"