/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import com.sun.java.swing.plaf.motif.MotifScrollBarUI; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTable; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import javax.swing.table.AbstractTableModel; import javax.swing.plaf.basic.BasicScrollBarUI; import java.awt.Dimension; import java.awt.Color; import java.awt.Robot; import java.awt.Toolkit; import java.awt.event.InputEvent; import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.awt.image.PixelGrabber; import java.io.File; import java.lang.reflect.InvocationTargetException; import javax.imageio.ImageIO; import java.util.Random; import java.net.URL; import java.util.logging.Level; import java.util.logging.Logger; public class JTableRenderingTest { private final class TestTableModel extends AbstractTableModel { @Override public int getRowCount() { return 20000; } @Override public int getColumnCount() { return 3; } @Override public Object getValueAt(int row, int column) { return ""; } } private final int sliderSize = 70; // slider button size private final int robotDelay = 500; private Robot robot; private JFrame frame; private JScrollPane scrollPane; private void createFrame() { frame = new JFrame(""); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setUndecorated(true); frame.setPreferredSize(new Dimension(500, 200)); JTable table = new JTable(new TestTableModel()); table.setTableHeader(null); table.setGridColor(Color.BLACK); table.setBackground(Color.WHITE); scrollPane = new JScrollPane(table); scrollPane.getVerticalScrollBar().setUI(new BasicScrollBarUI() { @Override protected JButton createDecreaseButton(int dummy) { return absentButton(); } @Override protected JButton createIncreaseButton(int dummy) { return absentButton(); } private JButton absentButton() { JButton btn = new JButton(); btn.setPreferredSize(new Dimension(0, 0)); btn.setMinimumSize(new Dimension(0, 0)); btn.setMaximumSize(new Dimension(0, 0)); return btn; } @Override protected Dimension getMinimumThumbSize() { return new Dimension(sliderSize, sliderSize); } @Override protected Dimension getMaximumThumbSize() { return new Dimension(sliderSize, sliderSize); } }); scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(sliderSize, Integer.MAX_VALUE)); frame.add(scrollPane); frame.pack(); frame.setLocation(100, 100); frame.setVisible(true); } public static void main(String[] args) { new JTableRenderingTest().doTest(); } public void doTest() { try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { createFrame(); } }); } catch (InterruptedException ex) { Logger.getLogger(JTableRenderingTest.class.getName()).log(Level.SEVERE, null, ex); } catch (InvocationTargetException ex) { Logger.getLogger(JTableRenderingTest.class.getName()).log(Level.SEVERE, null, ex); } } }