diff options
Diffstat (limited to 'src/share/classes/sun/swing')
3 files changed, 57 insertions, 4 deletions
diff --git a/src/share/classes/sun/swing/SwingUtilities2.java b/src/share/classes/sun/swing/SwingUtilities2.java index 443fb90d1..6358d9870 100644 --- a/src/share/classes/sun/swing/SwingUtilities2.java +++ b/src/share/classes/sun/swing/SwingUtilities2.java @@ -44,6 +44,8 @@ import javax.swing.text.JTextComponent; import javax.swing.text.DefaultHighlighter; import javax.swing.text.DefaultCaret; import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; + import sun.swing.PrintColorUIResource; import sun.swing.ImageIconUIResource; import sun.print.ProxyPrintGraphics; @@ -1807,4 +1809,54 @@ public class SwingUtilities2 { boolean three) { return liesIn(rect, p, false, false, three); } + + /** + * Maps the index of the column in the view at + * {@code viewColumnIndex} to the index of the column + * in the table model. Returns the index of the corresponding + * column in the model. If {@code viewColumnIndex} + * is less than zero, returns {@code viewColumnIndex}. + * + * @param cm the table model + * @param viewColumnIndex the index of the column in the view + * @return the index of the corresponding column in the model + * + * @see JTable#convertColumnIndexToModel(int) + * @see javax.swing.plaf.basic.BasicTableHeaderUI + */ + public static int convertColumnIndexToModel(TableColumnModel cm, + int viewColumnIndex) { + if (viewColumnIndex < 0) { + return viewColumnIndex; + } + return cm.getColumn(viewColumnIndex).getModelIndex(); + } + + /** + * Maps the index of the column in the {@code cm} at + * {@code modelColumnIndex} to the index of the column + * in the view. Returns the index of the + * corresponding column in the view; returns {@code -1} if this column + * is not being displayed. If {@code modelColumnIndex} is less than zero, + * returns {@code modelColumnIndex}. + * + * @param cm the table model + * @param modelColumnIndex the index of the column in the model + * @return the index of the corresponding column in the view + * + * @see JTable#convertColumnIndexToView(int) + * @see javax.swing.plaf.basic.BasicTableHeaderUI + */ + public static int convertColumnIndexToView(TableColumnModel cm, + int modelColumnIndex) { + if (modelColumnIndex < 0) { + return modelColumnIndex; + } + for (int column = 0; column < cm.getColumnCount(); column++) { + if (cm.getColumn(column).getModelIndex() == modelColumnIndex) { + return column; + } + } + return -1; + } } diff --git a/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java b/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java index f45c60f67..08745ad19 100644 --- a/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java +++ b/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java @@ -788,7 +788,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI { // for example /foo/bar/ becomes /foo/bar File canonical; try { - canonical = directory.getCanonicalFile(); + canonical = ShellFolder.getNormalizedFile(directory); } catch (IOException e) { // Maybe drive is not ready. Can't abort here. canonical = directory; diff --git a/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java b/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java index 492578f57..8187fea6f 100644 --- a/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java +++ b/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java @@ -24,6 +24,8 @@ */ package sun.swing.table; +import sun.swing.DefaultLookup; + import java.awt.Component; import java.awt.Color; import java.awt.FontMetrics; @@ -31,12 +33,11 @@ import java.awt.Graphics; import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; +import java.io.Serializable; import javax.swing.*; import javax.swing.plaf.UIResource; import javax.swing.border.Border; import javax.swing.table.*; -import sun.swing.DefaultLookup; - public class DefaultTableCellHeaderRenderer extends DefaultTableCellRenderer implements UIResource { @@ -186,7 +187,7 @@ public class DefaultTableCellHeaderRenderer extends DefaultTableCellRenderer return new Point(x, y); } - private class EmptyIcon implements Icon { + private class EmptyIcon implements Icon, Serializable { int width = 0; int height = 0; public void paintIcon(Component c, Graphics g, int x, int y) {} |