creating JFrame and adding components

Posted on 2009-04-28
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;


public class converter {


	public static void main(String[] argv) throws Exception{


	    JFileChooser chooser = new JFileChooser();

	    File f = new File(new File("filename.txt").getCanonicalPath());



	    File curFile = chooser.getSelectedFile();

	    String filename = curFile.getName();

	    converter convert = new converter(filename);




Open in new window

Question by:TuringMachine0101
    LVL 2

    Assisted Solution


    Accepted Solution

    Thanks itzy,

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

    Best Regards

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now