How to keep a label at the left side of a JScrollPane

Hi all
I am essentially trying to make a text block that doesn't move as the scrollpane scrolls (horizontally in my case)
Here's my code trying to do this simply using Graphics.drawString (not compilable - tell me if you need something that compiles):
          g.setFont(getTaskFont());
          g.setColor(getTaskLabelForeground());
          g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
          JScrollPane sp = ComponentUtilities.getJScrollPaneAncester(this);
          for (int i = 0; i < tasks.size() - 1; i++) {
               Task t = tasks.get(i + 1);
               FontMetrics fm = g.getFontMetrics();
               int y = i * (rowHeight + rowSpace) + fm.getAscent() + (rowHeight - fm.getHeight()) / 2;
               int strlen = fm.stringWidth(t.getName().toUpperCase());
               int start = getXLocationForTime(t.getStart());
               int end = getXLocationForTime(t.getFinish());
               int len = end - start;
               int x = 0;
               //System.out.println("task: " + t.getName());
               if (strlen < len) {
                    x = Math.min(end + 5, Math.max(start + 3, sp.getHorizontalScrollBar().getValue()));
               else {
                    x = end + 5;
               g.drawString(t.getName().toUpperCase(), x, y);
          }Here's my code trying to do this using a JLabel
               JScrollPane sp = ComponentUtilities.getJScrollPaneAncester(this);
               int y = i * (rowHeight + rowSpace); //+ fm.getAscent() + (rowHeight - fm.getHeight()) / 2;
               int strlen = fm.stringWidth(t.getName().toUpperCase());
               int start = getXLocationForTime(t.getStart());
               int end = getXLocationForTime(t.getFinish());
               int len = end - start;
               int x = 0;
               //System.out.println("task: " + t.getName());
               if (strlen < len) {
                    x = Math.min(end + 5, Math.max(start + 3, sp.getHorizontalScrollBar().getValue()));
               else {
                    x = end + 5;
               floaters.setLocation(x, y + (rowHeight - fm.getHeight()) / 4);
               floaters[i].repaint();
Both [i]almost work, but the scrolling is not smooth (blinks back & forth). It seemed like a double buffering problem, but when I added code to paint first to an image and then to screen the issue remained.
I also tried adding labels to the JLayeredPane popup layer, but I this solution is problematic also, as labels start drawing all over the place. Plus, I'd rather not have to keep track of the labels and be repositioning them in the first place.
Any advice on this is sincerely appreciated.
Thanks!
-Tom
Anyone know how to fix this?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Darryl Burke wrote:
a label at the left side of a JScrollPaneI take it <tt>setRowHeader</tt> / <tt>setRowHeaderView</tt> don't do what you want?
dbThat's a very helpful suggestion, and I think would solve the problem as stated, however in reading your answer I see now that I didn't state my problem well, and that what I am trying to do is much more complex than I originally thought it was.
Thanks tho, you have helped me gain clarity in what I am trying to do.

Similar Messages

  • How can I keep my signature on the left side when using rtl on mail application

    I'm writing in Hebrew & English on apple Mail application on OS X /mountain Lion.
    When I'm starting to write a mail in HEBREW it's automatically move the signature to the right side which I don't like it because my signature is in English (My Hebrew is a why better from my English ; )
    How can I keep the signature on the left side as default?
    Hope to get your support in this issue.
    Thanks in advance,
    Joni.

    Joni11 wrote:
    How could i do this?
    Sorry, I don't know.  But have you already tried selecting your sig and using the usual alignment tools?  It seems to work for me when used in the new message pane.

  • How can I turn off related search window, it keeps popping up on the left side of my screen when I refresh? This is very annoying

    This is very annoying, whenever I refresh a site, a window pops up on the left side of my screen of related searches, I want to turn this OFF

    '''Try Firefox Safe Mode''' to see if the problem goes away. [[Troubleshoot Firefox issues using Safe Mode|Firefox Safe Mode]] is a troubleshooting mode that turns off some settings and disables most add-ons (extensions and themes).
    ''(If you're using an added theme, switch to the Default theme.)''
    If Firefox is open, you can restart in Firefox Safe Mode from the Help menu by clicking on the '''Restart with Add-ons Disabled...''' menu item:<br>
    [[Image:FirefoxSafeMode|width=520]]<br><br>
    If Firefox is not running, you can start Firefox in Safe Mode as follows:
    * On Windows: Hold the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac: Hold the '''option''' key while starting Firefox.
    * On Linux: Quit Firefox, go to your Terminal and run ''firefox -safe-mode'' <br>(you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]] article to find the cause.
    ''To exit Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    When you figure out what's causing your issues, please let us know. It might help others with the same problem.
    Thank you.

  • How to display NEGATIVE sign on the left side of a number in SMARTFORMS

    Hi,
         In smartforms I'm trying to print some negative values, but the negative sign is displayed on the right hand side of the number.
    How can I display the '-' sign on the left hand side of a number. I tried the logic &value(<), it works well in sap scripts. Why is it not working in smartforms ?
    Eg :   I'm getting  the output  as  126.75 -
             I want :  - 126.75

    see this wiki which gives details for restrictions of formatting options (I guess you didn't declare the variable correctly, i.e. with the right data element): http://wiki.sdn.sap.com/wiki/display/ABAP/SAPscript#SAPscript-WhatarethevarioustextformattingoptionsinSAPscript%3F

  • How to display Success Message on the Left side of Screen

    I am displaying a Process Success Message after the ApplyMRU process, *#MRU_COUNT# row(s) updated*. By default, this message is displayed at the center of the screen. I would like to display this message at the left hand side of the screen.
    I am using APEX 4.0; Theme Sand - 10. I have tried changing the alignment for the success message position in the Page Template – One Level Tabs, HTML Body section. But I am not having any luck.
    Does anyone know how to change/override the default position for the success message?
    Thanks

    Andy,
    I tried what you suggested and the success message is still being displayed in the center of the page.
    I went to Template --> Page --> One Level Tabs. In the Header, I put the following lines before the </head>
    <style type="text/css">
    .t10messages {text-align:left;}
    </style>
    </head>
    <body #ONLOAD#>
    #FORM_OPEN#
    I do not have any other custom CSS. Just strictly using Theme 10 - Sand
    Any ideas on what else could be the reason?
    Thanks,
    DP
    Sorry for the delayed response - out for holidays.

  • How can I have 'Bookmarks' on the left side of the bar (it seems fixed on the right)?

    Without any difficulty, I can have the items in the Bookmarks Toolbar in any order I like. However, the Bookmarks Button is on the extreme right and I would like it on the left - how can I move it to the extreme left side?

    Go to toolbar customize and change "Show:" to Icons and Text so that you can see the existing/default Bookmarks button, then drag it from its current position over to the far left, than change "Show:" back to Icons only.

  • I keep getting a partial frame from the same website on the left side of the screen no matter what I'm viewing. How do I get rid of it?

    I even removed the site that keeps appearing on the left side as a bookmark. It is always the same. I've tried right click "This Frame" and all the resulting options to no avail.
    I just want the link I choose to fill the entire screen without about 20% being used up by the same partial frame on the left side.

    Oh, that's part of Voice Over?  Ok, I had the audio turned off, so I wasn't hearing anything, hence my confusion.
    Awesome, thanks for your help!
    Dave

  • How to I make pop up windows go back to the left side of the screen when they are moving to the right?

    Whenever I click on a link, a new window pops up. That's good, that's what I wanted. They've always opened on the left side of the screen. However, they are now opening in the middle of the screen. This has happened before and the screen eventually opened completely on the right. Last time this happened, I ended up having to delete something. I don't remember what, but it solved the issue. Please help!

    You can check for problems caused by a corrupted localstore.rdf file.
    *http://kb.mozillazine.org/Corrupt_localstore.rdf
    You can also try to emove the Firefox plist file (org.mozilla.firefox.plist).
    *http://www.macfixit.com/article.php?story=20060606082246983 How .plist files become corrupt and troubleshooting the results
    Go to "~/Library/Preferences" and remove the plist file for Firefox (org.mozilla.firefox.plist)

  • I have an iPhone 4 and my lock button is jammed and I also can not touch anything on the left side of my screen well as any pop ups from the phone itself, so i can not get past the set up stage in reset process...how can i fix it/can it be fixed?

    I have an iPhone 4 and my lock button is jammed and I also can not touch anything on the left side of my screen well as any pop ups from the phone itself, so i can not get past the set up stage in reset process...how can i fix it/can it be fixed?

    Make an appointment at the genius bar and get the phone replaced.

  • I put in my memory card to the left side of the computer, but I cannot find the file of pictures anywhere. Its not even on my desktop. What should I do and how can I get it to show up on my desktop?

    I put in my memory card to the left side of the computer, but I cannot find the file of pictures anywhere. Its not even on my desktop. What should I do and how can I get it to show up on my desktop?

    If your Mac is new-ish and has one of the Lions as its OS, the drives, cards, USB sticks no longer show up, even though they're there. Go to Finder's Preferences and tick the corresponding items in the General and Sidebar tabs.

  • How can I display all of my bookmarks along the left side of my browser window like earlier versions of Firefox?

    I like the bookmarks on the left side of the screen. I don't want to be navigating through a tree of all of my various bookmarks. How can I display all of my bookmarks along the left side of my browser window like earlier versions of Firefox?

    View > Sidebar > Bookmarks (Ctrl+B)
    Press F10 or tap the Alt key to bring up the "Menu Bar" temporarily if the Menu Bar is hidden.
    *https://support.mozilla.com/kb/how-do-i-use-bookmarks

  • How do you put your bookmarks on left side of the web page.

    I the older version of Firefox I had my Bookmarks on the left side of the window, how can I get this back in Firefox 4?

    '''{Ctrl + B}''' or View > Sidebar > Bookmarks

  • How do I stop the side bar from popping up in the left side of my screen when I click on a bookmark on my tool bar?

    I just got a new laptop, and redownloaded mozilla as my browser. I've set up my tool bar tabs but when I click them they only appear on the left side bar when I click them. This didn't happen before on my previous laptop, so I'm confused on how to get it to stop opening the sidebar when I click them, and have them instead appear in my main window.

    Opening in the sidebar is the default for bookmarks that are created via a link or button on a website.
    You can check the properties of a bookmark via the right-click context menu in the sidebar (Ctrl+B; Command+B on Mac).
    In the Bookmarks Manager (Bookmarks > Show All Bookmarks) you can click the More button in the Details pane at the bottom right.
    Make sure that "Load this bookmark in the sidebar" is not selected.

  • ICal 5: day view: how can the list on the left side be hidden?

    hi fellows
    how can the list on the left side in the day-view of iCal 5 be hidden, so that the computer-screen only shows the graphic-bars (right side)?
    Thanks a lot for your help
    Mullika

    Sorry, but there was nothing in your last post.

  • The new Pages in Mavericks OS:  How can I get a ruler down the left side?  When I click on "Show Rulers,"  all I get is a ruler at the top.

    In the new Mavericks OS, when I use Pages, I cannot find a way to get a ruler on the left side of the document.  When I click on "Show rulers," all I get is a ruler at the top of the document.  How can I get a ruler on the left side?

    Wait for an Apple update to Pages which is suppose to put the vertical ruler feature back in.

Maybe you are looking for