Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: JFileChooser.showOpenFileDialog()

  1. #1
    Junior Member
    Join Date
    Mar 2024
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JFileChooser.showOpenFileDialog()

    JFileChooser fchsr=new JFileCbooser();

    In the above show...Dialog() call, 'file type' combo box is still shown even
    flchsr.setFileSelectionMode(JFileChooser.DIRECTORI ES_ONLY) is called.
    Since only a folder is sought, 'file type' combo is irrelevant, right?
    I was looking for a method to either set the combo null, or disabled but can't identify the combo...
    n=flchsr.getComponentCount() reports 3. So for each Component, 0 to 2, I try to identify what it is by
    Component cmp; String nm; Point pt; boolean on;
    cmp=flchsr.getComponent(0 to 2);
    nm=cmp.getName();
    on=com.isShowing();
    pt=cmp.getLocation();
    Then nm=null, on=false, and pt.x=pt.y=0 for all reported component...

    So how can I drop or disable 'file type' in the dialog? Any input, suggestion is greatly appreciated.
    (I don't want to write a custom dialog since this Java-provided one is already available, you know.)

  2. #2
    Junior Member
    Join Date
    Jan 2024
    Posts
    28
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: JFileChooser.showOpenFileDialog()

    It seems like you're facing a challenge in customizing the behavior of the file type combo box in the JFileChooser dialog. While the setFileSelectionMode() method is intended to limit the selection to directories only, the file type combo box remains visible, which might be irrelevant in this context.

    Unfortunately, directly accessing or modifying the file type combo box within the JFileChooser dialog is not officially supported by the Java API. The components inside the JFileChooser dialog might not be easily accessible or modifiable using standard methods.

    However, there might be a workaround you could consider. You could potentially subclass JFileChooser and override certain methods to customize its behavior. For instance, you might override the createDialog() method to intercept the creation of the dialog and make modifications to its components before it is displayed.

    Alternatively, you could explore third-party libraries or frameworks that provide more extensive customization options for file chooser dialogs.

    While it's understandable that you prefer to utilize the Java-provided dialog, sometimes customizing its behavior might require more advanced techniques beyond the standard API. If you're open to it, creating a custom dialog might be the most straightforward solution to achieve the exact behavior you desire.

    I hope this provides some insight into your issue, and I wish you the best of luck in finding a suitable solution! If you have any further questions or need clarification, feel free to ask.

    While it's understandable that you prefer to utilize the Java-provided dialog, sometimes customizing its behavior might require more advanced techniques beyond the standard API. If you're open to it, creating a custom dialog might be the most straightforward solution to achieve the exact behavior you desire. Exploring resources for help with Java assignment, such as programminghomeworkhelp.com, could also provide valuable insights into addressing this challenge effectively.

Similar Threads

  1. Question about JFileChooser
    By rolfis in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: March 23rd, 2013, 07:24 PM
  2. JFileChooser
    By Karthik Prabhu in forum AWT / Java Swing
    Replies: 4
    Last Post: June 23rd, 2012, 04:47 AM
  3. JFileChooser Please Help
    By mulligan252 in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: October 9th, 2011, 11:03 AM
  4. JFileChooser frustrations!
    By chrisivey1980 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 3rd, 2011, 05:32 AM
  5. JFileChooser
    By FretDancer69 in forum AWT / Java Swing
    Replies: 2
    Last Post: February 3rd, 2010, 06:35 AM