|
|
@ -1,9 +1,11 @@ |
|
|
|
package com.fine.theme.light.ui; |
|
|
|
package com.fine.theme.light.ui; |
|
|
|
|
|
|
|
|
|
|
|
import com.formdev.flatlaf.ui.FlatScrollBarUI; |
|
|
|
import com.formdev.flatlaf.ui.FlatScrollBarUI; |
|
|
|
|
|
|
|
import com.fr.design.gui.iscrollbar.UIVerticalScrollBar; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.JComponent; |
|
|
|
import javax.swing.JComponent; |
|
|
|
import javax.swing.JTable; |
|
|
|
import javax.swing.JTable; |
|
|
|
|
|
|
|
import javax.swing.plaf.ComponentUI; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Rectangle; |
|
|
|
import java.awt.Rectangle; |
|
|
|
|
|
|
|
|
|
|
@ -16,12 +18,20 @@ import java.awt.Rectangle; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class FineTableScrollBarPaneUI extends FlatScrollBarUI { |
|
|
|
public class FineTableScrollBarPaneUI extends FlatScrollBarUI { |
|
|
|
|
|
|
|
|
|
|
|
private final JTable table; |
|
|
|
public FineTableScrollBarPaneUI() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public FineTableScrollBarPaneUI(JTable table) { |
|
|
|
/** |
|
|
|
this.table = table; |
|
|
|
* 创建UI |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param c 组件 |
|
|
|
|
|
|
|
* @return ComponentUI |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static ComponentUI createUI(JComponent c) { |
|
|
|
|
|
|
|
return new FineTableScrollBarPaneUI(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) { |
|
|
|
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) { |
|
|
|
super.paintTrack(g, c, trackBounds); |
|
|
|
super.paintTrack(g, c, trackBounds); |
|
|
@ -29,10 +39,13 @@ public class FineTableScrollBarPaneUI extends FlatScrollBarUI { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { |
|
|
|
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { |
|
|
|
|
|
|
|
if (c instanceof UIVerticalScrollBar) { |
|
|
|
// 确保滚动条滑块不会超过表头区域
|
|
|
|
// 确保滚动条滑块不会超过表头区域
|
|
|
|
|
|
|
|
JTable table = ((UIVerticalScrollBar) c).getTable(); |
|
|
|
Rectangle headerRect = table.getTableHeader().getBounds(); |
|
|
|
Rectangle headerRect = table.getTableHeader().getBounds(); |
|
|
|
int headerHeight = headerRect.height; |
|
|
|
int headerHeight = headerRect.height; |
|
|
|
thumbBounds.y = Math.max(thumbBounds.y, headerHeight); |
|
|
|
thumbBounds.y = Math.max(thumbBounds.y, headerHeight); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
super.paintThumb(g, c, thumbBounds); |
|
|
|
super.paintThumb(g, c, thumbBounds); |
|
|
|
} |
|
|
|
} |
|
|
|