JTree in JScrollPane doesn't scroll

I have a JTree in a JScrollPane that doesn't scroll.
Background: it used to!
History: I moved the creation of the JTree to inside an Object that returns it with a ".getTree()" method. Since then, it hasn't been scrolling. I even set the JScrollPane to always have scrollbars and they just sit there inactive.
Does anyone know what this would happen and/or how to fix it?
thanks.

That actaully worked, but it was way to big. I'm not sure what I did, but I changed the values to Studio ONE's defaults and now it works ok.

Similar Messages

  • JScrollPane doesn't scroll when appended from outside Thread.

    The strangest thing I've ever seen in Java has just occured. I'm making a client program that uses an outside thread to get input from a BufferedReader that's created from a TCP/IP connection. Now, I'm using a JTextArea, that has been added into a JScrollPane. Within the main thread, if I append to my JTextArea until it reaches the end of it's view, it will scroll down to meet the newly added text. If I however instead append it remotely from a thread I've created, it will append the text, but not scroll. Does any one have any idea how I can fix this?
    -Jason Thomas.

    Your may try one of these:
    1- Contruct the JScrollPane with scrollbar-policy on:
    ...new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    2- Contruct the JTextArea with the number of rows & columns big enough to make the scrollers appear: say ...= new JTextArea(200, 200) so that you always have them
    3- Call invalidate() method on the instance of the JTextArea inside the remote Thread after appending.
    <main thread>
    JTextArea textArea;
    <remote thread>
    public void run()
    textArea.append(...);
    textArea.invalidate();
    4- If the remote Thread appends to the TextArea while the TextArea is being shown (pack), this might confuse the JScrollPane to calculate the preferredScrollableViewportSize. You may Synchronized the remote Thread. Or check this code:
    <main thread>
    JTextArea textArea;
    <remote thread>
    public void run() {
    // wait until the textArea becomes visible
    while ( ! textArea.isVisible() )
    try {
    Thread.sleep(100);
    } catch (InterruptedException e) {}
    // now append
    textArea.append(...);

  • JTree in JScrollPane incorrect scrolling

    Hi,
    I have a JTree in a JScrollPane, when I scroll (programatically) in the JTree using the setAnchorSelectionPath method of the JTree some scrolling occurs but not enough to bring the leaf node of the JTree into the visible viewport.
    Any suggestions,
    Mark

    Cheers for the pointer, I am not attempting drag and drop though ....
    I have a selected leaf node in the tree and then I change the type of sort I use on the data in the tree, I find the new leaf node, expand the path down to it and then attempt to scroll.
    Thus no pointer information to use with <i>Autoscroll</i>
    Mark

  • JTree and JScrollPane problems

    Hello all.
    bear with me a second, so I can explain what is happenning with my code. I have got a java application that is accessing an SQL database (either Oracle or postgreSQL) and inputing the data into a tree.
    More specifically it takes the "enrollment" data and draws into the scrollpane the courses and students enrolled. Everything seems to be working perfectly with the building of the tree.
    but I have a drop down list that can select which years to display (1-4th year). I want the tree in the scrollPane to update when u change the year in the drop down list.
    I have added an ActionListener to the drop down list and it picks up the right selection, and I create a new tree object with the new year details and nothing is changed in the scrollpane.
    This is what the GUI looks like:
    This is my tree class which creates teh tree and adds it to the scrollPane object:
    package Interface;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.sql.*;
    import Database.Database;
    public class Tree{
         JTree tree;
         JScrollPane scrollPane;
         public Tree(GridBagConstraints c, Container contentPane, GridBagLayout gridBag, int year){
              //Set up the default table.
              TreeNode root = buildTree("Enrollments", year);
              tree = new JTree(root);
              //Set up a scrollPane for the tree.
              scrollPane = new JScrollPane(tree);
              //Set constraints for the ScrollPane
              c.fill = GridBagConstraints.BOTH;
              c.weightx = 1;
              c.weighty = 1;
              c.gridwidth = 2;
              c.gridx = 0;
              c.gridy = 1;
              c.anchor = GridBagConstraints.CENTER;
              gridBag.setConstraints(scrollPane, c);
              contentPane.add(scrollPane);     
              //Set defaults for teh Tree object.
              tree.expandRow(0);
              tree.setRootVisible(false);
              tree.setEditable(true);     
         public DefaultMutableTreeNode buildTree(String s, int year){
              //Set root of tree.
              DefaultMutableTreeNode node = new DefaultMutableTreeNode(s);
              //Create a database object.
              Database db = new Database();
              //change this bit to get the name's of the courses and add into array.
              ResultSet className = db.query("SELECT name FROM courses WHERE year = "+year);
              DefaultMutableTreeNode course = null;
              DefaultMutableTreeNode name = null;
              try {
                        while(className.next()){
                             String classStr = className.getString("name");
                             course = new DefaultMutableTreeNode(classStr);
                             node.add(course);
                             ResultSet firstName = db.query("SELECT students.name FROM students, enrollments, courses WHERE students.id = enrollments.studentID AND enrollments.courseid = courses.id AND courses.name = '"+classStr+"'");
                             while(firstName.next()){
                                  String nameStr = firstName.getString("name");
                                  name = new DefaultMutableTreeNode(nameStr);
                                  course.add(name);
                   catch(Exception e){
                        System.err.println("" + e.getMessage());
                        e.printStackTrace(System.err);
              return node;
    }This is the GUI class that calls on the tree class and draws the GUI. and the actionlistener for the drop down list.
    package Interface;
         import java.awt.*;
         import javax.swing.*;
         import java.awt.event.*;
    import java.sql.*;
         public class GUI extends JFrame implements ActionListener{
              private static final long serialVersionUID = 1L;     
              DropDownMenu yearDrop;
              ScrollPane scrollPane;
              JMenuItem menuItemSave;
              JMenuItem menuItemQuit;
              JMenuBar menuBar;
              JMenu menu;
              JButton save;
              JButton quit;
              Tree tree;
              String year[] = { "First Year", "Second Year", "Third Year", "Fourth Year" };
              Container contentPane = getContentPane();
              GridBagLayout gridBag = new GridBagLayout();
              GridBagConstraints c = new GridBagConstraints();
              public GUI(){
                   setSize(500,500);
                   setTitle("UTAS Enrollments");
                   contentPane.setLayout(gridBag);          
                   save = new JButton("Save");
                   quit = new JButton("Quit");
                   menuItemSave = new JMenuItem("Save");
                   menuItemQuit = new JMenuItem("Quit");
                   menuItemSave.setMnemonic('s');
                   menuItemQuit.setMnemonic('q');
                   yearDrop = new DropDownMenu(year, c, contentPane, gridBag);
                   tree = new Tree(c, contentPane, gridBag, 1);
                   menuBar = new JMenuBar();
                   menu = new JMenu("File");
                   menu.setMnemonic('f');
                   menuBar.add(menu);
                   menu.add(menuItemSave);
                   menu.add(menuItemQuit);
                   setJMenuBar(menuBar);
                   //Set constraints for the Save button
                   c.fill = GridBagConstraints.NONE;
                   c.weightx = 1;
                   c.weighty = 0;
                   c.gridwidth = 1;
                   c.gridx = 0;
                   c.gridy = 2;
                   c.anchor = GridBagConstraints.WEST;
                   save.setMnemonic('s');
                   gridBag.setConstraints(save, c);
                   contentPane.add(save);
                   //Set constraints for the Quit button
                   c.fill = GridBagConstraints.NONE;
                   c.weightx = 1;
                   c.weighty = 0;
                   c.gridwidth = 1;
                   c.gridx = 1;
                   c.gridy = 2;
                   c.anchor = GridBagConstraints.EAST;
                   quit.setMnemonic('q');
                   gridBag.setConstraints(quit, c);
                   contentPane.add(quit);
                   //Add ActionListener to the interactive buttons on the GUI.
                   //QUIT MENU
                   menuItemQuit.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                             quitAction();
                   //SAVE MENU
                   menuItemSave.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent e){
                             saveAction();
                   //QUIT BUTTON
                   quit.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e){
                             quitAction();
                   //SAVE BUTTON
                   save.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e){
                             saveAction();
                   //DROPDOWN LIST
                   yearDrop.dropDown.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e){
                             listAction();
              public void listAction(){
                   System.out.println("getSelected: "+ year[yearDrop.getSelected()]);
                   tree = new Tree(c, contentPane, gridBag, (yearDrop.getSelected()+1));
                   repaint();
         I have taken out the quitAction and saveAction methods to save space.
    I would have thought creating a new Tree object over the original tree would have updated the scrollPane.
    Any ideas would be awesome.
    Thanks in advance.

    and I create a new tree object with the new year details and nothing is changed in the scrollpane.Creating a new Tree doesn't add the tree to the scroll pane. It just changes the reference of the tree variable to point to the new Tree object. To update the scroll pane you would need to do:
    scrollPane.setViewportView( tree );
    Or another option is to just create a new TreeModel and then change the model that your existing tree is using:
    TreeModel model = new TreeModel(...);
    tree.setModel( model );

  • Itunes installs ok but doesn't scroll properly. plz help!

    Ive installed itunes so many times, it doesn't scroll properly and i cant see the file, edit, view etc..(the bar at the top). I cant get a clear view of all my music and its driving me mental!! Does any1 kno wots wrong?

    It may be that the toolbar is "hiding" off the top of your screen. Try reducing the screen resolution (right-click on the desktop, select Personalize, then Display Settings). If that then allows you to see the iTunes toolbar, drag it lower on the screen, then set the display resolution back to normal.
    Hope this helps.

  • Problem in refreshing JTree inside Jscrollpane on Button click

    hi sir,
    i have problem in refreshing JTree on Button click inside JscrollPane
    Actually I am removing scrollPane from panel and then again creating tree inside scrollpane and adding it to Jpanel but the tree is not shown inside scrollpane. here is the dummy code.
    please help me.
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.tree.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.event.WindowListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    public class Test
    public static void main(String[] args)
         JFrame jf=new TestTreeRefresh();
         jf.addWindowListener( new
         WindowAdapter()
         public void windowClosing(WindowEvent e )
         System.exit(0);
         jf.setVisible(true);
    class TestTreeRefresh extends JFrame
         DefaultMutableTreeNode top;
    JTree tree;
         JScrollPane treeView;
         JPanel jp=new JPanel();
         JButton jb= new JButton("Refresh");
    TestTreeRefresh()
    setTitle("TestTree");
    setSize(500,500);
    getContentPane().setLayout(null);
    jp.setBounds(new Rectangle(1,1,490,490));
    jp.setLayout(null);
    top =new DefaultMutableTreeNode("The Java Series");
    createNodes(top);
    tree = new JTree(top);
    treeView = new JScrollPane(tree);
    treeView.setBounds(new Rectangle(50,50,200,200));
    jb.setBounds(new Rectangle(50,300,100,50));
    jb.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
              jp.remove(treeView);
              top =new DefaultMutableTreeNode("The Java ");
    createNodes(top);
              tree = new JTree(top);
                   treeView = new JScrollPane(tree);
                   treeView.setBounds(new Rectangle(50,50,200,200));
                   jp.add(treeView);     
                   jp.repaint();     
    jp.add(jb);     
    jp.add(treeView);
    getContentPane().add(jp);
    private void createNodes(DefaultMutableTreeNode top) {
    DefaultMutableTreeNode category = null;
    DefaultMutableTreeNode book = null;
    category = new DefaultMutableTreeNode("Books for Java Programmers");
    top.add(category);
    book = new DefaultMutableTreeNode("The Java Tutorial: A Short Course on the Basics");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Tutorial Continued: The Rest of the JDK");
    category.add(book);
    book = new DefaultMutableTreeNode("The JFC Swing Tutorial: A Guide to Constructing GUIs");
    category.add(book);
    book = new DefaultMutableTreeNode("Effective Java Programming Language Guide");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Programming Language");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Developers Almanac");
    category.add(book);
    category = new DefaultMutableTreeNode("Books for Java Implementers");
    top.add(category);
    book = new DefaultMutableTreeNode("The Java Virtual Machine Specification");
    category.add(book);
    book = new DefaultMutableTreeNode("The Java Language Specification");
    category.add(book);
    }

    hi sir ,
    thaks for u'r suggession.Its working fine but the
    properties of the previous tree were not working
    after setModel() property .like action at leaf node
    is not working,I'm sorry but I don't understand. I think you are saying that the problem is solved but I can read it to mean that you still have a problem.
    If you still have a problem then please post some code (using the [code] tags of course).

  • APPLE MOUSE DOESN'T SCROLL IN MAIL?

    Suddenly my Apple wireless mouse doesn't scroll (moving finger on top of mouse) in the Apple MAIL ap.  It works fine in all other aps/activities.

    See solution in More like this at right (need to set scrolling with inertia).

  • IOS 8 - my calendar doesn't scroll forwards from week to week since updating to IOS any ideas to help?

    SMain with updating to IOS 8 my iPad calendar doesn't scroll forwards from week to week. Any idess on what I can do?
    thanks

    That works for me. Can you clarify exactly what you are doing and what happens?

  • Installed Firefox 3.6.10 now my mouse wheel doesn't scroll

    I just installed FF 3.6.10 update, and now my mouse wheel doesn't scroll. I checked my mouse settings, and all is correct. Mouse wheel scrolls in non-Firefox applications, including off-line folders and online IE. Mouse wheel worked fine with last version of FF. Also tried hooking up a different mouse, (an old mechanical one at that), same problem. If this cannot be fixed, how can I uninstall the latest update and rollback to the previous version?

    thanks for all the tips, however none of these work. Installed 3.6.10, 3.6.11 and latest version 3.6.13 but the mouse wheel is still not working.
    Waiting for comment from Mozilla. If they take this problem serious, which I doubt, reading about the problem since September and 86 people who reported...

  • JScrollPane doesn't think

    Hi,
    I am trying to display a histogram on a JPanel and place that on a JScrollPane.
    My problem is that the JScrollPane doesn't seem to think it is needed when it is. I have not set any sizes and the histogram(Graphics 2D) is not being fully shown in my Frame and no scrollBars are appearing.
    Anybody know a solution to this?
    Thanks in advance,
    L.

    Don't make multiple posts.
    I've already answered to your question in your previous post.
    http://forum.java.sun.com/thread.jsp?forum=57&thread=352148&tstart=0&trange=30
    Denis

  • New version of itunes doesn't scroll artists smoothly.

    New version of itunes doesn't scroll artists smoothly.  It is very choppy and slow.  Anyone else have this problem?

    I finally was able to get it working.....looked like it just hadn't finished with the download...I am not sure I am not very computer savvy but it works and all my music is there....thank goodness thank you for repsonding

  • I have a Lenovo Optical Mouse which doesn't scroll in Firefox. Any idea how to fix it? I tried the options from the tools menu and the advance config options too. Nothing worked. Please help. Thank you.

    Wheel doesn't scroll in firefox, but works fine in other browsers and windows softwares.

    Are there any special settings in the "Control Panel > Mouse" for that scroll wheel and button?

  • Typing in the index box doesn't scroll the index topics

    This has been a bug for quite a while (v5?).  We are using v7 now.  We have a large help system.  Generating WebHelp with RoboHelp for Word.  We are calling context help using the Robohelp_CSH.cpp function RH_ShowHelp().  What we are seeing is that when the user types into the index box (where it says 'Type in the keyword to find'), the list of index topics doesn't scroll to what the user is typing.  If we run the help 'standalone' by double clicking on the 'root' .htm file, it works fine.  We have users that find this very offensive.  One actually got a hold of the president of the company and gave him 'an earfull' about it.  Called us incompetent, etc.  I downloaded the trial of v9 to see if it had been corrected.  But it hasn't.  Has anyone seen this?  Is there a fix?

    Hi there
    I bit the bullet, downloaded the app and installed it. I do see what you mean by the index not scrolling automagickally as it would with basic WebHelp being presented in a standard browser. But I note that what is happening is you appear to have WebHelp but being somehow presented using a custom viewer? I think we need more information about exactly how this viewer is working with the content.
    What type of help is this? I know you said that you are using RoboHelp for Word, meaning that you are making edits using Microsoft Word and creating output from that. But what happens once you create the WebHelp? I see that you have a gob of content out in the RSU.Help folder. I also note that if I find and double-click the page named: rsu.htm that WebHelp loads and the Index works just fine and scrolls as you would expect.
    So I can only conclude that the issue really isn't with what RoboHelp is producing, but more what your developers may be doing with the help once they link it to the application. I guess my analogy would be that you are stuffing a working product into a crate and the process of stuffing it into the crate is causing breakage.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7, 8 or 9 within the day!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • X220 Touchpad Doesn't Scroll Down, but scrolls up

    I just got my X220, installed all relevant Windows and Lenovo updates, restarted several times, but the touchpad doesn't scroll down.  It only scrolls up. 
    Also the touchpad tap action (which is same as left click) is not as responsive as I like.  Is there a setting for that?
    Solved!
    Go to Solution.

    It is a bit more responsive now and is scrolling down more.  Not sure what has changed.  It is still not as responsive as it should be.  I'm clearly sliding my finger down on the scroll side of the touchpad and it doesn't scroll.  Yet sometimes it scrolls.  Something is still wrong.

  • JTree doesn't scroll to selected node when out of scrollable view..

    When ever I add a new item to the END of the tree and the tree is within a scrollpane, OR as I hit keys to navigate to items starting with the letter of the key I enter, the view is not scrolled into place. Any way to do this without custom code? If not, what sort of code does this? I am adding various listeners already for mouse drag/drop, editing, selection, etc.
    Thanks.

    After you do the expandPath or expandRow, whichever it is you are using in JTree, make sure you reload the your DefaultTreeModel. model.reload( ); Where DefaultTreeModel model;
    Or (And) try validate( ) and repaint( );
    One of those does it. I think the first. It's been awile.
    Con

Maybe you are looking for

  • Using iCal on iPhone in Day view - How can I move divider to give more space to all-day events?

    I am using iCal on an iPhone I would like to move the divider that seperates all-day events from the timed events. I would like to view with more room for all-day events and less room for timed events. How can I do this?

  • Airport Express' no longer available to iTunes as remote speakers

    Hi,      I'm running Windows 7, iTunes 10.6.1.7 and the firmware on my airports is 7.6.1. I'm having a wierd issue where I can't use iTunes itself to send audio to the airports.  There is no mulitple speaker icon in the lower right corner like there

  • EPM 11.1.2.3 Security Patches or bugfix patches

    Dear Experts, Kindly note that we are in process of doing a New Implementation of EPM Suite 11.1.2.3 With the  following Modules 1. HFM 2. HPM 3. Essbase 4. FDQM I would like to know list of security patches which we are suppose to Install Installati

  • SAP IdM Script on Linux

    Hi All, I am trying to update an existing IdM installation running on Oracle 11 and RedHat linux. I am using the default scripts (.sh) available with SP09 but nothing is happening. I have amended include.sql to meet the database configuration but the

  • Router not connecting

    I have a wrt54g that i cannot get to see my motorola dsl modem.  I have a PPPoE connection with the login and password set, local ip is 192.168.1.1, DHCP is set to Enabled, wireless mode is Mixed, channel is set to 11,  WPA Algorithms is TKIP+AES. Th