1 Replies - 1278 Views - Last Post: 16 January 2012 - 01:54 AM Rate Topic: -----

#1 Vampiricx3   User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 85
  • Joined: 01-December 11

GUI

Posted 16 January 2012 - 01:38 AM

Hey guys, I'm here today to ask you a really quick question. I'm trying to improve my Java, slowly but surely I'm getting the hang of it, I created a program (with the help of programmers here), that runs an employee system. It grabs the title based on a number and returns the proper name, can print out to *.txt files, and right now, reads in data from a *.txt file into an array. But now I want to take it a step further, and load it all into a GUI. I have a decent thought that it will be a bit of a challenge for me, but I'm up for it. I'm not asking for people to do this for me, I am just simply asking for people to point out which GUI components I will be needing for my task.
I want my GUI to include..
- A menu bar (Where I will be able to add new objects to the ArrayList file).
- A button for a pop-out frame to show the contents of the ArrayList.
- Possibly a button to delete objects from the ArrayList.
- And any other possible suggest to make a good program for school.

If anyone is willing to help me program this, my entire source code is below, including the ArrayList.txt file.
// Working.java
import java.io.*;

import java.util.*; 



public class Working {



	public Working() {

		String read, fname;
		int counter = 0;

	    //Employee[] employees = new Employee[10];

	    ArrayList<Employee> employees = new ArrayList<Employee>();
		try {

		Scanner s = new Scanner(new File("src/ArrayList.txt"));

			while(s.hasNext()) {

   				int id = s.nextInt();

			        String name = s.next();
				String lname = s.next();

   				int title = s.nextInt();

   				int hireYear = s.nextInt();

   				double salary = s.nextDouble();
					fname = name + " " + lname;
				employees.add(new Employee(id, fname, title, hireYear, salary));
			    counter++;

			}


		} catch(FileNotFoundException e) {

	            System.out.println("There was a problem:" + e);

	        }

	    

	    	/*employees.add(new Employee(1, "Taylah Jayne", 5, 2000, 500000.00));

	    	employees.add(new Employee(2, "Hurp Hurp", 3, 1981, 1000000.00));

	    	employees.add(new Employee(3, "Hurp Durp", 1, 2011, 10000.00));

	    	employees.add(new Employee(4, "4chan l00lz", 2, 2004, 0.00));

	    	employees.add(new Employee(5, "m00t harz", 3, 2004, 200000.00));

	    	employees.add(new Employee(6, "Derpina z0r", 1, 2009, 15000.00));

	    	employees.add(new Employee(7, "Nathan Kreider", 5, 2000, 500000.00));

	    	employees.add(new Employee(8, "Durp Dur", 4, 2000, 50000.00));

	    	employees.add(new Employee(9, "Durp Hurp", 5, 1821, 180912.00));

	    	employees.add(new Employee(10, "Le Durp", 2, 1921, 1920101.00));

	    	employees.add(new Employee(11, "Nathan Kreider", 5, 2000, 500000.00));

	    	employees.add(new Employee(12, "What Durp", 1, 1200, 500000.00));

	    	employees.add(new Employee(13, "Oh No", 1800, 3, 120000.00));

	    	employees.add(new Employee(14, "Waddup Bruh", 1, 2012, 180000.00));

	    	employees.add(new Employee(15, "Jai Mason", 3, 2007, 12000.00));*/

		for(int i = 0; i < counter; i++) {
			employees.get(i).print();
		}

	}



  public static void main(String[] args) {

    new Working();

    }



  public class Employee {

    private int id;

    private String name;

    private int hireYear;

    private double salary;

    private int title;



    public Employee() {

      id = 1;

      name = "Nathan Kreider";

      title = 5;

      hireYear = 2000;

      salary = 50000.00;

    }



    public Employee(int newId, String newName, int newTitle, int newHireYear, double newSalary) {

      id = newId;

      name = newName;

      title = newTitle;

      hireYear = newHireYear;

      salary = newSalary;

    }



    public String getData() {

      return "  [" + id + "] Name: " + name + " | Title: " + getTitle() + " | Hired in: " + hireYear + " | Salary: $" + salary;

    }

    

    public void print() {

    	System.out.println("   [" + id + "] Name: " + name + " | Title: " + getTitle() + " | Hired in: " + hireYear + " | Salary: $" + salary);

    }

    

    public String cOutput() {

    	return id + " " + name + " " + title + " " + hireYear + " " + salary;

    }

    

    public void setHireYear(int hire1) {

	    hireYear = hire1;

	}

	

	public int getHireYear() {

	    return hireYear;

	}

	

	public double getSalary() {

		return salary;

	}

	

	public String getTitle() {

	  String Title = "";

	  

		if(getHireYear() > 2010) {

			Title = "Trainee";

		} if(title == 1) {

			Title = "Trainee";

		} if(title == 2) {

			Title = "Employee";

		} if(title == 3) {

			Title = "Senior";

		} if(title == 4) {

			Title = "Manager";

		} if(title == 5) {

			Title = "Owner";

		}

		

		return Title;

	}

	

	public int getLeTitle() {

		return title;

	}

  }

}


ArrayList.txt
1 Taylah Jayne 5 2000 500000.0
2 Hurp Hurp 3 1981 1000000.0
3 Hurp Durp 1 2011 10000.0
4 4chan l00lz 2 2004 0.0
5 m00t harz 3 2004 200000.0
6 Derpina z0r 1 2009 15000.0
7 Nathan Kreider 5 2000 500000.0
8 Durp Dur 4 2000 50000.0
9 Durp Hurp 5 1821 180912.0
10 Le Durp 2 1921 1920101.0
11 Nathan Kreider 5 2000 500000.0
12 What Durp 1 1200 500000.0
13 Oh No 1800 3 120000.0
14 Waddup Bruh 1 2012 180000.0
15 Jai Mason 3 2007 12000.0


Is This A Good Question/Topic? 0
  • +

Replies To: GUI

#2 DaneAU   User is offline

  • Great::Southern::Land
  • member icon

Reputation: 286
  • View blog
  • Posts: 1,620
  • Joined: 15-May 08

Re: GUI

Posted 16 January 2012 - 01:54 AM

Well in order to get a start i would draw on paper or in some paint app what you intend your graphical user interface to look like. Then start going through some of the tutorials on this site that deal with the development of graphical applications. One introductionary tute can be found here, from this you can go on and implement more tutorials. You will need to understand the general components you are dealing with, JButton, JFrame etc...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1