973 return 0; 974 } 975 } 976 977 public FileFilter getElementAt(int index) { 978 if(index > getSize() - 1) { 979 // This shouldn't happen. Try to recover gracefully. 980 return getFileChooser().getFileFilter(); 981 } 982 if(filters != null) { 983 return filters[index]; 984 } else { 985 return null; 986 } 987 } 988 } 989 990 991 992 /** 993 * <code>ButtonAreaLayout</code> behaves in a similar manner to 994 * <code>FlowLayout</code>. It lays out all components from left to 995 * right, flushed right. The widths of all components will be set 996 * to the largest preferred size width. 997 */ 998 private static class ButtonAreaLayout implements LayoutManager { 999 private int hGap = 5; 1000 private int topMargin = 17; 1001 1002 public void addLayoutComponent(String string, Component comp) { 1003 } 1004 1005 public void layoutContainer(Container container) { 1006 Component[] children = container.getComponents(); 1007 1008 if (children != null && children.length > 0) { 1009 int numChildren = children.length; 1010 Dimension[] sizes = new Dimension[numChildren]; 1011 Insets insets = container.getInsets(); 1012 int yLocation = insets.top + topMargin; 1013 int maxWidth = 0; 1014 | 973 return 0; 974 } 975 } 976 977 public FileFilter getElementAt(int index) { 978 if(index > getSize() - 1) { 979 // This shouldn't happen. Try to recover gracefully. 980 return getFileChooser().getFileFilter(); 981 } 982 if(filters != null) { 983 return filters[index]; 984 } else { 985 return null; 986 } 987 } 988 } 989 990 991 992 /** 993 * {@code ButtonAreaLayout} behaves in a similar manner to 994 * {@code FlowLayout}. It lays out all components from left to 995 * right, flushed right. The widths of all components will be set 996 * to the largest preferred size width. 997 */ 998 private static class ButtonAreaLayout implements LayoutManager { 999 private int hGap = 5; 1000 private int topMargin = 17; 1001 1002 public void addLayoutComponent(String string, Component comp) { 1003 } 1004 1005 public void layoutContainer(Container container) { 1006 Component[] children = container.getComponents(); 1007 1008 if (children != null && children.length > 0) { 1009 int numChildren = children.length; 1010 Dimension[] sizes = new Dimension[numChildren]; 1011 Insets insets = container.getInsets(); 1012 int yLocation = insets.top + topMargin; 1013 int maxWidth = 0; 1014 |