本文整理汇总了Java中javax.swing.plaf.basic.BasicScrollPaneUI类的典型用法代码示例。如果您正苦于以下问题:Java BasicScrollPaneUI类的具体用法?Java BasicScrollPaneUI怎么用?Java BasicScrollPaneUI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicScrollPaneUI类属于javax.swing.plaf.basic包,在下文中一共展示了BasicScrollPaneUI类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetSetUpdateUI
import javax.swing.plaf.basic.BasicScrollPaneUI; //导入依赖的package包/类
public void testGetSetUpdateUI() throws Exception {
assertNotNull(pane.getUI());
ScrollPaneUI ui = new BasicScrollPaneUI();
pane.setUI(ui);
assertEquals(ui, pane.getUI());
pane.updateUI();
assertNotSame(ui, pane.getUI());
}
示例2: setUI
import javax.swing.plaf.basic.BasicScrollPaneUI; //导入依赖的package包/类
@Override
public void setUI(ScrollPaneUI ui) {
super.setUI(ui);
updateViewportBorder();
if (ui instanceof BasicScrollPaneUI) {
try {
Field field = BasicScrollPaneUI.class.getDeclaredField("mouseScrollListener");
field.setAccessible(true);
Object value = field.get(ui);
if (value instanceof MouseWheelListener) {
MouseWheelListener oldListener = (MouseWheelListener)value;
MouseWheelListener newListener = event -> {
if (isScrollEvent(event)) {
Object source = event.getSource();
if (source instanceof JScrollPane) {
JScrollPane pane = (JScrollPane)source;
if (pane.isWheelScrollingEnabled()) {
JScrollBar bar = event.isShiftDown() ? pane.getHorizontalScrollBar() : pane.getVerticalScrollBar();
if (bar != null && bar.isVisible()) oldListener.mouseWheelMoved(event);
}
}
}
};
field.set(ui, newListener);
// replace listener if field updated successfully
removeMouseWheelListener(oldListener);
addMouseWheelListener(newListener);
}
}
catch (Exception exception) {
LOG.warn(exception);
}
}
}
示例3: updateUI
import javax.swing.plaf.basic.BasicScrollPaneUI; //导入依赖的package包/类
@Override
public void updateUI() {
setUI(new BasicScrollPaneUI());
setBackground(ColorService.forCurrentTheme(Background));
}