How do i show the filename.type instead of the entire file path?

How do i show the filename.type instead of the entire file path?
I want it to show "ProgramSetup.exe" instead of "C:/Program Files/Oracle/JavaFX/ProgramSetup.exe"
I have created a JavaFX program with the help of my manager
below are the code
               File file = fileChooser.showOpenDialog(Admin.mainStage);
               if (file != null) {
                    textFiles.setText(file.getAbsolutePath());
                    String absolutePath = file.getAbsolutePath();
                    //String fileName = new File(absolutePath).getName();the reason i put the last line as // because it has error on that line....
if i remove the last line, it will display but with the full path....
i search through google and the guide on many forums aren't clear to me.....some said there are 2 ways but i tried and it is not working, atleast for me...maybe i left out something or what....can anyone help me on this?

You don’t need the absolutePath:
File file = fileChooser.showOpenDialog(Admin.mainStage);
               if (file != null) {
                    textFiles.setText(file.getName());
                           }

Similar Messages

  • Having an inherited function return the derived type instead of the base type

    I am writing two classes in C#:
    A Matrix class
    that represents a general Matrix with n-by-m dimensions
    A SquareMatrix class
    that inherits from Matrix and
    has the constraint of being n-by-n
    The reason I designed it this way is because square matrices support additional specific operations like calculating the determinant or the inverse, so being able to guarantee that those functions are avaliable with the specific type you're using are nice things
    to have. Additionally it would support all the regular Matrix operations and can be used as a Matrix
    I have a function in Matrix called getTranspose().
    It calculates the transpose of the Matrix and returns it as a new Matrix
    I inherited it in SquareMatrix,
    but because the transpose of a square matrix is guaranteed to be square matrix, I also want it to return a SquareMatrix
    I am unsure about the best way to do this.
    I can re-implement the function in SquareMatrix,
    but that would be code duplication because it's essentially the same calculation
    I can use implicit typecast operators, but if I understand correctly that would cause unnecessary allocations (upcast SquareMatrix to Matrix,
    create a new Matrix as
    the transpose, create a new SquareMatrix during
    typecasting and throw away the tranposed Matrix)
    I can use explicit typecast operators, but it would be stupid to have to typecast the transpose of a SquareMatrix explicitly,
    and it also has the same problem of the implicit operator with unnecessary allocations
    Is there another option? Should I change the design of having SquareMatrix inherit
    from Matrix?
    This problem also applies to operators. It seems that I have to either implement typecasting operators which might cost in performance, or have to re-implement the same code.

    Inheritance not helping to eliminate repetition and typecasts is often a sign that generics would help. You can do something like:
    public T getTranspose<T>()
    // or non-member function
    T getTranspose<T>(T input)
    I haven't fully worked it out, but it seems it might get awkward on the calling side. I know C# does some inference with generic methods, but I don't know C#, so I'm not familiar with the details. That might be the way you have to go, though, if you want
    full compile-time type checking with the least amount of repetition in the implementation.
    Another option would be to create private helper functions, then pass in the result type you want, for the helper to populate, like:
    public SquareMatrix getTranspose() {
    SquareMatrix result = new SquareMatrix();
    transposeHelper(result);
    return result;
    This gives you more boilerplate on the implementation side, but at least it isn't full repetition.
    A third option is just to check if the result is square in the Matrix implementation, and return a
    SquareMatrix if it is, like:
    public Matrix getTranspose() {
    Matrix result;
    if (resultIsSquare())
    result = new SquareMatrix();
    else
    result = new Matrix();
    // calculate result
    return result;
    This has the advantage of not needing any implementation at all for getTranspose() in
    SquareMatrix, but at the expense of requiring type checking of the return value at the call site. It also works for cases like multiplying two non-square matrices that happen to give a square result. You give up most compile-time type checking,
    though.
    If your application happens to mostly require run-time instead of compile-time type checking anyway, you might as well just give up the different types and throw an exception if you call a method that a non-square matrix doesn't support. I believe this is
    the approach most existing libraries take, especially since there are other conditions than being non-square that can cause methods like
    inverse() to fail.
    Speaking of libraries, there are a lot of good ones out there for matrix math, that are already heavily tested and optimized. Don't reinvent the wheel if you don't have to.

  • I had to restore my iPhone 4s and now my recent calls show only phone numbers instead of the contact's name.  How can I restore the names to my recent calls list?

    I had to restore my iPhone 4s and now my recent calls show only phone numbers instead of the contact's name.  How can I restore the names to my recent calls list?

    Are the contact details in your contacts app, the phone app uses the contact app to put names against telephone numbers.

  • Apple shows me as living in the United Kingdom instead of the United States. How do I change this?

    Apple shows me as living in the United Kingdom instead of the United States.  How do I change it?

    Changing Account Information
    http://support.apple.com/kb/HT1918
    See  >  Change your iTunes Store country
    Here  >  http://support.apple.com/kb/HT1311

  • Wenn I've made changes on my private home-page and want to see the result, how do I get my Mac to load the new side instead of the "old" one?

    When I've worked on my private home-page and want to controll the results, how do I get my Mac to take the new version instead of the old one? I tried cmd R without any change! Who knows? Nina

    Try clearing the cache - command-option-e in Safari.

  • I have an old version of itunes on my computer.  My current iPhone will only support OS 10.6.8, how can I upgrade to that system instead of the latest version?

    I have an old version of itunes on my computer.  My current iPhone will only support OS 10.6.8, how can I upgrade to that system instead of the latest version?

    In teh middle of this page...
    -> http://support.apple.com/kb/DL1576
    Download iTunes 10.7 for Windows here: iTunes 10.7 for Windows

  • When capturing images from a Nikon D600, they show in Bridge, but when clicked to load into CS6,an error message says that it is the wrong type of document, even jpeg files. This is a NEW frustration.

    When capturing images from a Nikon D600, they show in Bridge, but when clicked to load into CS6,an error message says that it is the wrong type of document, evne jpeg files. This is a NEW frustration.

    Nikon raw files would open up in Adobe Camera Raw and so should jpegs.
    If you select one in Bridge and give the command "Ctrl r" (Windows), what happens?
    Also what is the version of ACR in the title bar?
    Gene
    Note: unmark your question as "answered". the green balloon next to the subject shows it as "solved".

  • My new iPad mini is connected to a Logitech keyboard but can't seem to get it to type instead of the touch screen version on the iPad - any hints?

    My new iPad mini is connected to a Logitech keyboard but can't seem to get it to type instead of the touch screen version on the iPad - any hints?
    Michael

    Is this a Bluetooth keyboard?
    Have you turned on Bluetooth in iPad's Settings app?

  • I purchased dungeon hunter alliance from the app store and accidentally hit the x button instead of the installed button to install the game how do I install the game now

    Can someone help me, I purchased the game dungeon hunter alliance froom the app store and accidentally hit the x button instead of the install button so now how can I install the game to my computer macbook

    Hi ...
    You accidentally "hid" the purchase ..
    Follow the instructions here.  Mac App Store: Hiding and unhiding purchases
    Once the app is available ...
    How to re download apps from the Mac App Store:
    Open the App Store. From the menu bar click Store > Sign In
    Click Purchases from the top of the App Store window.
    Select which apps you want to re download. Then right or control click where you see Installed  then click Install.
    Make sure and use the same Apple ID used for the original purchase.

  • HT4743 I just purchased an iTunes TV show and it successfully downloaded. It is now saying that I do not have the proper version of QuickTime on this version of iTunes (10.6.3). How can a show I purchased be incompatible with the latest version of iTunes?

    I just purchased an iTunes TV show and it successfully downloaded. It is now saying that I do not have the proper version of QuickTime on this version of iTunes (10.6.3).
    How can a show I purchased be incompatible with the latest version of iTunes?
    I want a refund, but I can't even figure out how to request one through support. Super frustrated and long time Apple customer.

    After a day of trying, both iTunes and my Apple TV are telling me that the episodes of Scooby Doo I purchased are incompatible due to QuickTime. I still don't understand how I purchased something from iTunes that doesn't work with iTunes.
    the exact error I receive when I try to play an episode is the following:
    "This movie requires QuickTime, which is not supported by this version of iTunes."
    Any advice would be great!

  • PR05: How to configure the expense types depending on the type of expense?

    Hi,
           We are in the process of upgrade from 4.6C to ECC 6.0. The problem is that when we are creating the expense request, after selecting the type of expense (travel expense or non travel expense) we are getting the same expense types for both the travel and non travel expenses.
    Now my question is that, is there any in error in configuring the expense types in transaction FITVFELD.
    How to configure the expense types depending on the type of expense (travel and non travel)?
    Your answer will be highly appreciated.
    Thanks in advance.
    Ramana

    Hi
    I checked with one of the SUBJECT MATTER EXPERT on T&E and it is not possible to have the expense types based on the schema.
    Thanks
    Ashok
    Award points if this is useful

  • TS3899 My incoming emails on my ipad are going into the important box instead of the inbox how do I get them to go into inbox

    The incoming  mail on my apple ipad  are going straight into the important box instead of the inbox how do I resolve this.

    Who is your email provider? Is it Gmail? Take a look at this.
    https://productforums.google.com/forum/#!topic/gmail/JVnvlvaVt0E

  • My 5600 keeps defaulting to the fax first instead of the printer only how can i change that ?

    my 5600    keeps defaulting to the fax first instead of the printer only how can i change that ? 

    What operating system?
    In general you would go to the Printers (or Devices and Printers or Printers and Faxes) folder, right click on the 5600 and select Set as Default.  Depending on your operating system you may need to do this as an administrative user.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Imessage only displays the phone number instead of the name after the last update. any idea how to fix it?

    imessage only displays the phone number instead of the name after the last update. any idea how to fix it? All messages had the names displaying correctly before the last update.

    From the menu bar, select
     ▹ System Preferences... ▹ Language & Region
    From the Region menu in the window, select one of the preset regions. If one is already selected, choose a different one, then change it back. Close the preference pane and test.

  • How can I choose the built-in mic of the Macbook Pro instead of the headphones' mic?

    I have some headphones with a built-in microphone connected to the Macbook Pro, but I would like to use the microphone of the Macbook Pro instead of the headphones' one. If I go to System Preferences > Sound > Input, I can choose between 'External microphone' and 'Line in', but none of them take the sound from the Macbook Pro's microphone.

    Go to System Preferences on that click sound icon select input chose which mic you want

Maybe you are looking for

  • How can I get my old messages back?

    I'm using my iPad to skype and I need to get my old messages of like one year ago back. Is there a way to get them back? Like doesn't skype have a server where all the messages are stored? If it is so, could I email them and ask for the list of the o

  • Printing as a booklet

    Hello, I'm trying to find iPages' equivalent of doing booklet printing.  I cannot seem to find that functionality that I usually find in MS Word.  I use it to print my sermon notes in a nice half page size and staple it as a booket.

  • Odd volume stuck issue.

    Alrighty I've had my iPhone 4 in the UK for around a week now and all in all I have no real issues with signal nor battery life (apart from that skype uses more than it did on my 3G). My only problems were getting o2 to activate it, the proximity sen

  • In Imovie I get the message that my source clip is missing so I can't work/view the project

    What do I do if I get a source clip is missing message in Imovie?

  • Color box garbled

    Using Cap5 and have started getting a weird problem in the "color box". When I set stroke or fill colour the color box displays normally, but if I try to edit stroke or fill in a highlight, the color box looks like its been "shaken and stirred". Have