Update JScrollBar Extent when JScrollPane Component Changes Preferred Size

Hi folks,
I have an interesting, but concise problem that I've been working on for a few days but haven't had any luck.
In Java 1.5 or Java6, I have a JScrollPane which contains a JPanel. The settings of the scrollbar (for example, the Extent [the width of the "thumb" or "slider" on the scrollbar]) are determined based on the dimension of the underlying contained component, in particular, the Preferred Size.
My problem is this. The underlying component has a "zoom" capability, such that the actual size of the component can and does change (i.e., zooming out reduces its preferred size).
Happily, the consequence of this design is that the "size" or extent of the scrollbar sliders/thumbs adjusts to give visual indication of the proportion of the current view (ViewPort View dimension) to the underlying component's dimension.
The problem is, the scrollbar sliders do NOT automatically update their size in response to programatically changing the JScrollPane's contained component's PreferredSize. They WILL be updated if I RESIZE the parent JFrame manually.
But for the life of me, I can't get those sliders to update programatically. I've tried repaint(), update, validate(), etc. on the JScrollPane but no luck.
I've done a debug to get into the stack trace of the Sun code during run time, and there's a lot going on... there's a doLayout(), a reshape() (deprecated), firing various property changes, but I just can't seem to find a good hook into getting the scrollbar to update its internal Bounds model and repaint accordingly. Calling setBounds() on the JScrollPane I think would trigger it, however, looking at the code.. it seems to ignore firing property events and repainting of the bounds themselves didn't actually change (i.e. no action happens if the current dimension and specified dimension in the argument to setBounds() are the same).
Any ideas here on how to this to get those sliders to update programatically with a new value for the extent?
Thanks,
--Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Understood! It was my intention to give credit and now I'm happy to do so! I've now assigned the Duke Points. Minor usability issue, it was not obvious how to do this the first time (and I did poke around a little before I gave up earlier in the day, reverting to just assigning him the correct question). I've got it now though! Thanks again--definitely knocked out an issue I was having today and allowed me to move on to add'l development work today.
All the best!
--Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • JScrollPane content changes preferred size; how to show the bars

    Before I have to delve deeply into the code of JScrollPane... I have a component inside a JScrollPane with as-needed scrollbars that changes its preferred size. I can invalidate and repaint every component in the tree, but the scrollbars don't show until I do a hide and reshow the window. Why?

    if you are happy with an answer - even your own self-muttering <g> please mark the question as answered.
    Cheers
    Jeanette

  • Lumia 900 - Updated to 7.8 - can't change icon siz...

    After updating my Lumia 900 phone to 7.8, I don't see the second icon in the lower right to change the size of the icons?  Am I missing a setting or something?  I click and hold down an icon, but I only see the unpin icon in the top right.
    Thanks in advance.
    Tom
    Solved!
    Go to Solution.

    Your Nokia Lumia 900 was updated to 7.5 CR3 (Tango). The 7.8 update has not yet been released. It is still under development and destined for release later this year.
    You can check your version number under Settings > About.
    Hope this helps.
    Microsoft Windows Phone MVP
    Follow me on Twitter: @ThisIsMetro
    Press the 'Accept As Solution' icon if I have solved your problem, click on the Star Icon below if my advice has helped you!

  • Have been using Thunderbird for years..can someone please--please--please-tell me when I can change font sizes numerically???

    I have been using Thunderbird for ages and just love the way it works. However, is there any possibility that the ability to alter font size from '10' to '12' instead of 'bigger or smaller' be available??
    It would be awesome to be able to do that.
    Thanks for your time in advance
    Michael
    New Zealand

    Numerical font size change is not a choice using Thunderbird. You can open a new "write mail" an increase font size by choosing the first and second "A" in the body line directly below the subject line. You have to be in the body of the letter to make this available. Also, in tools, options, composition, general, HTML you can set both color and font size with choices from xx small to xx large (by default), and then increase the default font size as stated above. As always, remember to click apply or OK when making these changes.
    ''Polaris224 [[#question-1056979|said]]''
    <blockquote>
    I have been using Thunderbird for ages and just love the way it works. However, is there any possibility that the ability to alter font size from '10' to '12' instead of 'bigger or smaller' be available??
    It would be awesome to be able to do that.
    Thanks for your time in advance
    Michael
    New Zealand
    </blockquote>

  • Any Way to Update Hyperlink Text When Topic Title Changes?

    Is there any to add a hyperlink "field" to a topic that will update when the title of the hyperlinked topic changes? Thanks in advance. RR

    Hi there
    I'm guessing you are asking this.
    You have topic A that has a link to topic B. The link currently reads topic B. But if you change the Title of topic B to perhaps topic X, you want the hyperlink to also change and reflect topic X?
    Personally I can't think of a way to make it happen. Maybe with a variable, but you would have to update the variable manually.
    Perhaps someone else has a clever solution for you.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • Automatic updation in  PO when info record change

    Dear All,
    We have a scenerio where we purchase copper components from one vendor. The rates are changed on every 15 days.
    i.e. from 1-15th the rates are x, and from 16th-30th the rates are y. The supplier sends material on new price on 16th, irrespective of pending order as per old price.
    Can we have some sort of facility so that pending orders price of some specific items get updated, as soon as we change in info record.
    Suggest some solution.
    Thanks in Advance,
    Ishu

    Hi
    In PO, ie) in ME21N.....Item Details -
    > Condition Control Tab -
    > You can see the "Pricing  Date Category" Field......
    If it is not found there....then,
    Goto -
    > OLME -
    > PO -
    >  Define Screen Layout at Document Level -
    > Choose Field Selection key "NBF"  and go into details -
    > Choose Field Selection Group "Quantity and Price"  and go into details -
    > There you maintain the "Pricing Date Control" field as Optional Entry or as Required Entry as per your requirement and SAVE...
    Now you can get the Pricing Date Category field in PO...
    Reward if useful
    Regards
    S.Baskaran

  • Firefox 4 Beta 7 freezing when trying to change window size

    Since I upgraded to FF4 beta 7 I can't move an un-maximized window of the browser (this also applies to pop-up windows). The browser completely freezes and I have to start the task manager to finish the process. It's really annoying.

    This can be a problem with Direct2D, you can try to disable the hardware acceleration.
    *Tools > Options > Advanced : General: Browsing: [ ] "Use hardware acceleration when available"

  • Change brush  sizes using [  ] too slow

    I've recently swapped from Windows to Mac and I'm glad to be on Mac now. But whenever I'm changing brush sizes using the bracket keys the response time is way to slow.. I search the forum but found nothing on this. anyone have a fix for this..
    Running Leopard with OS 10.5.4 three internal harddrives and 10 gigs ram.
    All updates and patches were installed prior to photoshop.
    Machine is one week old.

    I completely remove Photoshop and did a clean install. Before changing anything I opened an image and tried increasing and decreasing my brush size using the bracket keys and everything was fine. The brush changes as soon as you hit the bracket key.
    But as soon as you highlight the info palette top right corner and make it active then come back over the picture and try changing the brush size I'm getting a one second delay. If I hit the bracket key three times quickly the brush completely disapears and then reapears at the appropriate size.
    This is a clean install with no plugins, no new fonts, no new nothing.
    I then downloaded the latest upgrades.. Reset disk permission, ran the chron scripts and I'm getting the exact same reaction from photoshop when attempting to change brush size with the bracket keys.
    Can anybody else reproduce this buy highlighting the info palette??
    I called a buddy who also recently purchased a new Mac Pro and his machine is doing the exact same thing.

  • ACR 7.3 Bug on Adjustment Brush tool - changing brush size problem.

    I update photoshop and using ACR 7.3 and now having big problem when I use Adjustment Brush took. Phe problem is when try to change brush size with holding right mouse button and moving the mouse. Behavior completely changed and its impossible to predict if I move mouse right what will happen.
    Please check solution for it. old behaviour was great. I think this is not new feature, its bug.
    Thanks in advance.

    No need.
    Already bugged and acknowledged: http://feedback.photoshop.com/photoshop_family/topics/bug_crash_adjustment_brush.

  • HT201279 Cannot change font size

    Am having trouble changing my font size when printing some emails and attachments . So small i cannot read .When I do change the size it changes back when I start to print . Anyone have the same problem .

    I have stopped using Text Edit as I find it flaky. Instead I prefer Bean:
    http://www.bean-osx.com/Bean.html
    which does not have that problem!

  • HT203421 i buy a macbook air with my friend and i changed the apple id also.at first i can update the application but now its impossible to update the application.when i clock to update it shows the id of my fren andsomebody do you have idea to solve this

    i buy a macbook air with my friend and i changed the apple id also.at first i can update the application but now its impossible to update the application.when i clock to update it shows the id of my fren andsomebody do you have idea to solve this problem.

    The first thing to do with a second-hand computer is to erase the internal drive and install a clean copy of OS X. You — not the previous owner — must do that. How you do it depends on the model, and on whether you already own another Mac. If you're not sure of the model, enter the serial number on this page. Then find the model on this page to see what OS version was originally installed.
    1. You don't own another Mac.
    If the machine shipped with OS X 10.4 or 10.5, you need a boxed and shrink-wrapped retail Snow Leopard (OS X 10.6) installation disc from the Apple Store or a reputable reseller — not from eBay or anything of the kind. If the machine has less than 1 GB of memory, you'll need to add more in order to install 10.6. Preferably, install as much memory as it can take, according to the technical specifications.
    If the machine shipped with OS X 10.6, you need the installation media that came with it: gray installation discs, or a USB flash drive for some MacBook Air models. For early MBA models, you may need a USB optical drive or Remote Disc. You should have received the media from the previous owner, but if you didn't, order replacements from Apple. A retail disc, or the gray discs from another model, will not work.
    To boot from an optical disc or a flash drive, insert it, then reboot and hold down the C key at the startup chime. Release the key when you see the gray Apple logo on the screen.
    If the machine shipped with OS X 10.7 or later, you don't need media. It should boot into Internet Recovery mode when you hold down the key combination option-command-R at the startup chime. Release the keys when you see a spinning globe.
    2. You do own another Mac.
    If you already own another Mac that was upgraded in the App Store to the version of OS X that you want to install, and if the new Mac is compatible with it, then you can install it. Use Recovery Disk Assistant to create a bootable USB device and boot the new Mac from it by holding down the C key at the startup chime. Alternatively, if you have a Time Machine backup of OS X 10.7.3 or later on an external hard drive (not a Time Capsule or other network device), you can boot from that by holding down the option key and selecting it from the row of icons that appears. Note that if your other Mac was never upgraded in the App Store, you can't use this method.
    Once booted in Recovery, launch Disk Utility and select the icon of the internal drive — not any of the volume icons nested beneath it. In the Partition tab, select the default options: a GUID partition table with one data volume in Mac OS Extended (Journaled) format. This operation will permanently remove all existing data on the drive.
    After partitioning, quit Disk Utility and run the OS X Installer. You will need the Apple ID and password that you used to upgrade. When the installation is done, the system will automatically reboot into the Setup Assistant, which will prompt you to transfer the data from another Mac, its backups, or from a Windows computer. If you have any data to transfer, this is usually the best time to do it.
    Then run Software Update and install all available system updates from Apple. To upgrade to a major version of OS X newer than 10.6, get it from the Mac App Store. Note that you can't keep an upgraded version that was installed by the previous owner. He or she can't legally transfer it to you, and without the Apple ID you won't be able to update it in Software Update or reinstall, if that becomes necessary. The same goes for any App Store products that the previous owner installed — you have to repurchase them.
    If the previous owner "accepted" the bundled iLife applications (iPhoto, iMovie, and Garage Band) in the App Store so that he or she could update them, then they're linked to that Apple ID and you won't be able to download them without buying them. Reportedly, Apple customer service has sometimes issued redemption codes for these apps to second owners who asked.
    If the previous owner didn't deauthorize the computer in the iTunes Store under his Apple ID, you wont be able to  authorize it immediately under your ID. In that case, you'll either have to wait up to 90 days or contact iTunes Support.

  • DefaultCellEditor in JTable can not update itself when the value changes

    Hi,
    I have a JTable which has 4 columns. The 3rd column has a comboBox. whenever I select an item from the first row, the cell at (currentrow, 4thcolumn) will be updated according to the item selected.
    Now the problem is, after selecting the item in any cell with 3rd column, the row is updated correctly, but then all comboBox in column 3 are gone! I cannot figure out what causes this. Please help! Any suggestion will be greatly appreciated!
    Jing

    Thanks! Could you give more details on how to use the second approach?
    I have a table with two columns, one called ID and the other called Value. I'm using JComboBox for the Value column. Whenever I select an item from the comboBox, I want the value in the cell under the ID column to change value to the value selected in the comboBox.
    The problem I'm having now is although I can change the value in the comboBox and which triggers the event to change the value under the ID column, when I click the comboBox of another row, the cell under ID of the previous row changed also, before the value under ID of the current selected row.
    I think the problem is there is no distinct comboBox for each row of the table. Seems like when one box change and trigger an event, that event performed in every other rows in the table.
    Following is the code:
    public class Test extends JPanel{
         DefaultTableModel tm;
         JTable table;
         JScrollPane nscrollPane;
         public int total=4;
         public Vector datavec, thvec;
         public Test(Vector datavec, Vector thvec){
              this.datavec=datavec;
              this.thvec=thvec;
         tm = new DefaultTableModel(datavec,thvec);
              table = new JTable(tm);
              table.addMouseListener(new PopupListener(table));
    // table.addMouseListener(new PopupListener(table));
    //tm.setTableHeader(table.getTableHeader()); //ADDED THIS
    int height = table.getRowHeight()*table.getRowCount();
    table.setPreferredScrollableViewportSize(new Dimension(500, height));
    //Create the scroll pane and add the table to it.
    nscrollPane = new JScrollPane(table);
    setUpNNColumn(table, table.getColumnModel().getColumn(1));
    //Add the scroll pane to this panel.
    add(nscrollPane);
    public void updateLabel(Integer size)
         int r=table.getSelectedRow();
         if(r!=-1)
         ((Vector)datavec.elementAt(r)).setElementAt(size, 0);
         repaint();
    public void setUpNNColumn(JTable table, TableColumn nnColumn) {
              //Set up the editor for the sport cells
              JComboBox comboBox = new JComboBox();
              comboBox.addActionListener(new ComboBoxListener());
              int num=total/2;
              for(int i=0; i<2; i++){
                   comboBox.addItem(new Integer(num*(i+1)));
              comboBox.setSelectedIndex(1);
              nnColumn.setCellEditor(new DefaultCellEditor(comboBox));
    private class ComboBoxListener implements ActionListener{
         public void actionPerformed(ActionEvent e)
              JComboBox cb = (JComboBox)e.getSource();
    Integer size = (Integer)cb.getSelectedItem();
         updateLabel(size);
    private static void createAndShowGUI(Vector a, Vector b) {
    \ JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame = new JFrame("Nearest Neighbor Fact Table");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create and set up the content pane.
    Test newContentPane = new Test(a, b);
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
         int patidx, hitnum=2;
         Vector a=new Vector();
         Vector a1=new Vector();
         Vector a2=new Vector();
         a1.add(new Integer(1));
         a1.add(new Integer(4));
         a.add(a1);
         a2.add(new Integer(2));
         a2.add(new Integer(4));
         a.add(a2);
         Vector b=new Vector();
         b.add("ID");
         b.add("Value");
         //StatTableGUI.createAndShowGUI(gd);
         Test.createAndShowGUI(a,b);
    Any suggestions? Thanks!
    Jing

  • Update of XML syndication map when XSD is changed

    All,
    So we recently upgraded to MDM 7.1 SP 06 and found a new feature which we were waiting for quiet some time. Thought i'll share with the community as well.
    Update of XML syndication map when XSD is changed in Console
    In earlier SP's of MDM, if we had to update an XML syndication map, we had to upload the new XSD in Console, go to syndicator and basically re-create the whole map. there was no way for syndicator to preserve the old mapping.
    Well with this new feature, the old mapping is preserved, we only need to re-map the new fields.
    The process is as below:
    1. Upload the new XSD in Console.
    2. Go to syndicator and open the syndication map which you want to update(File->Open).
    3. Click File -> Update XML Schema. (this is the new option)
    4. It will give a pop-up, select the new schema you have uploaded in console and hit OK.
    5. You will get a prompt saying that syndication map is being changed, hit OK.
    6. Now you will see the new XSD in syndicator, the older fields are still mapped, you only need to map the new fields.
    It a nice feature which will definitely save lot of time. Thanks SAP
    Regards
    Aamir

    If this post answered your question or helped, please mark it as such.
    This works.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Script>
        <![CDATA[
          import mx.events.DataGridEvent;
          import mx.collections.ArrayCollection;
          [Bindable] private var ac:ArrayCollection = new ArrayCollection([
            {bgColor: "0xFF0000", num: 100, name: "Test1"},
            {bgColor: "0xFF0000", num: 200, name: "Test2"},
            {bgColor: "0xFF0000", num: 300, name: "Test3"},
          private function changeBK(evt:DataGridEvent):void{
            var row:uint = evt.rowIndex;
            var data:Object = ac.getItemAt(row);
            data.bgColor = "0x00FF00";
        ]]>
      </mx:Script>
      <mx:DataGrid id="dg" dataProvider="{ac}" itemEditEnd="changeBK(event);"
        editable="true">
        <mx:columns>
          <mx:DataGridColumn dataField="num">
            <mx:itemRenderer>
              <mx:Component>
                <mx:TextArea backgroundColor="{data.bgColor}" text="{data.num}"/>
              </mx:Component>
            </mx:itemRenderer>
          </mx:DataGridColumn>
          <mx:DataGridColumn dataField="name"/>
        </mx:columns>   
      </mx:DataGrid>
    </mx:Application>

  • Using Adobe Photoshop CS2 version 9 and have updated it, but when stacking photos, it comes up with PSD, whereas I want Jpeg, and I change the format to Jpeg and the box then comes up with cannot save as there is a program error. Be very grateful for help

    Using Adobe Photoshop CS2 version 9 and have updated it, but when stacking photos, it comes up with PSD, whereas I want Jpeg, and I change the format to Jpeg and the box then comes up with cannot save as there is a program error. Be very grateful for help with this, please.

    jpg does not support Layers.
    Just to make sure, what exactly do you mean by "stacking photos" and what do you want to achieve thereby?

  • How to update the table when change list item in classic report

    hi ,
    i worked with apex 4.2 and i create normal classic report with one select list(named loved)Column ,now i want to update table when user change the list with new value ,i can't create dynamic action to do this,i create check box with primary key and loop for check item to update the table but i can't get the value of list item. and for more speed the user want to do this when change the list value.
    my question
    1- how to do this by javascript and get the value from list item and update the table with new value
    2- is i must use API to create list item so i can get the value of item in report or what.
    Thanks
    Ahmed

    I coded the following to give you direction:
    1. In the "Element Attributes" section of the DEPTNO column, I call a javascript function as:
    onchange = "javascript:updateTable(this);"2. I wrote a simple javascript function that shows an alert when the user changes the select list as:
    <script language="JavaScript" type="text/javascript">
    function updateTable(pThis)
        var vRow = pThis.id.substr(pThis.id.indexOf('_')+1);
        alert('Row# - '+ vRow + ' has the value - ' + pThis.value);
    </script>Now, you can call a AJAX on-demand process inside the javascript function to update the database value.

Maybe you are looking for

  • How to check the value in Table CDPOS

    Mostly I can't see the following fields value in the table CDPOS,   (1) CDPOS-VALUE_NEW   (2) CDPOS-VALUE_OLD In fact, it should have values, so how to check the values, is there any special method needed? Thanks and best regards.

  • Java Web Start and JAAS

    Has anybody tried to use JAAS in an application launched via Java Web Start? I'm experiencing problems with it. (The application works fine when being launched directly on the client.) If somebody already successfully tried, please let me know. Do I

  • I dropped my ipod touch 4 apple give me a new one under warrenty?

    I got an ipod touch 4th gen for christmas and its brand new. about a week ago i dropped it from about 4-5 feet. the glass shatterd and half of the lights on the screen dont work. everything is fine everything works on the ipod but at midway on the ip

  • SQL PLUS/ ORACLE

    HELLO, I DOWNLOADED 9i DATABASE 9.2.0.1.0 TO ACCESS THE SQL PLUS APPLICATION TO PRACTICE SQL. UPON THE LOGIN SCREEN WHEN IT ASK TO PUT IN USER I.D.,PASSWORD, AND HOST STRING. I RECEIVE AN ERROR MESSAGE THAT SAYS "ORA-12560: TNS: PROTOCOL ADAPTER ERRO

  • InDesign CS6 TOC Issues

    I can create a simple TOC but if I implement some of the options (eg, chapter head entry style) and then save and close, I can no longer reopen the file? Is this a known problem?