804 boolean isEmpty = (availR.width < 0 || availR.height < 0); 805 Scrollable sv; 806 // Don't bother checking the Scrollable methods if there is no room 807 // for the viewport, we aren't going to show any scrollbars in this 808 // case anyway. 809 if (!isEmpty && view instanceof Scrollable) { 810 sv = (Scrollable)view; 811 viewTracksViewportWidth = sv.getScrollableTracksViewportWidth(); 812 viewTracksViewportHeight = sv.getScrollableTracksViewportHeight(); 813 } 814 else { 815 sv = null; 816 } 817 818 /* If there's a vertical scrollbar and we need one, allocate 819 * space for it (we'll make it visible later). A vertical 820 * scrollbar is considered to be fixed width, arbitrary height. 821 */ 822 823 Rectangle vsbR = new Rectangle(0, availR.y - vpbInsets.top, 0, 0); 824 825 boolean vsbNeeded; 826 if (vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS) { 827 vsbNeeded = true; 828 } 829 else if (vsbPolicy == VERTICAL_SCROLLBAR_NEVER) { 830 vsbNeeded = false; 831 } 832 else { // vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED 833 vsbNeeded = !viewTracksViewportHeight && (viewPrefSize.height > extentSize.height); 834 } 835 836 837 if ((vsb != null) && vsbNeeded) { 838 adjustForVSB(true, availR, vsbR, vpbInsets, leftToRight); 839 extentSize = viewport.toViewCoordinates(availR.getSize()); 840 } 841 842 /* If there's a horizontal scrollbar and we need one, allocate 843 * space for it (we'll make it visible later). A horizontal 931 if (oldHSBNeeded != hsbNeeded || 932 oldVSBNeeded != vsbNeeded) { 933 viewport.setBounds(availR); 934 // You could argue that we should recheck the 935 // Scrollable methods again until they stop changing, 936 // but they might never stop changing, so we stop here 937 // and don't do any additional checks. 938 } 939 } 940 } 941 942 /* We now have the final size of the viewport: availR. 943 * Now fixup the header and scrollbar widths/heights. 944 */ 945 vsbR.height = availR.height + vpbInsets.top + vpbInsets.bottom; 946 hsbR.width = availR.width + vpbInsets.left + vpbInsets.right; 947 rowHeadR.height = availR.height + vpbInsets.top + vpbInsets.bottom; 948 rowHeadR.y = availR.y - vpbInsets.top; 949 colHeadR.width = availR.width + vpbInsets.left + vpbInsets.right; 950 colHeadR.x = availR.x - vpbInsets.left; 951 952 /* Set the bounds of the remaining components. The scrollbars 953 * are made invisible if they're not needed. 954 */ 955 956 if (rowHead != null) { 957 rowHead.setBounds(rowHeadR); 958 } 959 960 if (colHead != null) { 961 colHead.setBounds(colHeadR); 962 } 963 964 if (vsb != null) { 965 if (vsbNeeded) { 966 if (colHead != null && 967 UIManager.getBoolean("ScrollPane.fillUpperCorner")) 968 { 969 if ((leftToRight && upperRight == null) || 970 (!leftToRight && upperLeft == null)) | 804 boolean isEmpty = (availR.width < 0 || availR.height < 0); 805 Scrollable sv; 806 // Don't bother checking the Scrollable methods if there is no room 807 // for the viewport, we aren't going to show any scrollbars in this 808 // case anyway. 809 if (!isEmpty && view instanceof Scrollable) { 810 sv = (Scrollable)view; 811 viewTracksViewportWidth = sv.getScrollableTracksViewportWidth(); 812 viewTracksViewportHeight = sv.getScrollableTracksViewportHeight(); 813 } 814 else { 815 sv = null; 816 } 817 818 /* If there's a vertical scrollbar and we need one, allocate 819 * space for it (we'll make it visible later). A vertical 820 * scrollbar is considered to be fixed width, arbitrary height. 821 */ 822 823 Rectangle vsbR = new Rectangle(0, availR.y - vpbInsets.top, 0, 0); 824 if(scrollPane.getClientProperty("ScrollPaneLayout.vsbAtTop") != null) { 825 vsbR.y = 0; 826 } 827 828 boolean vsbNeeded; 829 if (vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS) { 830 vsbNeeded = true; 831 } 832 else if (vsbPolicy == VERTICAL_SCROLLBAR_NEVER) { 833 vsbNeeded = false; 834 } 835 else { // vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED 836 vsbNeeded = !viewTracksViewportHeight && (viewPrefSize.height > extentSize.height); 837 } 838 839 840 if ((vsb != null) && vsbNeeded) { 841 adjustForVSB(true, availR, vsbR, vpbInsets, leftToRight); 842 extentSize = viewport.toViewCoordinates(availR.getSize()); 843 } 844 845 /* If there's a horizontal scrollbar and we need one, allocate 846 * space for it (we'll make it visible later). A horizontal 934 if (oldHSBNeeded != hsbNeeded || 935 oldVSBNeeded != vsbNeeded) { 936 viewport.setBounds(availR); 937 // You could argue that we should recheck the 938 // Scrollable methods again until they stop changing, 939 // but they might never stop changing, so we stop here 940 // and don't do any additional checks. 941 } 942 } 943 } 944 945 /* We now have the final size of the viewport: availR. 946 * Now fixup the header and scrollbar widths/heights. 947 */ 948 vsbR.height = availR.height + vpbInsets.top + vpbInsets.bottom; 949 hsbR.width = availR.width + vpbInsets.left + vpbInsets.right; 950 rowHeadR.height = availR.height + vpbInsets.top + vpbInsets.bottom; 951 rowHeadR.y = availR.y - vpbInsets.top; 952 colHeadR.width = availR.width + vpbInsets.left + vpbInsets.right; 953 colHeadR.x = availR.x - vpbInsets.left; 954 955 if(scrollPane.getClientProperty("ScrollPaneLayout.vsbAtTop") != null) { 956 vsbR.height += colHeadR.height; 957 } 958 959 /* Set the bounds of the remaining components. The scrollbars 960 * are made invisible if they're not needed. 961 */ 962 963 if (rowHead != null) { 964 rowHead.setBounds(rowHeadR); 965 } 966 967 if (colHead != null) { 968 colHead.setBounds(colHeadR); 969 } 970 971 if (vsb != null) { 972 if (vsbNeeded) { 973 if (colHead != null && 974 UIManager.getBoolean("ScrollPane.fillUpperCorner")) 975 { 976 if ((leftToRight && upperRight == null) || 977 (!leftToRight && upperLeft == null)) |