From: <ls...@us...> - 2007-01-09 20:25:51
|
Revision: 3062 http://jnode.svn.sourceforge.net/jnode/?rev=3062&view=rev Author: lsantha Date: 2007-01-09 12:25:48 -0800 (Tue, 09 Jan 2007) Log Message: ----------- Classpath patches. Modified Paths: -------------- trunk/core/src/classpath/javax/javax/swing/AbstractButton.java trunk/core/src/classpath/javax/javax/swing/AbstractListModel.java trunk/core/src/classpath/javax/javax/swing/AbstractSpinnerModel.java trunk/core/src/classpath/javax/javax/swing/ButtonGroup.java trunk/core/src/classpath/javax/javax/swing/DefaultBoundedRangeModel.java trunk/core/src/classpath/javax/javax/swing/DefaultButtonModel.java trunk/core/src/classpath/javax/javax/swing/DefaultComboBoxModel.java trunk/core/src/classpath/javax/javax/swing/DefaultListModel.java trunk/core/src/classpath/javax/javax/swing/DefaultListSelectionModel.java trunk/core/src/classpath/javax/javax/swing/DefaultSingleSelectionModel.java trunk/core/src/classpath/javax/javax/swing/JButton.java trunk/core/src/classpath/javax/javax/swing/JComboBox.java trunk/core/src/classpath/javax/javax/swing/JEditorPane.java trunk/core/src/classpath/javax/javax/swing/JFileChooser.java trunk/core/src/classpath/javax/javax/swing/JFormattedTextField.java trunk/core/src/classpath/javax/javax/swing/JList.java trunk/core/src/classpath/javax/javax/swing/JMenuBar.java trunk/core/src/classpath/javax/javax/swing/JRootPane.java trunk/core/src/classpath/javax/javax/swing/JScrollPane.java trunk/core/src/classpath/javax/javax/swing/JTabbedPane.java trunk/core/src/classpath/javax/javax/swing/JToggleButton.java trunk/core/src/classpath/javax/javax/swing/JToolTip.java trunk/core/src/classpath/javax/javax/swing/JWindow.java trunk/core/src/classpath/javax/javax/swing/LookAndFeel.java trunk/core/src/classpath/javax/javax/swing/Popup.java trunk/core/src/classpath/javax/javax/swing/SizeSequence.java trunk/core/src/classpath/javax/javax/swing/SortingFocusTraversalPolicy.java trunk/core/src/classpath/javax/javax/swing/SpinnerListModel.java trunk/core/src/classpath/javax/javax/swing/Timer.java trunk/core/src/classpath/javax/javax/swing/UIDefaults.java Modified: trunk/core/src/classpath/javax/javax/swing/AbstractButton.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/AbstractButton.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/AbstractButton.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -37,8 +37,6 @@ package javax.swing; -import gnu.classpath.NotImplementedException; - import java.awt.Component; import java.awt.Graphics; import java.awt.Image; @@ -74,7 +72,10 @@ import javax.swing.plaf.basic.BasicHTML; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; import javax.swing.text.Position; +import javax.swing.text.StyledDocument; import javax.swing.text.View; @@ -804,22 +805,127 @@ return -1; } - public String getAtIndex(int value0, int value1) - throws NotImplementedException + /** + * Returns the character, word or sentence at the specified index. The + * <code>part</code> parameter determines what is returned, the character, + * word or sentence after the index. + * + * @param part one of {@link AccessibleText#CHARACTER}, + * {@link AccessibleText#WORD} or + * {@link AccessibleText#SENTENCE}, specifying what is returned + * @param index the index + * + * @return the character, word or sentence after <code>index</code> + */ + public String getAtIndex(int part, int index) { - return null; // TODO + String result = ""; + int startIndex = -1; + int endIndex = -1; + switch(part) + { + case AccessibleText.CHARACTER: + result = String.valueOf(text.charAt(index)); + break; + case AccessibleText.WORD: + startIndex = text.lastIndexOf(' ', index); + endIndex = text.indexOf(' ', startIndex + 1); + if (endIndex == -1) + endIndex = startIndex + 1; + result = text.substring(startIndex + 1, endIndex); + break; + case AccessibleText.SENTENCE: + default: + startIndex = text.lastIndexOf('.', index); + endIndex = text.indexOf('.', startIndex + 1); + if (endIndex == -1) + endIndex = startIndex + 1; + result = text.substring(startIndex + 1, endIndex); + break; + } + return result; } - public String getAfterIndex(int value0, int value1) - throws NotImplementedException + /** + * Returns the character, word or sentence after the specified index. The + * <code>part</code> parameter determines what is returned, the character, + * word or sentence after the index. + * + * @param part one of {@link AccessibleText#CHARACTER}, + * {@link AccessibleText#WORD} or + * {@link AccessibleText#SENTENCE}, specifying what is returned + * @param index the index + * + * @return the character, word or sentence after <code>index</code> + */ + public String getAfterIndex(int part, int index) { - return null; // TODO + String result = ""; + int startIndex = -1; + int endIndex = -1; + switch(part) + { + case AccessibleText.CHARACTER: + result = String.valueOf(text.charAt(index + 1)); + break; + case AccessibleText.WORD: + startIndex = text.indexOf(' ', index); + endIndex = text.indexOf(' ', startIndex + 1); + if (endIndex == -1) + endIndex = startIndex + 1; + result = text.substring(startIndex + 1, endIndex); + break; + case AccessibleText.SENTENCE: + default: + startIndex = text.indexOf('.', index); + endIndex = text.indexOf('.', startIndex + 1); + if (endIndex == -1) + endIndex = startIndex + 1; + result = text.substring(startIndex + 1, endIndex); + break; + } + return result; } - public String getBeforeIndex(int value0, int value1) - throws NotImplementedException + /** + * Returns the character, word or sentence before the specified index. The + * <code>part</code> parameter determines what is returned, the character, + * word or sentence before the index. + * + * @param part one of {@link AccessibleText#CHARACTER}, + * {@link AccessibleText#WORD} or + * {@link AccessibleText#SENTENCE}, specifying what is returned + * @param index the index + * + * @return the character, word or sentence before <code>index</code> + */ + public String getBeforeIndex(int part, int index) { - return null; // TODO + String result = ""; + int startIndex = -1; + int endIndex = -1; + switch(part) + { + case AccessibleText.CHARACTER: + result = String.valueOf(text.charAt(index - 1)); + break; + case AccessibleText.WORD: + endIndex = text.lastIndexOf(' ', index); + if (endIndex == -1) + endIndex = 0; + startIndex = text.lastIndexOf(' ', endIndex - 1); + result = text.substring(startIndex + 1, endIndex); + break; + case AccessibleText.SENTENCE: + default: + endIndex = text.lastIndexOf('.', index); + if (endIndex == -1) + endIndex = 0; + startIndex = text.lastIndexOf('.', endIndex - 1); + result = text.substring(startIndex + 1, endIndex); + break; + } + return result; } /** @@ -837,7 +943,14 @@ View view = (View) getClientProperty(BasicHTML.propertyKey); if (view != null) { - + Document doc = view.getDocument(); + if (doc instanceof StyledDocument) + { + StyledDocument sDoc = (StyledDocument) doc; + Element charEl = sDoc.getCharacterElement(i); + if (charEl != null) + atts = charEl.getAttributes(); + } } return atts; } @@ -904,7 +1017,10 @@ setDisplayedMnemonicIndex(-1); setOpaque(true); text = ""; - updateUI(); + // testing on JRE1.5 shows that the iconTextGap default value is + // hard-coded here and the 'Button.iconTextGap' setting in the + // UI defaults is ignored, at least by the MetalLookAndFeel + iconTextGap = 4; } /** @@ -965,6 +1081,8 @@ if (icon != null) default_icon = icon; + + updateUI(); } /** Modified: trunk/core/src/classpath/javax/javax/swing/AbstractListModel.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/AbstractListModel.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/AbstractListModel.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -164,7 +164,7 @@ * * @return The set of listeners of the specified type */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } Modified: trunk/core/src/classpath/javax/javax/swing/AbstractSpinnerModel.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/AbstractSpinnerModel.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/AbstractSpinnerModel.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -1,5 +1,5 @@ /* AbstractSpinnerModel.java -- - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,12 +48,15 @@ * Provides standard implementations for some of the methods in * {@link SpinnerModel}. * + * @since 1.4 + * * @author Ka-Hing Cheung */ public abstract class AbstractSpinnerModel implements SpinnerModel { private ChangeEvent changeEvent = new ChangeEvent(this); + /** Stores the listeners registered with the model. */ protected EventListenerList listenerList = new EventListenerList(); /** @@ -65,9 +68,10 @@ } /** - * Adds a <code>ChangeListener</code>. + * Registers a <code>ChangeListener</code> with the model so that it will + * receive {@link ChangeEvent} notifications when the model changes. * - * @param listener the listener to add + * @param listener the listener to add (<code>null</code> is ignored). */ public void addChangeListener(ChangeListener listener) { @@ -80,7 +84,7 @@ * @param c the type of listener * @return the listeners that are of the specific type */ - public EventListener[] getListeners(Class c) + public <T extends EventListener> T[] getListeners(Class<T> c) { return listenerList.getListeners(c); } Modified: trunk/core/src/classpath/javax/javax/swing/ButtonGroup.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/ButtonGroup.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/ButtonGroup.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -68,7 +68,7 @@ private static final long serialVersionUID = 4259076101881721375L; /** Stores references to the buttons added to this button group. */ - protected Vector buttons = new Vector(); + protected Vector<AbstractButton> buttons = new Vector<AbstractButton>(); /** The currently selected button model. */ ButtonModel sel; @@ -129,7 +129,7 @@ * * @return <code>Enumeration</code> over all added buttons */ - public Enumeration getElements() + public Enumeration<AbstractButton> getElements() { return buttons.elements(); } @@ -183,6 +183,10 @@ if (old != null) old.setSelected(false); + + if (m != null) + sel.setSelected(true); + AbstractButton button = findButton(old); if (button != null) button.repaint(); Modified: trunk/core/src/classpath/javax/javax/swing/DefaultBoundedRangeModel.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/DefaultBoundedRangeModel.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/DefaultBoundedRangeModel.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -424,7 +424,7 @@ * * @since 1.3 */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } Modified: trunk/core/src/classpath/javax/javax/swing/DefaultButtonModel.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/DefaultButtonModel.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/DefaultButtonModel.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -166,7 +166,7 @@ * * @return array of listeners */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } Modified: trunk/core/src/classpath/javax/javax/swing/DefaultComboBoxModel.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/DefaultComboBoxModel.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/DefaultComboBoxModel.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -104,7 +104,7 @@ * * @throws NullPointerException if <code>vector</code> is <code>null</code>. */ - public DefaultComboBoxModel(Vector vector) + public DefaultComboBoxModel(Vector<?> vector) { this.list = vector; if (getSize() > 0) @@ -224,16 +224,24 @@ */ public void setSelectedItem(Object object) { - if (selectedItem == null) - { - if (object == null) + // No item is selected and object is null, so no change required. + if (selectedItem == null && object == null) return; - } - else - { - if (selectedItem.equals(object)) + + // object is already selected so no change required. + if (selectedItem != null && selectedItem.equals(object)) return; - } + + // Simply return if object is not in the list. + if (object != null && getIndexOf(object) == -1) + return; + + // Here we know that object is either an item in the list or null. + + // Handle the three change cases: selectedItem is null, object is + // non-null; selectedItem is non-null, object is null; + // selectedItem is non-null, object is non-null and they're not + // equal. selectedItem = object; fireContentsChanged(this, -1, -1); } Modified: trunk/core/src/classpath/javax/javax/swing/DefaultListModel.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/DefaultListModel.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/DefaultListModel.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -309,7 +309,7 @@ * * @return A new enumeration which iterates over the list */ - public Enumeration elements() + public Enumeration<?> elements() { return elements.elements(); } Modified: trunk/core/src/classpath/javax/javax/swing/DefaultListSelectionModel.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/DefaultListSelectionModel.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/DefaultListSelectionModel.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -815,7 +815,7 @@ * @see #getListSelectionListeners * @since 1.3 */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } Modified: trunk/core/src/classpath/javax/javax/swing/DefaultSingleSelectionModel.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/DefaultSingleSelectionModel.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/DefaultSingleSelectionModel.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -174,7 +174,7 @@ * * @since 1.3 */ - public EventListener[] getListeners(Class listenerClass) + public <T extends EventListener> T[] getListeners(Class<T> listenerClass) { return listenerList.getListeners(listenerClass); } Modified: trunk/core/src/classpath/javax/javax/swing/JButton.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JButton.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JButton.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -132,8 +132,8 @@ public JButton(String text, Icon icon) { super(); + setModel(new DefaultButtonModel()); init(text, icon); - setModel(new DefaultButtonModel()); defaultCapable = true; } Modified: trunk/core/src/classpath/javax/javax/swing/JComboBox.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JComboBox.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JComboBox.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -196,7 +196,7 @@ * * @param itemVector vector containing list of items for this JComboBox. */ - public JComboBox(Vector itemVector) + public JComboBox(Vector<?> itemVector) { this(new DefaultComboBoxModel(itemVector)); Modified: trunk/core/src/classpath/javax/javax/swing/JEditorPane.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JEditorPane.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JEditorPane.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -712,7 +712,7 @@ public JEditorPane(URL url) throws IOException { init(); - setEditorKit(createEditorKitForContentType("text/html"));; + setEditorKit(createEditorKitForContentType("text/html")); setPage(url); } Modified: trunk/core/src/classpath/javax/javax/swing/JFileChooser.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JFileChooser.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JFileChooser.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -43,6 +43,8 @@ import java.awt.HeadlessException; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowAdapter; import java.beans.PropertyChangeEvent; import java.io.File; import java.util.ArrayList; @@ -351,7 +353,7 @@ * The file selection mode. * @see #setFileSelectionMode(int) */ - private int fileSelectionMode = FILES_AND_DIRECTORIES; + private int fileSelectionMode = FILES_ONLY; /** * The file view. @@ -744,10 +746,16 @@ JDialog dialog = new JDialog(toUse); setSelectedFile(null); dialog.getContentPane().add(this); + dialog.addWindowListener( new WindowAdapter() + { + public void windowClosing(WindowEvent e) + { + cancelSelection(); + } + }); dialog.setModal(true); dialog.invalidate(); dialog.repaint(); - return dialog; } Modified: trunk/core/src/classpath/javax/javax/swing/JFormattedTextField.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JFormattedTextField.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JFormattedTextField.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -415,7 +415,7 @@ // to create a new formatter. Object oldValue = this.value; - this.value = formatter.stringToValue(getText());; + this.value = formatter.stringToValue(getText()); editValid = true; firePropertyChange("value", oldValue, this.value); Modified: trunk/core/src/classpath/javax/javax/swing/JList.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JList.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JList.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -1041,7 +1041,7 @@ * * @param items the initial list items. */ - public JList(Vector items) + public JList(Vector<?> items) { init(createListModel(items)); } @@ -1643,9 +1643,20 @@ * @param listData The object array to build a new list model on * @see #setModel */ - public void setListData(Vector listData) + public void setListData(final Vector<?> listData) { - setModel(createListModel(listData)); + setModel(new AbstractListModel() + { + public int getSize() + { + return listData.size(); + } + + public Object getElementAt(int i) + { + return listData.elementAt(i); + } + }); } /** Modified: trunk/core/src/classpath/javax/javax/swing/JMenuBar.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JMenuBar.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JMenuBar.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -298,19 +298,25 @@ } /** - * DOCUMENT ME! + * This method is not implemented and will throw an {@link Error} if called. * - * @return DOCUMENT ME! + * @return This method never returns anything, it throws an exception. */ public JMenu getHelpMenu() { - return null; + // the following error matches the behaviour of the reference + // implementation... + throw new Error("getHelpMenu() is not implemented"); } /** - * Returns margin betweeen menu bar's border and its menues + * Returns the margin between the menu bar's border and its menus. If the + * margin is <code>null</code>, this method returns + * <code>new Insets(0, 0, 0, 0)</code>. * - * @return margin between menu bar's border and its menues + * @return The margin (never <code>null</code>). + * + * @see #setMargin(Insets) */ public Insets getMargin() { @@ -617,13 +623,12 @@ } /** - * Sets the menu bar's "margin" bound property, which represents - * distance between the menubar's border and its menus. - * icon. When marging property is modified, PropertyChangeEvent will - * be fired to menuBar's PropertyChangeListener's. + * Sets the margin between the menu bar's border and its menus (this is a + * bound property with the name 'margin'). * - * @param m distance between the menubar's border and its menus. + * @param m the margin (<code>null</code> permitted). * + * @see #getMargin() */ public void setMargin(Insets m) { Modified: trunk/core/src/classpath/javax/javax/swing/JRootPane.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JRootPane.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JRootPane.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -505,12 +505,18 @@ } /** - * DOCUMENT ME! + * Set the layered pane for the root pane. * - * @param f DOCUMENT ME! + * @param f The JLayeredPane to be used. + * + * @throws IllegalComponentStateException if JLayeredPane + * parameter is null. */ public void setLayeredPane(JLayeredPane f) { + if (f == null) + throw new IllegalComponentStateException(); + if (layeredPane != null) remove(layeredPane); Modified: trunk/core/src/classpath/javax/javax/swing/JScrollPane.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JScrollPane.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JScrollPane.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -162,9 +162,10 @@ protected JViewport viewport; - Border viewportBorder; - boolean wheelScrollingEnabled; + private Border viewportBorder; + private boolean wheelScrollingEnabled; + public JViewport getColumnHeader() { return columnHeader; @@ -595,6 +596,7 @@ */ public JScrollPane(Component view, int vsbPolicy, int hsbPolicy) { + wheelScrollingEnabled = true; setVerticalScrollBarPolicy(vsbPolicy); setVerticalScrollBar(createVerticalScrollBar()); setHorizontalScrollBarPolicy(hsbPolicy); Modified: trunk/core/src/classpath/javax/javax/swing/JTabbedPane.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JTabbedPane.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JTabbedPane.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -887,7 +887,7 @@ if (model != null) { - if (changeListener != null) + if (changeListener == null) changeListener = createChangeListener(); model.addChangeListener(changeListener); } @@ -1054,7 +1054,10 @@ } if (getSelectedIndex() == -1) + { setSelectedIndex(0); + fireStateChanged(); + } revalidate(); repaint(); Modified: trunk/core/src/classpath/javax/javax/swing/JToggleButton.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JToggleButton.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JToggleButton.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -1,5 +1,5 @@ /* JToggleButton.java -- - Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -291,9 +291,8 @@ public JToggleButton (String text, Icon icon, boolean selected) { super(); - init(text, icon); - setModel(new ToggleButtonModel()); + init(text, icon); model.setSelected(selected); setAlignmentX(LEFT_ALIGNMENT); } Modified: trunk/core/src/classpath/javax/javax/swing/JToolTip.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JToolTip.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JToolTip.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -181,7 +181,7 @@ { StringBuffer sb = new StringBuffer(super.paramString()); sb.append(",tiptext="); - if (text != null); + if (text != null) sb.append(text); return sb.toString(); } Modified: trunk/core/src/classpath/javax/javax/swing/JWindow.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/JWindow.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/JWindow.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -38,6 +38,7 @@ package javax.swing; +import java.awt.AWTEvent; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; @@ -158,6 +159,10 @@ protected void windowInit() { + // We need to explicitly enable events here so that our processKeyEvent() + // and processWindowEvent() gets called. + enableEvents(AWTEvent.KEY_EVENT_MASK); + super.setLayout(new BorderLayout(1, 1)); getRootPane(); // will do set/create // Now we're done init stage, adds and layouts go to content pane. Modified: trunk/core/src/classpath/javax/javax/swing/LookAndFeel.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/LookAndFeel.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/LookAndFeel.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -284,7 +284,7 @@ * @return A {@link UIDefaults.LazyValue} that serves up an * {@link IconUIResource}. */ - public static Object makeIcon(Class baseClass, String gifFile) + public static Object makeIcon(Class<?> baseClass, String gifFile) { final URL file = baseClass.getResource(gifFile); return new UIDefaults.LazyValue() Modified: trunk/core/src/classpath/javax/javax/swing/Popup.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/Popup.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/Popup.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -284,7 +284,7 @@ panel.setSize(contents.getSize()); Point layeredPaneLoc = layeredPane.getLocationOnScreen(); panel.setLocation(x - layeredPaneLoc.x, y - layeredPaneLoc.y); - layeredPane.add(panel, JLayeredPane.POPUP_LAYER); + layeredPane.add(panel, JLayeredPane.POPUP_LAYER, 0); panel.repaint(); } Modified: trunk/core/src/classpath/javax/javax/swing/SizeSequence.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/SizeSequence.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/SizeSequence.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -129,14 +129,18 @@ } /** - * Returns the size of the specified element. + * Returns the size of the specified element, or 0 if the element index is + * outside the defined range. * * @param index the element index. * - * @return The size of the specified element. + * @return The size of the specified element, or 0 if the element index is + * outside the defined range. */ public int getSize(int index) { + if (index < 0 || index >= sizes.length) + return 0; return sizes[index]; } Modified: trunk/core/src/classpath/javax/javax/swing/SortingFocusTraversalPolicy.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/SortingFocusTraversalPolicy.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/SortingFocusTraversalPolicy.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -91,7 +91,7 @@ * * @param comparator the comparator to set */ - public SortingFocusTraversalPolicy(Comparator comparator) + public SortingFocusTraversalPolicy(Comparator<? super Component> comparator) { this.comparator = comparator; } @@ -119,7 +119,7 @@ * * @see #setComparator */ - protected Comparator getComparator() + protected Comparator<? super Component> getComparator() { return comparator; } @@ -131,7 +131,7 @@ * * @see #getComparator */ - protected void setComparator(Comparator comparator) + protected void setComparator(Comparator<? super Component> comparator) { this.comparator = comparator; } Modified: trunk/core/src/classpath/javax/javax/swing/SpinnerListModel.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/SpinnerListModel.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/SpinnerListModel.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -118,7 +118,7 @@ * @see SpinnerListModel#getNextValue() * @see SpinnerListModel#getValue() */ - public SpinnerListModel(List list) + public SpinnerListModel(List<?> list) { // Retain a reference to the valid list. setList(list); @@ -163,7 +163,7 @@ * * @return The backing list. */ - public List getList() + public List<?> getList() { return list; } @@ -239,7 +239,7 @@ * * @see ChangeEvent */ - public void setList(List list) + public void setList(List<?> list) { // Check for null or zero size list. if (list == null || list.size() == 0) Modified: trunk/core/src/classpath/javax/javax/swing/Timer.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/Timer.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/Timer.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -228,7 +228,7 @@ * fired by this timer * @since 1.3 */ - public EventListener[] getListeners(Class listenerType) + public <T extends EventListener> T[] getListeners(Class<T> listenerType) { return listenerList.getListeners(listenerType); } Modified: trunk/core/src/classpath/javax/javax/swing/UIDefaults.java =================================================================== --- trunk/core/src/classpath/javax/javax/swing/UIDefaults.java 2007-01-09 20:25:00 UTC (rev 3061) +++ trunk/core/src/classpath/javax/javax/swing/UIDefaults.java 2007-01-09 20:25:48 UTC (rev 3062) @@ -63,7 +63,7 @@ * * @author Ronald Veldema (rve...@cs...) */ -public class UIDefaults extends Hashtable +public class UIDefaults extends Hashtable<Object, Object> { /** Our ResourceBundles. */ @@ -672,7 +672,7 @@ * * @return the UI class for <code>id</code> */ - public Class getUIClass(String id, ClassLoader loader) + public Class<? extends ComponentUI> getUIClass(String id, ClassLoader loader) { String className = (String) get(id); if (className == null) @@ -681,7 +681,7 @@ { if (loader == null) loader = ClassLoader.getSystemClassLoader(); - return loader.loadClass (className); + return (Class<? extends ComponentUI>) loader.loadClass (className); } catch (Exception e) { @@ -698,7 +698,7 @@ * * @return the UI class for <code>id</code> */ - public Class getUIClass(String id) + public Class<? extends ComponentUI> getUIClass(String id) { return getUIClass (id, null); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |