Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-12-2008, 01:10 AM
Member
 
Join Date: Nov 2008
Posts: 6
Rep Power: 0
nenadm is on a distinguished road
Default JFileChooser horizontal scrollbar problem
Hi,
I use JFileChooser to make possible to user to navigate among great number of files and folders. However it is desirable that file chooser always stay positioned on the position of last selected file.
But for some reason horizontal scroll bar don't stay at last position but always stay centered. Moreover it have desirable behaviour only if user dont scroll horizontaly at all (remember position), but if user scroll to the end, close and again open file chooser, it dont remember last position.
I am interested is it possible in some way to work upon on position of JFileChooser scroll bar or handle this situation.
Thanks alot.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-12-2008, 03:56 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 3,195
Rep Power: 5
Fubarable is on a distinguished road
Default
In my SSCCE the scroll position seems to persist. Are you doing something different than I'm doing here?
Code:
import java.awt.event.*;
import javax.swing.*;

public class JFCTest
{
  private JPanel mainPanel = new JPanel();
  private JFileChooser jfc = new JFileChooser();

  public JFCTest()
  {
    JButton openJfcBtn = new JButton("Open JFileChooser");
    mainPanel.add(openJfcBtn);
    
    openJfcBtn.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        jfc.showDialog(mainPanel, "Go For It!");
      }
    });
  }

  public JComponent getComponent()
  {
    return mainPanel;
  }

  private static void createAndShowUI()
  {
    JFrame frame = new JFrame("JFCTest");
    frame.getContentPane().add(new JFCTest().getComponent());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }

  public static void main(String[] args)
  {
    java.awt.EventQueue.invokeLater(new Runnable()
    {
      public void run()
      {
        createAndShowUI();
      }
    });
  }
}
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-12-2008, 09:59 AM
Member
 
Join Date: Nov 2008
Posts: 6
Rep Power: 0
nenadm is on a distinguished road
Default
Well just one thing and i think there is a problem, i set preferred position of my JFileChooser. When i use default window dimensions all works fine.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-12-2008, 10:16 AM
Senior Member
 
Join Date: Sep 2008
Posts: 607
Rep Power: 1
Darryl.Burke is on a distinguished road
Default
Off hand I'd say that shouldn't be a problem either provided you set the position just once, before you display the chooser for the first time.

db
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-12-2008, 11:16 AM
Member
 
Join Date: Nov 2008
Posts: 6
Rep Power: 0
nenadm is on a distinguished road
Default
Thank you guys,
i find out that problem is in centering my file chooser.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regd the scrollbar in a table in JSP itmani2020 Advanced Java 4 08-13-2008 01:26 PM
How to use vertical and horizontal sliders in SWT Java Tip SWT 0 07-02-2008 08:06 PM
Need JFileChooser Help Wraithier New To Java 4 06-18-2008 05:40 PM
Using java.awt.Scrollbar Java Tip Java Tips 0 01-03-2008 09:19 AM
how to use JFileChooser tommy New To Java 1 08-06-2007 08:49 PM


All times are GMT +2. The time now is 11:09 PM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org