M.H
M.H

Reputation: 3

opening text file in my textapp

I am new in java swing .For practice, I've created text app which simply allow the user to open,read and write text files and also have some editing functions. I've packaged my .class and other required files into jar file and created .exe file from this jar file.

When user opens text file(.txt,.rtf e.t.c) from the app(by clicking Open file toolbar on my app ) it works fine and display the content of file in JTextpane.

But when user opens text file outside my app (by clicking open with and set my app to open particular text file) to display the content of file on my app,my app just getting opened but not displaying the content of the file in JTextPane .

Can anyone suggest me the way How can this be done?

Upvotes: 0

Views: 71

Answers (1)

IMP1
IMP1

Reputation: 280

When you Open With... a file, that file's location is passed to the program as the first argument. So in your public static void main(String... args) procedure, you could add handling of a first argument that is a file location and open that file as you would otherwise from the GUI.

Upvotes: 2

Related Questions