?
Solved

creating JFrame and adding components

Posted on 2009-04-28
2
Medium Priority
?
433 Views
Last Modified: 2013-11-23
With the code below, how can I implement a user interface that has a button asking to choose a file.  Once chosen, I want to display the path including the selected file.  Then, I would like to add another button, that when pressed, will call convert.startConversion().  Once this is done, I'd like to have another button that will open the directory where the newly "converted" file is located at (which should be on the same directory original file is at).

But initially, I need help creating the jframe and adding the appropriate components to it.

The code below is working.
import javax.swing.JFileChooser;
import java.io.File;
 
 
public class converter {
	
	public static void main(String[] argv) throws Exception{
		
	    JFileChooser chooser = new JFileChooser();
	    File f = new File(new File("filename.txt").getCanonicalPath());
	    chooser.setSelectedFile(f);
	    chooser.showOpenDialog(null);
	    File curFile = chooser.getSelectedFile();
 
	    String filename = curFile.getName();
	    converter convert = new converter(filename);
	    convert.startConversion();
	}
 
}

Open in new window

0
Comment
Question by:TuringMachine0101
2 Comments
 
LVL 2

Assisted Solution

by:itzy
itzy earned 160 total points
ID: 24256106
0
 

Accepted Solution

by:
TuringMachine0101 earned 0 total points
ID: 24265079
Thanks itzy,

But how can I incorporate my current code to add the components I mentioned earlier?

Best Regards
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question