• Post Reply Bookmark Topic Watch Topic
  • New Topic

Open a log file's content

 
Minal Shah
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using Java Swings. I want to open log file's content by pressing key board short cuts.
I know JFileChooser but for that i can get a dialog to choose file but i want to open file's content by just pressing F9 or any short cut key anywhere in the aplication.
Can anyone suggest a way to get that.
Thanks,
Minal
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You only need a JFileChooser if you don't know the filename and you need the user to select a file. I'm not sure how you're doing logging, but however you know your "log file" you just use that file name directly and do whatever you do to "open" it. This would be whatever you do with the file reference that you get from the JFileChooser when the user selects a file.

One way to do all of this based off a keypress would be to do all of this in an action, associate that action with a JMenuItem, and then assign a keyboard shortcut to that JMenuItem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!