630 Dimension itemSize = item.getPreferredSize();
631 Rectangle cellBounds = list.getCellBounds(index, index);
632 if (!item.getComponentOrientation().isLeftToRight()) {
633 cellBounds.x += (cellBounds.width - itemSize.width);
634 }
635 cellBounds.width = itemSize.width;
636
637 return cellBounds.contains(point);
638 }
639
640
641 /**
642 * Returns true if the given point is outside the preferredSize of the
643 * item at the given row of the table. (Column must be 0).
644 * Does not check the "Table.isFileList" property. That should be checked
645 * before calling this method.
646 * This is used to make Windows {@literal L&F} JFileChooser act
647 * like native dialogs.
648 */
649 public static boolean pointOutsidePrefSize(JTable table, int row, int column, Point p) {
650 if (table.convertColumnIndexToModel(column) != 0 || row == -1) {
651 return true;
652 }
653 TableCellRenderer tcr = table.getCellRenderer(row, column);
654 Object value = table.getValueAt(row, column);
655 Component cell = tcr.getTableCellRendererComponent(table, value, false,
656 false, row, column);
657 Dimension itemSize = cell.getPreferredSize();
658 Rectangle cellBounds = table.getCellRect(row, column, false);
659 cellBounds.width = itemSize.width;
660 cellBounds.height = itemSize.height;
661
662 // See if coords are inside
663 // ASSUME: mouse x,y will never be < cell's x,y
664 assert (p.x >= cellBounds.x && p.y >= cellBounds.y);
665 return p.x > cellBounds.x + cellBounds.width ||
666 p.y > cellBounds.y + cellBounds.height;
667 }
668
669 /**
|
630 Dimension itemSize = item.getPreferredSize();
631 Rectangle cellBounds = list.getCellBounds(index, index);
632 if (!item.getComponentOrientation().isLeftToRight()) {
633 cellBounds.x += (cellBounds.width - itemSize.width);
634 }
635 cellBounds.width = itemSize.width;
636
637 return cellBounds.contains(point);
638 }
639
640
641 /**
642 * Returns true if the given point is outside the preferredSize of the
643 * item at the given row of the table. (Column must be 0).
644 * Does not check the "Table.isFileList" property. That should be checked
645 * before calling this method.
646 * This is used to make Windows {@literal L&F} JFileChooser act
647 * like native dialogs.
648 */
649 public static boolean pointOutsidePrefSize(JTable table, int row, int column, Point p) {
650 if(table.getClientProperty("Table.noOutsideChecking") == Boolean.TRUE) {
651 return false;
652 }
653
654
655 if (table.convertColumnIndexToModel(column) != 0 || row == -1) {
656 return true;
657 }
658 TableCellRenderer tcr = table.getCellRenderer(row, column);
659 Object value = table.getValueAt(row, column);
660 Component cell = tcr.getTableCellRendererComponent(table, value, false,
661 false, row, column);
662 Dimension itemSize = cell.getPreferredSize();
663 Rectangle cellBounds = table.getCellRect(row, column, false);
664 cellBounds.width = itemSize.width;
665 cellBounds.height = itemSize.height;
666
667 // See if coords are inside
668 // ASSUME: mouse x,y will never be < cell's x,y
669 assert (p.x >= cellBounds.x && p.y >= cellBounds.y);
670 return p.x > cellBounds.x + cellBounds.width ||
671 p.y > cellBounds.y + cellBounds.height;
672 }
673
674 /**
|