Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
282,700
void (JScrollPane sp) { super.syncWithScrollPane(sp); if (sp instanceof JBScrollPane) { statusComponent = ((JBScrollPane)sp).getStatusComponent(); } }
syncWithScrollPane
282,701
void (String s, Component c) { if (s.equals(STATUS_COMPONENT)) { statusComponent = addSingletonComponent(statusComponent, c); } else { super.addLayoutComponent(s, c); } }
addLayoutComponent
282,702
void (Container parent) { JScrollPane pane = (JScrollPane)parent; // Calculate inner bounds of the scroll pane Rectangle viewportBounds = new Rectangle(pane.getWidth(), pane.getHeight()); final boolean isOverlappingScrollBar = isOverlappingScrollBar(pane); @NotNull Rectangle wholePaneBounds = viewportBounds.getBounds(); JBInsets.removeFrom(viewportBounds, pane.getInsets()); // Determine positions of scroll bars on the scroll pane Object property = pane.getClientProperty(Flip.class); Flip flip = property instanceof Flip ? (Flip)property : Flip.NONE; boolean hsbOnTop = flip == Flip.BOTH || flip == Flip.VERTICAL; boolean vsbOnLeft = pane.getComponentOrientation().isLeftToRight() ? flip == Flip.BOTH || flip == Flip.HORIZONTAL : flip == Flip.NONE || flip == Flip.VERTICAL; // If there's a visible row header remove the space it needs. // The row header is treated as if it were fixed width, arbitrary height. Rectangle rowHeadBounds = new Rectangle(viewportBounds.x, 0, 0, 0); if (rowHead != null && rowHead.isVisible()) { rowHeadBounds.width = min(viewportBounds.width, rowHead.getPreferredSize().width); viewportBounds.width -= rowHeadBounds.width; if (vsbOnLeft) { rowHeadBounds.x += viewportBounds.width; } else { viewportBounds.x += rowHeadBounds.width; } } // If there's a visible column header remove the space it needs. // The column header is treated as if it were fixed height, arbitrary width. Rectangle colHeadBounds = new Rectangle(0, viewportBounds.y, 0, 0); if (colHead != null && colHead.isVisible()) { colHeadBounds.height = min(viewportBounds.height, colHead.getPreferredSize().height); viewportBounds.height -= colHeadBounds.height; if (hsbOnTop) { colHeadBounds.y += viewportBounds.height; } else { viewportBounds.y += colHeadBounds.height; } } // If there's a JScrollPane.viewportBorder, remove the space it occupies Border border = pane.getViewportBorder(); Insets insets = border == null ? null : border.getBorderInsets(parent); JBInsets.removeFrom(viewportBounds, insets); if (insets == null) insets = EMPTY_INSETS; // At this point: // colHeadBounds is correct except for its width and x // rowHeadBounds is correct except for its height and y // bounds - the space available for the viewport and scroll bars // Once we're through computing the dimensions of these three parts // we can go back and set the bounds for the corners and the dimensions of // colHeadBounds.x, colHeadBounds.width, rowHeadBounds.y, rowHeadBounds.height. // Don't bother checking the Scrollable methods if there is no room for the viewport, // we aren't going to show any scroll bars in this case anyway. boolean isEmpty = viewportBounds.width < 0 || viewportBounds.height < 0; Component view = viewport == null ? null : viewport.getView(); Dimension viewPreferredSize = view == null ? new Dimension() : view.getPreferredSize(); if (view instanceof JComponent && !view.isPreferredSizeSet()) { JBInsets.removeFrom(viewPreferredSize, JBViewport.getViewInsets((JComponent)view)); } Dimension viewportExtentSize = viewport == null ? new Dimension() : viewport.toViewCoordinates(viewportBounds.getSize()); // workaround for installed JBViewport.ViewBorder: // do not hide scroll bars if view is not aligned Point viewLocation = new Point(); if (view != null) viewLocation = view.getLocation(viewLocation); // If there's a vertical scroll bar and we need one, allocate space for it. // A vertical scroll bar is considered to be fixed width, arbitrary height. boolean vsbRequiresSpace = false; boolean vsbNeeded = false; int vsbPolicy = pane.getVerticalScrollBarPolicy(); if (!isEmpty && vsbPolicy != VERTICAL_SCROLLBAR_NEVER) { vsbNeeded = vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS || isVerticalScrollBarNeeded(view, viewLocation, viewPreferredSize, viewportExtentSize); } Rectangle vsbBounds = new Rectangle(0, viewportBounds.y - insets.top, 0, 0); if (vsb != null) { if (isAlwaysOpaque(view)) vsb.setOpaque(true); vsbRequiresSpace = vsb.isOpaque() && !isOverlappingScrollBar; if (vsbNeeded) { adjustForVSB(viewportBounds, insets, vsbBounds, vsbRequiresSpace, vsbOnLeft, isOverlappingScrollBar, wholePaneBounds); if (vsbRequiresSpace && viewport != null) { viewportExtentSize = viewport.toViewCoordinates(viewportBounds.getSize()); } } } // If there's a horizontal scroll bar and we need one, allocate space for it. // A horizontal scroll bar is considered to be fixed height, arbitrary width. boolean hsbRequiresSpace = false; boolean hsbNeeded = false; int hsbPolicy = pane.getHorizontalScrollBarPolicy(); if (!isEmpty && hsbPolicy != HORIZONTAL_SCROLLBAR_NEVER) { hsbNeeded = hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS || isHorizontalScrollBarNeeded(view, viewLocation, viewPreferredSize, viewportExtentSize); } Rectangle hsbBounds = new Rectangle(viewportBounds.x - insets.left, 0, 0, 0); if (hsb != null) { if (isAlwaysOpaque(view)) hsb.setOpaque(true); hsbRequiresSpace = hsb.isOpaque() && !isOverlappingScrollBar; if (hsbNeeded) { adjustForHSB(viewportBounds, insets, hsbBounds, hsbRequiresSpace, hsbOnTop, isOverlappingScrollBar, wholePaneBounds); // If we added the horizontal scrollbar and reduced the vertical space // we may have to add the vertical scrollbar, if that hasn't been done so already. if (vsb != null && !vsbNeeded && vsbPolicy != VERTICAL_SCROLLBAR_NEVER) { if (!hsbRequiresSpace) { viewPreferredSize.height += hsbBounds.height; } else if (viewport != null) { viewportExtentSize = viewport.toViewCoordinates(viewportBounds.getSize()); } vsbNeeded = isScrollBarNeeded(viewLocation.y, viewPreferredSize.height, viewportExtentSize.height); if (vsbNeeded) adjustForVSB(viewportBounds, insets, vsbBounds, vsbRequiresSpace, vsbOnLeft, isOverlappingScrollBar, wholePaneBounds); } } } // Set the size of the viewport first, and then recheck the Scrollable methods. // Some components base their return values for the Scrollable methods on the size of the viewport, // so that if we don't ask after resetting the bounds we may have gotten the wrong answer. if (viewport != null) { viewport.setBounds(viewportBounds); if (!isEmpty && view instanceof Scrollable) { viewportExtentSize = viewport.toViewCoordinates(viewportBounds.getSize()); boolean vsbNeededOld = vsbNeeded; if (vsb != null && vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED) { boolean vsbNeededNew = isVerticalScrollBarNeeded(view, viewLocation, viewPreferredSize, viewportExtentSize); if (vsbNeeded != vsbNeededNew) { vsbNeeded = vsbNeededNew; if (vsbNeeded) { adjustForVSB(viewportBounds, insets, vsbBounds, vsbRequiresSpace, vsbOnLeft, isOverlappingScrollBar, wholePaneBounds); } else if (vsbRequiresSpace) { viewportBounds.width += vsbBounds.width; } if (vsbRequiresSpace) viewportExtentSize = viewport.toViewCoordinates(viewportBounds.getSize()); } } boolean hsbNeededOld = hsbNeeded; if (hsb != null && hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED) { boolean hsbNeededNew = isHorizontalScrollBarNeeded(view, viewLocation, viewPreferredSize, viewportExtentSize); if (hsbNeeded != hsbNeededNew) { hsbNeeded = hsbNeededNew; if (hsbNeeded) { adjustForHSB(viewportBounds, insets, hsbBounds, hsbRequiresSpace, hsbOnTop, isOverlappingScrollBar, wholePaneBounds); } else if (hsbRequiresSpace) { viewportBounds.height += hsbBounds.height; } if (hsbRequiresSpace && vsb != null && !vsbNeeded && vsbPolicy != VERTICAL_SCROLLBAR_NEVER) { viewportExtentSize = viewport.toViewCoordinates(viewportBounds.getSize()); vsbNeeded = isScrollBarNeeded(viewLocation.y, viewPreferredSize.height, viewportExtentSize.height); if (vsbNeeded) { adjustForVSB(viewportBounds, insets, vsbBounds, vsbRequiresSpace, vsbOnLeft, isOverlappingScrollBar, wholePaneBounds); } } } } if (hsbNeededOld != hsbNeeded || vsbNeededOld != vsbNeeded) { viewport.setBounds(viewportBounds); // You could argue that we should recheck the Scrollable methods again until they stop changing, // but they might never stop changing, so we stop here and don't do any additional checks. } } } // Set the bounds of the row header. rowHeadBounds.y = viewportBounds.y - insets.top; rowHeadBounds.height = viewportBounds.height + insets.top + insets.bottom; boolean fillLowerCorner = false; if (rowHead != null) { if (hsbRequiresSpace) { Component corner = hsbOnTop ? (vsbOnLeft ? upperRight : upperLeft) : (vsbOnLeft ? lowerRight : lowerLeft); fillLowerCorner = corner == null && UIManager.getBoolean("ScrollPane.fillLowerCorner"); if (!fillLowerCorner && ScrollSettings.isHeaderOverCorner(viewport)) { if (hsbOnTop) rowHeadBounds.y -= hsbBounds.height; rowHeadBounds.height += hsbBounds.height; } } rowHead.setBounds(rowHeadBounds); rowHead.putClientProperty(Alignment.class, vsbOnLeft ? Alignment.RIGHT : Alignment.LEFT); } // Set the bounds of the column header. colHeadBounds.x = viewportBounds.x - insets.left; colHeadBounds.width = viewportBounds.width + insets.left + insets.right; boolean fillUpperCorner = false; boolean hasStatusComponent = statusComponent != null && statusComponent.isShowing(); if (colHead != null) { if (vsbRequiresSpace) { Component corner = vsbOnLeft ? (hsbOnTop ? lowerLeft : upperLeft) : (hsbOnTop ? lowerRight : upperRight); fillUpperCorner = corner == null && UIManager.getBoolean("ScrollPane.fillUpperCorner") && !hasStatusComponent; if (!fillUpperCorner && ScrollSettings.isHeaderOverCorner(viewport)) { if (vsbOnLeft) colHeadBounds.x -= vsbBounds.width; colHeadBounds.width += vsbBounds.width; } } colHead.setBounds(colHeadBounds); colHead.putClientProperty(Alignment.class, hsbOnTop ? Alignment.BOTTOM : Alignment.TOP); } // Calculate overlaps for translucent scroll bars int overlapWidth = 0; int overlapHeight = 0; if (vsbNeeded && !vsbRequiresSpace && hsbNeeded && !hsbRequiresSpace) { overlapWidth = vsbBounds.width; // shrink horizontally //overlapHeight = hsbBounds.height; // shrink vertically } // Set the bounds of the vertical scroll bar. vsbBounds.y = viewportBounds.y - insets.top; vsbBounds.height = viewportBounds.height + insets.top + insets.bottom; // Forked bounds that are actually used for setting vertical scroll bar bounds // after possible modification with statusComponent bounds. Rectangle actualVsbBounds = new Rectangle(vsbBounds); if (vsb != null) { vsb.setVisible(vsbNeeded); if (vsbNeeded) { if (fillUpperCorner) { // This is used primarily for GTK L&F, which needs to extend // the vertical scrollbar to fill the upper corner near the column header. // Note that we skip this step (and use the default behavior) // if the user has set a custom corner component. if (!hsbOnTop) vsbBounds.y -= colHeadBounds.height; vsbBounds.height += colHeadBounds.height; } int overlapY = !hsbOnTop ? 0 : overlapHeight; actualVsbBounds.y += overlapY; actualVsbBounds.height -= overlapHeight; vsb.putClientProperty(Alignment.class, vsbOnLeft ? Alignment.LEFT : Alignment.RIGHT); } // Modify the bounds of the translucent scroll bar. if (!vsbRequiresSpace) { if (!vsbOnLeft) vsbBounds.x += vsbBounds.width; vsbBounds.width = 0; } } // Set the bounds of the horizontal scroll bar. hsbBounds.x = viewportBounds.x - insets.left; hsbBounds.width = viewportBounds.width + insets.left + insets.right; if (hsb != null) { hsb.setVisible(hsbNeeded); if (hsbNeeded) { if (fillLowerCorner) { // This is used primarily for GTK L&F, which needs to extend // the horizontal scrollbar to fill the lower corner near the row header. // Note that we skip this step (and use the default behavior) // if the user has set a custom corner component. if (!vsbOnLeft) hsbBounds.x -= rowHeadBounds.width; hsbBounds.width += rowHeadBounds.width; } int overlapX = !vsbOnLeft ? 0 : overlapWidth; hsb.setBounds(hsbBounds.x + overlapX, hsbBounds.y, hsbBounds.width - overlapWidth, hsbBounds.height); hsb.putClientProperty(Alignment.class, hsbOnTop ? Alignment.TOP : Alignment.BOTTOM); } // Modify the bounds of the translucent scroll bar. if (!hsbRequiresSpace) { if (!hsbOnTop) hsbBounds.y += hsbBounds.height; hsbBounds.height = 0; } } if (hasStatusComponent) { Dimension scSize = statusComponent.getPreferredSize(); switch (flip) { case NONE -> { statusComponent.setBounds(actualVsbBounds.x + actualVsbBounds.width - scSize.width, actualVsbBounds.y, scSize.width, scSize.height); actualVsbBounds.y += scSize.height; } case HORIZONTAL -> { statusComponent.setBounds(actualVsbBounds.x, actualVsbBounds.y, scSize.width, scSize.height); actualVsbBounds.y += scSize.height; } case VERTICAL -> statusComponent.setBounds(actualVsbBounds.x + actualVsbBounds.width - scSize.width, actualVsbBounds.y + actualVsbBounds.height - scSize.height, scSize.width, scSize.height); case BOTH -> statusComponent.setBounds(actualVsbBounds.x, actualVsbBounds.y + actualVsbBounds.height - scSize.height, scSize.width, scSize.height); } actualVsbBounds.height -= scSize.height; } if (vsb != null && vsbNeeded) { vsb.setBounds(actualVsbBounds); } // Set the bounds of the corners. Rectangle left = vsbOnLeft ? vsbBounds : rowHeadBounds; Rectangle right = vsbOnLeft ? rowHeadBounds : vsbBounds; Rectangle upper = hsbOnTop ? hsbBounds : colHeadBounds; Rectangle lower = hsbOnTop ? colHeadBounds : hsbBounds; if (lowerLeft != null) { Rectangle lowerLeftBounds = new Rectangle(left.x, left.y + left.height, 0, 0); if (left.width > 0 && lower.height > 0) updateCornerBounds(lowerLeftBounds, lower.x, lower.y + lower.height); lowerLeft.setBounds(lowerLeftBounds); } if (lowerRight != null) { Rectangle lowerRightBounds = new Rectangle(lower.x + lower.width, right.y + right.height, 0, 0); if (right.width > 0 && lower.height > 0) updateCornerBounds(lowerRightBounds, right.x + right.width, lower.y + lower.height); lowerRight.setBounds(lowerRightBounds); } if (upperLeft != null) { Rectangle upperLeftBounds = new Rectangle(left.x, upper.y, 0, 0); if (left.width > 0 && upper.height > 0) updateCornerBounds(upperLeftBounds, upper.x, left.y); upperLeft.setBounds(upperLeftBounds); } if (upperRight != null) { Rectangle upperRightBounds = new Rectangle(upper.x + upper.width, upper.y, 0, 0); if (right.width > 0 && upper.height > 0) updateCornerBounds(upperRightBounds, right.x + right.width, right.y); upperRight.setBounds(upperRightBounds); } if (!vsbRequiresSpace && vsbNeeded || !hsbRequiresSpace && hsbNeeded) { fixComponentZOrder(vsb, 0); fixComponentZOrder(viewport, -1); } else if (hasStatusComponent) { fixComponentZOrder(statusComponent, 0); fixComponentZOrder(viewport, -1); } }
layoutContainer
282,703
boolean (Component view) { return view instanceof Scrollable && ((Scrollable)view).getScrollableTracksViewportWidth(); }
tracksViewportWidth
282,704
boolean (Component view) { return view instanceof Scrollable && ((Scrollable)view).getScrollableTracksViewportHeight(); }
tracksViewportHeight
282,705
Dimension (Container parent) { Dimension result = new Dimension(); JScrollPane pane = (JScrollPane)parent; JBInsets.addTo(result, pane.getInsets()); Border border = pane.getViewportBorder(); if (border != null) JBInsets.addTo(result, border.getBorderInsets(parent)); int vsbPolicy = pane.getVerticalScrollBarPolicy(); int hsbPolicy = pane.getHorizontalScrollBarPolicy(); if (viewport != null) { Component view = viewport.getView(); if (view != null) { Point viewLocation = view.getLocation(); Dimension viewportExtentSize = viewport.getPreferredSize(); if (viewportExtentSize == null) viewportExtentSize = new Dimension(); Dimension viewPreferredSize = view.getPreferredSize(); if (viewPreferredSize == null) viewPreferredSize = new Dimension(); if (view instanceof JComponent && !view.isPreferredSizeSet()) { JBInsets.removeFrom(viewPreferredSize, JBViewport.getViewInsets((JComponent)view)); } result.width += viewportExtentSize.width; result.height += viewportExtentSize.height; if (vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED) { if (viewportExtentSize.height < viewPreferredSize.height && isVerticalScrollBarNeeded(view, viewLocation, viewPreferredSize, viewportExtentSize)) { vsbPolicy = VERTICAL_SCROLLBAR_ALWAYS; } } if (hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED) { if (viewportExtentSize.width < viewPreferredSize.width && isHorizontalScrollBarNeeded(view, viewLocation, viewPreferredSize, viewportExtentSize)) { hsbPolicy = HORIZONTAL_SCROLLBAR_ALWAYS; } } } } boolean isOverlappingScrollBar = isOverlappingScrollBar(pane); // disabled scroll bars should be minimized (see #adjustForVSB and #adjustForHSB) if (vsb != null && vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS && vsb.isEnabled() && ! isOverlappingScrollBar) result.width += vsb.getPreferredSize().width; if (hsb != null && hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS && hsb.isEnabled() && !isOverlappingScrollBar) result.height += hsb.getPreferredSize().height; if (rowHead != null && rowHead.isVisible()) result.width += rowHead.getPreferredSize().width; if (colHead != null && colHead.isVisible()) result.height += colHead.getPreferredSize().height; return result; }
preferredLayoutSize
282,706
boolean (JScrollPane scrollPane) { return (scrollPane instanceof JBScrollPane) && ((JBScrollPane)scrollPane).isOverlappingScrollBar(); }
isOverlappingScrollBar
282,707
boolean (Component view) { return !SystemInfo.isMac && ScrollSettings.isNotSupportedYet(view); }
isAlwaysOpaque
282,708
void (Rectangle bounds, int x, int y) { bounds.width = Math.abs(bounds.x - x); bounds.height = Math.abs(bounds.y - y); bounds.x = Math.min(bounds.x, x); bounds.y = Math.min(bounds.y, y); }
updateCornerBounds
282,709
void (Component component, int index) { if (component != null) { Container parent = component.getParent(); synchronized (parent.getTreeLock()) { if (index < 0) index += parent.getComponentCount(); parent.setComponentZOrder(component, index); } } }
fixComponentZOrder
282,710
void (Rectangle bounds, Insets insets, Rectangle vsbBounds, boolean vsbRequiresSpace, boolean vsbOnLeft, boolean vsbOverlapping, @NotNull Rectangle wholePaneBounds) { vsbBounds.width = vsb.isEnabled() ? min(bounds.width, vsb.getPreferredSize().width) : 0; if (vsbOnLeft) { if (vsbOverlapping) { vsbBounds.x = 0; } else { vsbBounds.x = bounds.x - insets.left/* + vsbBounds.width*/; } if (vsbRequiresSpace) bounds.x += vsbBounds.width; } else if (vsbOverlapping) { vsbBounds.x = wholePaneBounds.x + wholePaneBounds.width - vsbBounds.width; } else { vsbBounds.x = bounds.x + bounds.width + insets.right - vsbBounds.width; } if (vsbRequiresSpace) bounds.width -= vsbBounds.width; }
adjustForVSB
282,711
void (Rectangle bounds, Insets insets, Rectangle hsbBounds, boolean hsbRequiresSpace, boolean hsbOnTop, boolean hsbOverlapping, @NotNull Rectangle wholePaneBounds) { hsbBounds.height = hsb.isEnabled() ? min(bounds.height, hsb.getPreferredSize().height) : 0; if (hsbOnTop) { if (hsbOverlapping) { hsbBounds.y = 0; } else { hsbBounds.y = bounds.y - insets.top/* + hsbBounds.height*/; } if (hsbRequiresSpace) bounds.y += hsbBounds.height; } else if (hsbOverlapping) { hsbBounds.y = wholePaneBounds.y + wholePaneBounds.height - hsbBounds.height; } else { hsbBounds.y = bounds.y + bounds.height + insets.bottom - hsbBounds.height; } if (hsbRequiresSpace) bounds.height -= hsbBounds.height; }
adjustForHSB
282,712
int (int one, int two) { return Math.max(0, Math.min(one, two)); }
min
282,713
boolean (int location, int preferredSize, int extentSize) { return preferredSize > extentSize || location != 0; }
isScrollBarNeeded
282,714
boolean (Component view, Point location, Dimension preferredSize, Dimension extentSize) { // don't bother Scrollable.getScrollableTracksViewportWidth if a horizontal scroll bar is not needed return isScrollBarNeeded(location.x, preferredSize.width, extentSize.width) && !tracksViewportWidth(view); }
isHorizontalScrollBarNeeded
282,715
boolean (Component view, Point location, Dimension preferredSize, Dimension extentSize) { // don't bother Scrollable.getScrollableTracksViewportHeight if a vertical scroll bar is not needed return isScrollBarNeeded(location.y, preferredSize.height, extentSize.height) && !tracksViewportHeight(view); }
isVerticalScrollBarNeeded
282,716
boolean (@NotNull MouseWheelEvent event) { // event should not be consumed already if (event.isConsumed()) return false; // any rotation expected (forward or backward) boolean ignore = event.getWheelRotation() == 0; if (ignore && (ScrollSettings.isPixelPerfectEnabled() || ScrollSettings.isHighPrecisionEnabled())) { double rotation = event.getPreciseWheelRotation(); ignore = rotation == 0.0D || !Double.isFinite(rotation); } return !ignore && 0 == (SCROLL_MODIFIERS & event.getModifiers()); }
isScrollEvent
282,717
RegionPainter<Float> (@NotNull Supplier<? extends Component> supplier) { return new ScrollBarPainter.Thumb(supplier, SystemInfo.isMac); }
getThumbPainter
282,718
Graphics (Graphics graphics) { return JBSwingUtilities.runGlobalCGTransform(this, super.getComponentGraphics(graphics)); }
getComponentGraphics
282,719
void () { SwingUndoUtil.addUndoRedoActions(this); myEmptyText = new TextComponentEmptyText(this, true) { @Override protected Rectangle getTextComponentBound() { return getEmptyTextComponentBounds(super.getTextComponentBound()); } }; }
init
282,720
Rectangle () { return getEmptyTextComponentBounds(super.getTextComponentBound()); }
getTextComponentBound
282,721
Rectangle (Rectangle bounds) { return bounds; }
getEmptyTextComponentBounds
282,722
void (String t) { myEmptyText.setTextToTriggerStatus(t); }
setTextToTriggerEmptyTextStatus
282,723
void (String t) { if (Objects.equals(t, getText())) return; super.setText(t); SwingUndoUtil.resetUndoRedoActions(this); }
setText
282,724
StatusText () { return myEmptyText; }
getEmptyText
282,725
void () { super.updateUI(); if (getParent() != null) myEmptyText.resetFont(); }
updateUI
282,726
void (Graphics g) { super.paintComponent(g); if (!myEmptyText.getStatusTriggerText().isEmpty() && myEmptyText.isStatusVisible()) { g.setColor(getBackground()); Rectangle rect = new Rectangle(getSize()); JBInsets.removeFrom(rect, getInsets()); JBInsets.removeFrom(rect, getMargin()); ((Graphics2D)g).fill(rect); g.setColor(getForeground()); } myEmptyText.paintStatusText(g); }
paintComponent
282,727
String (MouseEvent event) { TextUI ui = getUI(); String text = ui == null ? null : ui.getToolTipText2D(this, event.getPoint()); return text != null ? text : getToolTipText(); }
getToolTipText
282,728
Insets (boolean small) { return JBUI.emptyInsets(); }
getInsets
282,729
void (Component component, Object name, int index) { Key<Component> key = LEADING.equals(name) ? DefaultScrollBarUI.LEADING : TRAILING.equals(name) ? DefaultScrollBarUI.TRAILING : null; if (key != null) { Component old = ClientProperty.get(this, key); ClientProperty.put(this, key, component); if (old != null) { remove(old); } } super.addImpl(component, name, index); }
addImpl
282,730
void () { ScrollBarUI ui = getUI(); if (ui instanceof DefaultScrollBarUI) return; setUI(createUI(this, isThin())); }
updateUI
282,731
ScrollBarUI (JComponent c) { return createUI(c, false); }
createUI
282,732
ScrollBarUI (JComponent c, boolean isThin) { if (SystemInfo.isMac) { return isThin ? new ThinMacScrollBarUI() : new MacScrollBarUI(); } else { return isThin ? new ThinScrollBarUI() : new DefaultScrollBarUI(); } }
createUI
282,733
int (int direction) { JViewport viewport = getViewport(); if (viewport != null) { Scrollable scrollable = getScrollableViewToCalculateIncrement(viewport.getView()); if (scrollable != null) return scrollable.getScrollableUnitIncrement(viewport.getViewRect(), orientation, direction); if (!isUnitIncrementSet) { Font font = getViewFont(viewport); if (font != null) return font.getSize(); // increase default unit increment for fast scrolling } } return super.getUnitIncrement(direction); }
getUnitIncrement
282,734
void (int increment) { isUnitIncrementSet = true; super.setUnitIncrement(increment); }
setUnitIncrement
282,735
void (boolean isOn) { ScrollBarUI ui = getUI(); if (ui instanceof DefaultScrollBarUI) { ((DefaultScrollBarUI)ui).toggle(isOn); } }
toggle
282,736
int (int direction) { JViewport viewport = getViewport(); if (viewport != null) { Scrollable scrollable = getScrollableViewToCalculateIncrement(viewport.getView()); if (scrollable != null) return scrollable.getScrollableBlockIncrement(viewport.getViewRect(), orientation, direction); if (!isBlockIncrementSet) { Dimension size = viewport.getExtentSize(); return orientation == HORIZONTAL ? size.width : size.height; } } return super.getBlockIncrement(direction); }
getBlockIncrement
282,737
void (int increment) { isBlockIncrementSet = true; super.setBlockIncrement(increment); }
setBlockIncrement
282,738
boolean (@NotNull MouseEvent event) { return JBScrollPane.canBePreprocessed(event, this); }
canBePreprocessed
282,739
void (int value) { int delay = 0; Component parent = getParent(); if (parent instanceof JBScrollPane pane) { JViewport viewport = pane.getViewport(); if (viewport != null && ScrollSettings.isEligibleFor(viewport.getView()) && ScrollSettings.isInterpolationEligibleFor(this)) { delay = pane.getInitialDelay(getValueIsAdjusting()); } } if (delay > 0) { myInterpolator.setTarget(value, delay); } else { super.setValue(value); } }
setValue
282,740
void (int value) { super.setValue(value); myFractionalRemainder = 0.0; }
setCurrentValue
282,741
int () { return myInterpolator.getTarget(); }
getTargetValue
282,742
boolean (MouseWheelEvent event) { if (!isSupportedScrollType(event)) return false; if (event.isShiftDown() == (orientation == VERTICAL)) return false; if (!ScrollSettings.isEligibleFor(this)) return false; double delta = getPreciseDelta(event); if (!Double.isFinite(delta)) return false; int value = getTargetValue(); double deltaAdjusted = getDeltaAdjusted(value, delta); if (deltaAdjusted != 0.0) { boolean isPositiveDelta = deltaAdjusted > 0.0; if (wasPositiveDelta != isPositiveDelta) { // reset accumulator if scrolling direction is changed wasPositiveDelta = isPositiveDelta; myFractionalRemainder = 0.0; } deltaAdjusted += myFractionalRemainder; int valueAdjusted = (int)deltaAdjusted; if (valueAdjusted == 0) { myFractionalRemainder = deltaAdjusted; } else { myFractionalRemainder = deltaAdjusted - (double)valueAdjusted; setValue(value + valueAdjusted); } } else if (delta != 0.0) { return true; // do not consume event if it can be processed by parent component } event.consume(); return true; }
handleMouseWheelEvent
282,743
boolean (MouseWheelEvent e) { return e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL || TouchScrollUtil.isUpdate(e); }
isSupportedScrollType
282,744
JViewport () { Component parent = getParent(); if (parent instanceof JScrollPane pane) { return pane.getViewport(); } return null; }
getViewport
282,745
Font (JViewport viewport) { if (viewport == null) return null; Component view = viewport.getView(); return view == null ? null : view.getFont(); }
getViewFont
282,746
Scrollable (Component view) { return view instanceof JTable || (view instanceof Scrollable && orientation == VERTICAL) ? (Scrollable)view : null; }
getScrollableViewToCalculateIncrement
282,747
double (double minDelta, double maxDelta, double delta) { return Math.max(minDelta, Math.min(maxDelta, delta)); }
boundDelta
282,748
double (MouseWheelEvent event) { int value = getTargetValue(); double delta = getPreciseDelta(event); return getDeltaAdjusted(value, delta); }
getDeltaAdjusted
282,749
double (int value, double delta) { double minDelta = getMinimum() - value; double maxDelta = getMaximum() - getVisibleAmount() - value; return Math.max(minDelta, Math.min(maxDelta, delta)); }
getDeltaAdjusted
282,750
double (MouseWheelEvent event) { if (TouchScrollUtil.isTouchScroll(event)) { return TouchScrollUtil.getDelta(event); } double rotation = event.getPreciseWheelRotation(); if (ScrollSettings.isPixelPerfectEnabled()) { // calculate an absolute delta if possible if (SystemInfo.isMac) { // Native code in our JDK for Mac uses 0.1 to convert pixels to units, // so we use 10 to restore amount of pixels to scroll. return 10 * rotation; } JViewport viewport = getViewport(); Font font = viewport == null ? null : getViewFont(viewport); int size = font == null ? JBUIScale.scale(10) : font.getSize(); // assume an unit size return size * rotation * event.getScrollAmount(); } if (ScrollSettings.isHighPrecisionEnabled()) { // calculate a relative delta if possible int direction = rotation < 0 ? -1 : 1; int unitIncrement = getUnitIncrement(direction); double delta = unitIncrement * rotation * event.getScrollAmount(); // When the scrolling speed is set to maximum, it's possible to scroll by more units than will fit in the visible area. // To make for more accurate low-speed scrolling, we limit scrolling to the block increment // if the wheel was only rotated one click. double blockIncrement = getBlockIncrement(direction); return boundDelta(-blockIncrement, blockIncrement, delta); } return Double.NaN; }
getPreciseDelta
282,751
boolean () { return false; }
isThin
282,752
void () { if (getValueIsAdjusting() && ScrollSource.SCROLLBAR.isInterpolationEnabled()) { Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ChangeListener.class) { ChangeListener listener = (ChangeListener)listeners[i + 1]; // ignore listeners declared in different implementations of ScrollBarUI if (!listener.getClass().getName().contains("ScrollBarUI")) { if (changeEvent == null) changeEvent = new ChangeEvent(this); listener.stateChanged(changeEvent); } } } } else { super.fireStateChanged(); } }
fireStateChanged
282,753
JBLabelDecorator () { return new JBLabelDecorator(); }
createJBLabelDecorator
282,754
JBLabelDecorator (@NlsContexts.Label String text) { return new JBLabelDecorator(text); }
createJBLabelDecorator
282,755
JBLabelDecorator (boolean isBold) { if (isBold) { setFont(getFont().deriveFont(Font.BOLD)); } else { setFont(getFont().deriveFont(Font.PLAIN)); } return this; }
setBold
282,756
JBLabelDecorator (@NotNull UIUtil.ComponentStyle componentStyle) { super.setComponentStyle(componentStyle); return this; }
setComponentStyleDecorative
282,757
JBLabelDecorator (@NotNull UIUtil.FontColor fontColor) { super.setFontColor(fontColor); return this; }
setFontColorDecorative
282,758
void (Graphics g) { if (myCachedImage != null && myMagnificationPoint != null) { double scale = magnificationToScale(myMagnification); int xOffset = (int)(myMagnificationPoint.x - myMagnificationPoint.x * scale); int yOffset = (int)(myMagnificationPoint.y - myMagnificationPoint.y * scale); Rectangle clip = g.getClipBounds(); g.setColor(myContentComponent.getBackground()); g.fillRect(clip.x, clip.y, clip.width, clip.height); Graphics2D translated = (Graphics2D)g.create(); translated.translate(xOffset, yOffset); translated.scale(scale, scale); UIUtil.drawImage(translated, myCachedImage, 0, 0, null); } }
paint
282,759
void (@NotNull Point at) { myMagnificationPoint = at; }
magnificationStarted
282,760
void (double magnification) { Magnificator magnificator = ((ZoomableViewport)myViewportComponent).getMagnificator(); if (magnificator != null && Double.compare(magnification, 0) != 0) { Point inContent = convertToContentCoordinates(myMagnificationPoint); final Point inContentScaled = magnificator.magnify(magnificationToScale(magnification), inContent); int vOffset = inContentScaled.y - myMagnificationPoint.y; int hOffset = inContentScaled.x - myMagnificationPoint.x; myViewportComponent.repaint(); myViewportComponent.validate(); scrollTo(vOffset, hOffset); } myMagnificationPoint = null; myMagnification = 0; myCachedImage = null; }
magnificationFinished
282,761
void (int vOffset, int hOffset) { JScrollPane pane = ComponentUtil.getScrollPane(myViewportComponent); JScrollBar vsb = pane == null ? null : pane.getVerticalScrollBar(); if (vsb != null) vsb.setValue(vOffset); JScrollBar hsb = pane == null ? null : pane.getHorizontalScrollBar(); if (hsb != null) hsb.setValue(hOffset); }
scrollTo
282,762
Point (Point point) { return SwingUtilities.convertPoint(myViewportComponent, point, myContentComponent); }
convertToContentCoordinates
282,763
boolean () { return myCachedImage != null; }
isActive
282,764
double (double magnification) { return magnification < 0 ? 1f / (1 - magnification) : (1 + magnification); }
magnificationToScale
282,765
void (double magnification) { double prev = myMagnification; myMagnification = magnification; if (myCachedImage == null) { Rectangle bounds = myViewportComponent.getBounds(); if (bounds.width <= 0 || bounds.height <= 0) return; BufferedImage image = ImageUtil.createImage(myViewportComponent.getGraphics(), bounds.width, bounds.height, BufferedImage.TYPE_INT_RGB); Graphics graphics = image.getGraphics(); graphics.setClip(0, 0, bounds.width, bounds.height); myViewportComponent.paint(graphics); myCachedImage = image; } if (Double.compare(prev, magnification) != 0) { myViewportComponent.repaint(); } }
magnify
282,766
AccessibleContext () { if (accessibleContext == null) { accessibleContext = new AccessibleJBMenu(); } return accessibleContext; }
getAccessibleContext
282,767
AccessibleStateSet () { AccessibleStateSet set = super.getAccessibleStateSet(); // Due to a bug in JMenu, CHECKED is added if the menu is enabled. That // is incorrect -- checked should be added only in the case of a "checkbox" // style menu. set.remove(AccessibleState.CHECKED); return set; }
getAccessibleStateSet
282,768
void () { if (fireEvents) { super.fireStateChanged(); } }
fireStateChanged
282,769
void (int n) { fireEvents = false; try { setValue(n); } finally { fireEvents = true; } }
setValueWithoutEvents
282,770
Component (@NotNull JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @SuppressWarnings({"unchecked"}) final JComponent comp = myFun.fun((T)value); comp.setOpaque(true); if (isSelected) { comp.setBackground(list.getSelectionBackground()); comp.setForeground(list.getSelectionForeground()); } else { comp.setBackground(list.getBackground()); comp.setForeground(list.getForeground()); } for (JLabel label : UIUtil.findComponentsOfType(comp, JLabel.class)) { label.setForeground(UIUtil.getListForeground(isSelected)); } return comp; }
getListCellRendererComponent
282,771
void (@NlsContexts.Button String onText) { myOnText = onText; }
setOnText
282,772
void (@NlsContexts.Button String offText) { myOffText = offText; }
setOffText
282,773
ComponentUI (JComponent c) { c.setAlignmentY(0.5f); return new DefaultOnOffButtonUI(); }
createUI
282,774
Dimension (JComponent c) { int vGap = JBUIScale.scale(3); OnOffButton button = (OnOffButton)c; String text = button.getOffText().length() > button.getOnText().length() ? button.getOffText() : button.getOnText(); text = text.toUpperCase(Locale.getDefault()); FontMetrics fm = c.getFontMetrics(c.getFont()); int w = fm.stringWidth(text); int h = fm.getHeight(); h += 2 * vGap; w += 1.25 * h; return new Dimension(w, h); }
getPreferredSize
282,775
void (Graphics g, JComponent c) { if (!(c instanceof OnOffButton button)) return; int toggleArc = JBUIScale.scale(3); int buttonArc = JBUIScale.scale(5); int vGap = JBUIScale.scale(3); int hGap = JBUIScale.scale(3); Dimension size = button.getSize(); int w = size.width - 2 * vGap; int h = size.height - 2 * hGap; if (h % 2 == 1) { h--; } Graphics2D g2 = (Graphics2D)g.create(); try { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int xOff = (button.getWidth() - w) / 2; int yOff = (button.getHeight() - h) / 2; g2.translate(xOff, yOff); boolean selected = button.isSelected(); g2.setColor(selected ? ON_BACKGROUND : OFF_BACKGROUND); g2.fillRoundRect(0, 0, w, h, buttonArc, buttonArc); int knobWidth = w - SwingUtilities.computeStringWidth(g2.getFontMetrics(), button.getOffText()) - JBUIScale.scale(2); knobWidth = Math.min(knobWidth, h); int textAscent = g2.getFontMetrics().getAscent(); Rectangle viewRect = new Rectangle(); Rectangle textRect = new Rectangle(); Rectangle iconRect = new Rectangle(); g2.setColor(BUTTON_COLOR); if (selected) { g2.fillRoundRect(w - knobWidth, 0, knobWidth, h, toggleArc, toggleArc); viewRect.setBounds(0, 0, w - knobWidth, h); SwingUtilities.layoutCompoundLabel(g2.getFontMetrics(), button.getOnText(), null, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.CENTER, viewRect, iconRect, textRect, 0); g2.setColor(ON_FOREGROUND); g2.drawString(button.getOnText(), textRect.x, textRect.y + textAscent); } else { g2.fillRoundRect(0, 0, knobWidth, h, toggleArc, toggleArc); viewRect.setBounds(knobWidth, 0, w - knobWidth, h); SwingUtilities.layoutCompoundLabel(g2.getFontMetrics(), button.getOffText(), null, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.CENTER, viewRect, iconRect, textRect, 0); g2.setColor(OFF_FOREGROUND); g2.drawString(button.getOffText(), textRect.x, textRect.y + textAscent); } g2.setColor(BORDER_COLOR); g2.drawRoundRect(0, 0, w, h, buttonArc, buttonArc); } finally { g2.dispose(); } }
paint
282,776
Dimension (JComponent c) { return getPreferredSize(c); }
getMinimumSize
282,777
Dimension (JComponent c) { return getPreferredSize(c); }
getMaximumSize
282,778
Insets (boolean small) { return JBUI.emptyInsets(); }
getInsets
282,779
void (MacScrollBarUI.Style style) { super.updateStyle(Style.Overlay); }
updateStyle
282,780
int () { return myModel.getSize(); }
getSize
282,781
void (Graphics g, JComponent c) { // do not paint a line background if layout orientation is not vertical myPaintBounds = JList.VERTICAL != list.getLayoutOrientation() ? null : g.getClipBounds(); super.paint(g, c); }
paint
282,782
void (Graphics g, int row, Rectangle rowBounds, ListCellRenderer renderer, ListModel model, ListSelectionModel selectionModel, int leadSelectionIndex) { if (!(0 <= row && row < model.getSize())) return; boolean selected = selectionModel.isSelectedIndex(row); Rectangle paintBounds = myPaintBounds; if (paintBounds != null) { boolean focused = row == leadSelectionIndex && (!list.isFocusable() || list.hasFocus()); Object value = model.getElementAt(row); Color background = getBackground(list, value, row, selected); if (background != null) { g.setColor(background); g.fillRect(rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height); } Component component = renderer.getListCellRendererComponent(list, value, row, selected, focused); if (component != null) { if (rendererPane != component.getParent()) rendererPane.add(component); g.setClip(paintBounds.x, paintBounds.y, paintBounds.width, paintBounds.height); paintRenderer(g, rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height, list, component); g.clipRect(rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height); } } try { super.paintCell(g, row, rowBounds, renderer, model, selectionModel, leadSelectionIndex); } catch (IndexOutOfBoundsException exception) { LOG.error("model asynchronously modified: " + model.getClass() + " in " + list, exception); } if (!isMac && g instanceof Graphics2D && row == leadSelectionIndex && list.hasFocus()) { int x = rowBounds.x; int width = rowBounds.width; if (JList.VERTICAL == list.getLayoutOrientation()) { x = 0; width = list.getWidth(); JViewport viewport = ComponentUtil.getViewport(list); if (viewport != null) { x = -list.getX(); width = viewport.getWidth(); } } if (!selected) { g.setColor(UIUtil.getListSelectionBackground(true)); g.setClip(x, rowBounds.y, width, rowBounds.height); DRAW.paint((Graphics2D)g, x, rowBounds.y, width, rowBounds.height, 0); } else if (isLeadSelectionNeeded(list, row)) { g.setColor(UIUtil.getListBackground()); g.setClip(x, rowBounds.y, width, rowBounds.height); DRAW.paint((Graphics2D)g, x + 1, rowBounds.y + 1, width - 2, rowBounds.height - 2, 0); } } }
paintCell
282,783
boolean (@NotNull JList list, int row) { return list.getMinSelectionIndex() < list.getMaxSelectionIndex() && list.isSelectedIndex(row - 1) && list.isSelectedIndex(row + 1); }
isLeadSelectionNeeded
282,784
Color (@NotNull JList<Object> list, @Nullable Object value, int row, boolean selected) { // to be consistent with com.intellij.ui.tree.ui.DefaultTreeUI#getBackground if (selected) { return RenderingUtil.getSelectionBackground(list); } if (row == ListHoverListener.getHoveredIndex(list)) { Color background = RenderingUtil.getHoverBackground(list); if (background != null) return background; } if (value instanceof ColoredItem) { Color background = ((ColoredItem)value).getColor(); if (background != null) return background; } if (value instanceof BackgroundSupplier) { BackgroundSupplier supplier = (BackgroundSupplier)value; Color background = supplier.getElementBackground(row); if (background != null) return background; } if (list instanceof ListCellBackgroundSupplier) { ListCellBackgroundSupplier<Object> supplier = (ListCellBackgroundSupplier<Object>)list; Color background = supplier.getCellBackground(value, row); if (background != null) return background; } return null; }
getBackground
282,785
void (Graphics g, int x, int y, int width, int height, Component owner, Component renderer) { g.clipRect(0, y, owner.getWidth(), height); paintBackground(g, y, height, owner, renderer); if (renderer instanceof Container) { Component[] children; Container container = (Container)renderer; synchronized (container.getTreeLock()) { children = container.getComponents(); } if (children.length > 0) { renderer.setBounds(x, y, width, height); renderer.validate(); for (Component child : children) { if (0 == child.getX() && width == child.getWidth() && 0 < child.getHeight()) { paintBackground(g, y + child.getY(), child.getHeight(), owner, child); } } } } }
paintRenderer
282,786
void (Graphics g, int y, int height, Component owner, Component child) { if (child.isOpaque()) { Color color = child.getBackground(); if (color != null && !color.equals(owner.getBackground())) { g.setColor(color); g.fillRect(0, y, owner.getWidth(), height); } } }
paintBackground
282,787
Rectangle (JList list, int index1, int index2) { Rectangle bounds = super.getCellBounds(list, index1, index2); if (bounds != null && index1 == index2 && list instanceof JBList && JList.VERTICAL == list.getLayoutOrientation()) { if (((JBList<?>)list).getExpandableItemsHandler().getExpandedItems().contains(index1)) { // increase paint area for list item with shown extendable popup JScrollPane pane = ComponentUtil.getScrollPane(list); JScrollBar bar = pane == null ? null : pane.getVerticalScrollBar(); if (bar != null && !bar.isOpaque()) bounds.width += bar.getWidth(); } } return bounds; }
getCellBounds
282,788
void () { if (list.getLayoutOrientation() != JList.VERTICAL) { super.updateLayoutState(); return; } // pasted from BasicListUI to provide min-height int fixedCellHeight = list.getFixedCellHeight(); int fixedCellWidth = list.getFixedCellWidth(); cellWidth = fixedCellWidth; if (fixedCellHeight != -1) { cellHeight = fixedCellHeight; cellHeights = null; } else { cellHeight = -1; cellHeights = new int[list.getModel().getSize()]; } if ((fixedCellWidth == -1) || (fixedCellHeight == -1)) { ListModel<Object> dataModel = list.getModel(); int dataModelSize = dataModel.getSize(); ListCellRenderer<Object> renderer = list.getCellRenderer(); if (renderer != null) { for (int index = 0; index < dataModelSize; index++) { Object value = dataModel.getElementAt(index); Component c = renderer.getListCellRendererComponent(list, value, index, false, false); rendererPane.add(c); Dimension cellSize = c.getPreferredSize(); if (UIUtil.getClientProperty(c, "IgnoreListRowHeight") == null) { cellSize = UIUtil.updateListRowHeight(cellSize); } if (fixedCellWidth == -1) { cellWidth = Math.max(cellSize.width, cellWidth); } if (fixedCellHeight == -1) { cellHeights[index] = cellSize.height; } } } else { if (cellWidth == -1) { cellWidth = 0; } if (cellHeights == null) { cellHeights = new int[dataModelSize]; } for (int index = 0; index < dataModelSize; index++) { cellHeights[index] = 0; } } } }
updateLayoutState
282,789
ComponentUI (JComponent list) { return new WideSelectionListUI(); }
createUI
282,790
int () { return Math.min(myMaxRows, getSize()); }
getRowCount
282,791
int () { final int rows = getRowCount(); return rows == 0 ? 0 : getSize() / rows + 1; }
getColumnCount
282,792
int (int row, int column) { final int rows = getRowCount(); return rows == 0 ? -1 : column * rows + row; }
toListIndex
282,793
int (int listIndex) { return listIndex / myMaxRows; }
getColumn
282,794
int (int listIndex) { return listIndex % myMaxRows; }
getRow
282,795
void (Border border) { super.setBorder(border); MultiColumnList.this.setBorder(border); }
setBorder
282,796
void () { MultiColumnList.this.repaint(); }
repaint
282,797
void (ListCellRenderer cellRenderer) { super.setCellRenderer(cellRenderer); if (myRenderer != cellRenderer) { MultiColumnList.this.setCellRenderer(cellRenderer); } }
setCellRenderer
282,798
void (KeyEvent e) { final int key = e.getKeyCode(); final int col = getSelectedColumn(); final int row = getSelectedRow(); final MultiColumnListModel model = getModel(); int r = row; int c = col; if (key == KeyEvent.VK_RIGHT) { if (c + 1 < getColumnCount()) { c++; } } else if (key == KeyEvent.VK_DOWN) { if (r + 1 < getRowCount()) { r++; if (model.toListIndex(r, c ) >= model.getSize()) { r = 0; c++; } } else { r = 0; c++; } } if (col != c || row != r) { if (e.getID() == KeyEvent.KEY_RELEASED) return; int index = model.toListIndex(r, c); if (index >= model.getSize() || r >= getRowCount() || c >= getColumnCount()) { e.consume(); final int last = model.getSize() - 1; changeSelection(model.getRow(last), model.getColumn(last), false, false); } else { changeSelection(r, c, false, false); e.consume(); } } else { super.processKeyEvent(e); } }
processKeyEvent
282,799
ListModel (Object...elements) { final DefaultListModel model = new DefaultListModel(); for (Object element : elements) { model.addElement(element); } return model; }
createListModel