Closed Thread
Results 1 to 2 of 2

Thread: Creating simple Notition store program

  1. #1
    Coldhearth is offline Learning Programmer
    Join Date
    Oct 2008
    Posts
    88
    Rep Power
    0

    Smile Creating simple Notition store program

    I want to create a simple program that can store notitions(create/edit/view).
    I'm doing this because my OO-thinking isn't what it should be...


    This is what I had come up with from structure:
    NOTITION PROGRAM:
    Program that stores notes. Functions are:
    - creating new notes + storing them
    - editing notes
    - viewing notes (all)

    Storing happens in MySQL database.
    I would like to have a GUI window to do all this.

    StartUp.java (class that starts up the program by creating a new NoteProgram.java object).
    MODEL:
    - note.java (a class that represent a note)

    VIEW:
    - NoteProgram.java (main GUI window that gives the possibility to create/edit/view notes

    CONTROLLER:
    - NoteController.java (controller class for notes)

    I already designed the Note.java class:

    Code:
    package model;
    
    import javax.swing.*;
    
    /*
     * This class represents a note. A note has:
     * - A ID
     * - A title
     * - A author
     * - A content
     * - A date
     */
    public class Note {
    	private int id;
    	private String title;
    	private String author;
    	private String content;
    	private String date;
    	
    	public Note(int id, String title, String author, String content, String date){
    		setId(id);
    		setTitle(title);
    		setAuthor(author);
    		setContent(content);
    		setDate(date);
    	}
    
    	public int getId() {
    		return id;
    	}
    
    	public void setId(int id) {
    		this.id = id;
    	}
    
    	public String getTitle() {
    		return title;
    	}
    
    	public void setTitle(String title) {
    		if(title != ""){
    			this.title = title;			
    		}else{
    			JOptionPane.showMessageDialog(null, "Your title has to be filled in");
    		}
    	}
    
    	public String getAuthor() {
    		return author;
    	}
    
    	public void setAuthor(String author) {
    		this.author = author;
    	}
    
    	public String getContent() {
    		return content;
    	}
    
    	public void setContent(String content) {
    		if(content != ""){
    			this.content = content;			
    		}else{
    			JOptionPane.showMessageDialog(null, "Your content has to be filled in");
    		}
    	}
    
    	public String getDate() {
    		return date;
    	}
    
    	public void setDate(String date) {
    		this.date = date;
    	}
    	
    }
    The GUI (NoteProgram.java) that I have is still just a frame:
    Code:
    package view;
    
    import javax.swing.JFrame;
    
    public class NoteProgram {
    	
    	//Declaration of fields
    	JFrame mainFrame;
    	
    	public NoteProgram(){
    		init();
    	}
    	
    	public void init(){
    		//initialisation of fields for frame of GUI
    		mainFrame = new JFrame("Notition manager");
    		mainFrame.setVisible(true);
    		mainFrame.setLocationRelativeTo(null);
    		mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		mainFrame.setSize(500, 400);
    	}
    }
    And of course the StartUp.java
    Code:
    import view.NoteProgram;
    
    public class StartUp {
    	
    	public static void main(String[] args) {
    		NoteProgram app = new NoteProgram();
    	}
    
    }

    About how to go further I'm a bit doubtfull...
    Anyone can help me out?

    Thanks

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Stu_328 is offline Learning Programmer
    Join Date
    Dec 2008
    Posts
    92
    Rep Power
    12

    Re: Creating simple Notition store program

    You will need a SQL connection class (probably singleton) for connecting to the SQL database. But why dont you have note.java implement Serializable instead?

    I like the idea of Startup.java but what about instead of creating new windows for each note, you create new tabs. So Startup.java is called MainWindow.java and NoteProgram.java is NoteTab.Java which is a swing tab that extends a note object?

    Thats probably a bit cleaner and a bit more OO? I find OOing problems hard so let me know what you think.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Creating A Simple Web Browser.
    By CommittedC0der in forum CSharp Tutorials
    Replies: 44
    Last Post: 12-29-2011, 01:36 AM
  2. Replies: 1
    Last Post: 10-13-2011, 08:52 PM
  3. Replies: 7
    Last Post: 10-08-2010, 05:39 PM
  4. Creating A Simple Compiler: Part 1
    By dargueta in forum C Tutorials
    Replies: 29
    Last Post: 09-21-2010, 08:08 AM
  5. Creating my own simple CMS with PHP and MySQL HELP!
    By Coldhearth in forum PHP Development
    Replies: 13
    Last Post: 11-19-2008, 01:18 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts