• (3 Pages)
  • +
  • 1
  • 2
  • 3

Creating a basic Notepad Application Rate Topic: ***** 5 Votes

#16 tivrfoa  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 9
  • View blog
  • Posts: 98
  • Joined: 25-January 09

Posted 06 February 2009 - 11:41 AM

hello gabehabe!

very nice tutorial!!!

I wanted to change the title when the user saves a file, so I did this:

created a static variable: private static Notepad app;
added this in the save event: app.setTitle(save.getSelectedFile().getName() + " - Notepad");
and this in the main: app = new Notepad();


do you know a better way to do this?

thanks
Was This Post Helpful? 0
  • +
  • -

#17 5thWall  Icon User is offline

  • Occasional Member

Reputation: 31
  • View blog
  • Posts: 529
  • Joined: 17-September 08

Posted 19 February 2009 - 10:37 PM

View Postjoezim007, on 24 Jan, 2009 - 11:49 AM, said:

I was wondering if you had any reasons for using TextArea, MenuBar, Menu, and MenuItem over the JTextArea, JMenuBar, JMenu, and JMenuItem alternatives? Are there any downsides to the J components?


If I recall correctly, the AWT components (no J prefix) use the operating system's built-in functions to draw components. So if you use those they will mesh with whatever operating system the code is run on. The Swing (J prefix) components, on the other hand, are all native Java components. So your application will look consistent between operating systems.

Swing is newer than AWT, but I don't know if Sun has stopped updating the AWT components.

This post has been edited by 5thWall: 19 February 2009 - 10:38 PM

Was This Post Helpful? 0
  • +
  • -

#18 makarei  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-April 09

Posted 16 April 2009 - 04:44 PM

I'm new to java, anyway i really liked this tutorial, and found it very straight forward, had no issues at all - after reading the follow up comments. anyways i was wondering is it possible to add a spell checker to the notepad app?

This post has been edited by makarei: 16 April 2009 - 04:45 PM

Was This Post Helpful? 0
  • +
  • -

#19 EnvXOwner  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 357
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Posted 10 April 2010 - 06:33 PM

View Postmakarei, on 16 April 2009 - 05:44 PM, said:

I'm new to java, anyway i really liked this tutorial, and found it very straight forward, had no issues at all - after reading the follow up comments. anyways i was wondering is it possible to add a spell checker to the notepad app?

If I were you I would look on Youtube, Google, and the Java snippets of the website.
Was This Post Helpful? 1
  • +
  • -

#20 muaaz007  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 16-June 10

Posted 16 June 2010 - 05:22 AM

Thanks man very Helpful tutorial. How do you create Font List and copy/cut/paste in menu bar.
Was This Post Helpful? 0
  • +
  • -

#21 Guest_andrew*


Reputation:

Posted 20 August 2010 - 03:13 AM

hi, do you guys have an idea to make find and replace menu?
I just learn java this morning and had an assignment like this, im kinda lost
Was This Post Helpful? 0

#22 jumptrooper  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 68
  • View blog
  • Posts: 234
  • Joined: 19-August 10

Posted 20 August 2010 - 01:49 PM

Very nice demonstration! This looks really good.
Was This Post Helpful? 0
  • +
  • -

#23 jumptrooper  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 68
  • View blog
  • Posts: 234
  • Joined: 19-August 10

Posted 22 August 2010 - 07:32 PM

I went through and coded this tutorial and like I said before, you did a great job. I did, however, find something interesting and I'm wondering if you might be able to explain it for me.
Whenever I exited the program using the "close" menu item, the window would disappear but the process would continue to run. I kept having to manually terminate the program from the command line. I modified the relevant portion of the event handler to say:
// if the source of the event was our "close" option
		if(e.getSource() == this.close){
			this.dispose();  // dispose all resources and close the application
			System.exit(0);
		}

And this fixed everything (I can actually get rid of the this.dispose(); line altogether and it works fine too). I did this on an Ubuntu linux computer - could that have anything to do with it? Is "this.dispose();" supposed to terminate the program or just visually remove the window and all its resources?

Did anyone else run into this?
Was This Post Helpful? 0
  • +
  • -

#24 Digihash  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-September 10

Posted 09 September 2010 - 03:16 PM

Nice Tutorial.

I'm working on Windows 7 and I can save those files perfectly, but when I want to open that same file the console says that is don't have permissions to open the file. How can I overdue that?
Was This Post Helpful? 0
  • +
  • -

#25 Guest_elvis*


Reputation:

Posted 22 September 2010 - 06:16 AM


hi
i am compiling and getting no error using cmd prompt but when i run i get :



C:\test\Notepad\src\notepad>javac notepad.java

C:\test\Notepad\src\notepad>java notepad
Exception in thread "main" java.lang.NoClassDefFoundError: notepad (wrong name:
Notepad)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: notepad. Program will exit.




and using netbeans when i run i get :

run:
java.lang.NoClassDefFoundError: notepad/Main
Caused by: java.lang.ClassNotFoundException: notepad.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: notepad.Main. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


pls help , what silly mistake am i doing
Was This Post Helpful? 0

#26 Guest_elvis*


Reputation:

Posted 22 September 2010 - 06:49 AM

oh , figured mistake

should be java Notepad
(not notepad)

thx very much for such explanation
Was This Post Helpful? 0

#27 her000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-October 10

Posted 05 October 2010 - 10:09 PM

Nice Tutorial but it would be nice if ya could make it easier by naming each section.
e.g the menubar and then the colde
Menu and then the code..
same as for the rest...
I try to join the codes but I'm lost I can't figure it out which code goes where....Sorry too dumb in java
Was This Post Helpful? 0
  • +
  • -

#28 eduard.barna  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-December 10

Posted 05 December 2010 - 05:29 AM

I managed to build the Notepad app. Thank you for this tutorial.

I had to put the "included" and Notepad class in a separate .java file and to put main in a class called ProgramTest, in a separate .java file. Then compile the project and run the ProgramTest.

You made me happy :)

View PostDigihash, on 09 September 2010 - 02:16 PM, said:

Nice Tutorial.

I'm working on Windows 7 and I can save those files perfectly, but when I want to open that same file the console says that is don't have permissions to open the file. How can I overdue that?


Save on desktop or on a non-system drive OR you can run the program with administrator privileges :)
Was This Post Helpful? 0
  • +
  • -

#29 DADDYCARDONA  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 54
  • Joined: 04-July 10

Posted 12 December 2010 - 07:44 AM

View Postelvis, on 22 September 2010 - 05:16 AM, said:


hi
i am compiling and getting no error using cmd prompt but when i run i get :



C:\test\Notepad\src\notepad>javac notepad.java

C:\test\Notepad\src\notepad>java notepad
Exception in thread "main" java.lang.NoClassDefFoundError: notepad (wrong name:
Notepad)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: notepad. Program will exit.




and using netbeans when i run i get :

run:
java.lang.NoClassDefFoundError: notepad/Main
Caused by: java.lang.ClassNotFoundException: notepad.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: notepad.Main. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


pls help , what silly mistake am i doing

did you copy and paste it? and if you did that did you delete the line numbers in front of the program after you coppied and pasted it?
Was This Post Helpful? 0
  • +
  • -

#30 EnvXOwner  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 357
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Posted 13 December 2010 - 06:36 AM

View PostDADDYCARDONA, on 12 December 2010 - 08:44 AM, said:

View Postelvis, on 22 September 2010 - 05:16 AM, said:


hi
i am compiling and getting no error using cmd prompt but when i run i get :



C:\test\Notepad\src\notepad>javac notepad.java

C:\test\Notepad\src\notepad>java notepad
Exception in thread "main" java.lang.NoClassDefFoundError: notepad (wrong name:
Notepad)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: notepad. Program will exit.




and using netbeans when i run i get :

run:
java.lang.NoClassDefFoundError: notepad/Main
Caused by: java.lang.ClassNotFoundException: notepad.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: notepad.Main. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


pls help , what silly mistake am i doing

did you copy and paste it? and if you did that did you delete the line numbers in front of the program after you coppied and pasted it?

No one should ever copy and paste when reading a tutorial. If you do how are you going to understand the code and learn it.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3