Use command line args in a Java Swing program -
how can process command line arguments in java swing program?
edit: want have user give file path arg. set text of jtextpane contents of file.
the way through main method when run java class file.
you following in command line once compiled; java nameofclassfile b c d
for example print them out array of command line arguments:
public static void main(string[] args) { for(string arg : args) system.out.println(arg); }
i don't know of anyway pass command line arguments running java swing program. not sure if can.
to display files contents on jtextpane can use args[0]
a command line argument file path using:
jtextpane pane = new jtextpane(); jframe frame = new jframe("example"); frame.add(pane); frame.setvisible(true); file file = new file(args[0]); pane.setpage(file.tourl().tostring()); frame.pack();
if want more 1 files contents use java nameofclassfile file1 file2 file3
can use args[0] args[1] args[2]
file path , modify above code put on jtextpane.
Comments
Post a Comment