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 3 of 3

Thread: I cannot get it to scroll to a tab just added.

  1. #1
    Member GoodbyeWorld's Avatar
    Join Date
    Jul 2012
    Location
    Hidden command post deep within the bowels of a hidden bunker somewhere under a nondescrip building
    Posts
    383
    My Mood
    Angry
    Thanks
    46
    Thanked 63 Times in 63 Posts

    Default I cannot get it to scroll to a tab just added.

    I've tried setSelectedIndex(), which, according the API, SHOULD work, but it's still staying where it was. In a tabbed pane with lots of tabs, this is sure to tick off users if it doesn't auto-scroll to a newly added tab at the end.

    However, the issue appears to be within the API itself I've heard. Does anyone know of a platform-independent fix?

    I've tried SwingUtilities.runLater and I've tried setSelectedIndex(). I also tried setSelectedTabComponent(), which kept throwing an exception saying its not visible or not in the tabbed pane or something stupid.

    I'm really upset and wanna

    Does anyone know a way around this glitch? So far, I can find nothing online that works. (And, I think I may have found one, but it's platform specific, meaning, it may work on one OS but not another, which isn't what I want.)

    -----Update------
    I thought it must be the API itself. I was right. http://bugs.sun.com/view_bug.do?bug_id=6285072. So, other than using a practically pathetic tab pane, what else can I do to get around this crippling glitch?


    ----Update Later------
    Ok, that might not be my issue. The issue isn't that it's not showing the component, it IS showing the component, the thing is, even if the tab is selected, the poor user has to scroll to the end if a new tab is added, which, if they're at the beginning in the view, is a pain in the you-know-what.

    However, the issue still appears to be the API itself.

    ----More info-------

    I've also tried

    javax.swing.Action action = tabPane.getActionMap().get("navigateNext");
    action.actionPerformed(new ActionEvent(tabPane, ActionEvent.ACTION_PERFORMED, "Unnamed") );


    Even that, which can't work in every case as tab names my vary depending on whether it's a tabbed addressbook or a tabbed notepad, and it won't work even in this specific case either.


    ----More update------
    I found another oracle issue related to the bug here, but the page has a hard time opening.

    http://bugs.sun.com/bugdatabase/view...bug_id=5037709
    JavaScript is NOT Java.


  2. #2
    Member GoodbyeWorld's Avatar
    Join Date
    Jul 2012
    Location
    Hidden command post deep within the bowels of a hidden bunker somewhere under a nondescrip building
    Posts
    383
    My Mood
    Angry
    Thanks
    46
    Thanked 63 Times in 63 Posts

    Default Re: I cannot get it to scroll to a tab just added.

    Ok, the issue seems to be that it CAN scroll to the tab IF the tab is inside the visible viewport part on the screen, otherwise it won't. Any idea how to fix that?

    (I found a class online that would fix it, but it's custom and I'd need to find a ton of source codes to get it to run.) Is there something I can do to fix it without having to write an entire new class?

    If I do it numerically, it will go to the tab before the last index, though it'll crash if I go for the last actual index (the new one added). I have added the new tab before I've told it to select the index so I'm not even sure why it's going wrong here. It can even scroll outside the viewport but seems to not work if I use a variable.

    Why the heck is this happening?


    Ok, I think I got it solved. I got it to later move to the next to last one in the view. It still wasn't showing. However, when I made the screen its full max, THEN it showed up.

    Why wouldn't it scroll to it completely unless I had the screen at full max?

    Also, why wouldn't it scroll if I also did setSelectedComponent() in addition to setSelectedIndex()?
    JavaScript is NOT Java.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,290
    My Mood
    Mellow
    Thanks
    252
    Thanked 777 Times in 762 Posts

    Default Re: I cannot get it to scroll to a tab just added.

    It's an interesting thread (sort of), but it's hard to imagine all that could be going wrong or right without some actual code to see that demonstrates the problem(s), the various workarounds you've found, and the result of resizing the frame to max firsthand.

    The original link you posted gave the impression the problem was actually solved in Java, so I'm not sure why you're still having a problem unless you're using a version previous to the fix, or you're experiencing a different problem which may or may not BE a real problem. GUI "problems" that are solved by changing the container's size are usually due to a forgotten call to repaint() or revalidate() or an inadequate/inappropriate design.

    Per your latest discovery, why not just add the tab inside the visible viewport?

Similar Threads

  1. Grid, tab do pacote Swuing
    By JeovaneOtoniel in forum Member Introductions
    Replies: 2
    Last Post: June 3rd, 2012, 02:37 PM
  2. previous tab's functions no longer working when new tab is created
    By captain in forum What's Wrong With My Code?
    Replies: 13
    Last Post: April 26th, 2012, 02:12 PM
  3. JTabbedPane with two Panels in the same tab?
    By cadarn in forum AWT / Java Swing
    Replies: 1
    Last Post: August 3rd, 2011, 11:48 AM
  4. Setting tab size for JEditorPane
    By helloworld922 in forum AWT / Java Swing
    Replies: 5
    Last Post: September 6th, 2010, 12:20 PM