]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
MemoryImageSource.java, [...]: New versions from classpath.
authorMichael Koch <konqueror@gmx.de>
Mon, 14 Jul 2003 05:33:30 +0000 (05:33 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Mon, 14 Jul 2003 05:33:30 +0000 (05:33 +0000)
2003-07-14  Michael Koch  <konqueror@gmx.de>

* java/awt/image/MemoryImageSource.java,
java/beans/PropertyEditorManager.java,
javax/naming/CompoundName.java,
javax/naming/spi/NamingManager.java,
javax/swing/AbstractButton.java,
javax/swing/ButtonModel.java,
javax/swing/SwingUtilities.java,
javax/swing/UIManager.java,
javax/swing/colorchooser/DefaultColorSelectionModel.java,
javax/swing/event/AncestorEvent.java,
javax/swing/event/InternalFrameEvent.java,
java/util/zip/ZipFile.java:
New versions from classpath.

From-SVN: r69321

13 files changed:
libjava/ChangeLog
libjava/java/awt/image/MemoryImageSource.java
libjava/java/beans/PropertyEditorManager.java
libjava/java/util/zip/ZipFile.java
libjava/javax/naming/CompoundName.java
libjava/javax/naming/spi/NamingManager.java
libjava/javax/swing/AbstractButton.java
libjava/javax/swing/ButtonModel.java
libjava/javax/swing/SwingUtilities.java
libjava/javax/swing/UIManager.java
libjava/javax/swing/colorchooser/DefaultColorSelectionModel.java
libjava/javax/swing/event/AncestorEvent.java
libjava/javax/swing/event/InternalFrameEvent.java

index fb23402138d8dcdaf2ae7d5bbbc0fd74d2ea4fc6..cc46804b0c0edcd2531978492d2529a667de1c6c 100644 (file)
@@ -1,3 +1,19 @@
+2003-07-14  Michael Koch  <konqueror@gmx.de>
+
+       * java/awt/image/MemoryImageSource.java,
+       java/beans/PropertyEditorManager.java,
+       javax/naming/CompoundName.java,
+       javax/naming/spi/NamingManager.java,
+       javax/swing/AbstractButton.java,
+       javax/swing/ButtonModel.java,
+       javax/swing/SwingUtilities.java,
+       javax/swing/UIManager.java,
+       javax/swing/colorchooser/DefaultColorSelectionModel.java,
+       javax/swing/event/AncestorEvent.java,
+       javax/swing/event/InternalFrameEvent.java,
+       java/util/zip/ZipFile.java:
+       New versions from classpath.
+
 2003-07-13  Michael Koch  <konqueror@gmx.de>
 
        * gnu/java/nio/FileChannelImpl.java,
index 0e8d462067240bef2bf4d957cc4f77e5b1e20958..5006afe79e56071845e7f9a3b5712f2e58f662ef 100644 (file)
@@ -74,7 +74,7 @@ public class MemoryImageSource implements ImageProducer
        this.props = props;
        int max = (( scansize > width ) ? scansize : width );
        pixelb = new byte[ max  * height ];
-       System.arraycopy( pix, 0, pixelb, 0, max );
+       System.arraycopy( pix, 0, pixelb, 0, max * height );
     }
     /**
        Constructs an ImageProducer from memory
@@ -100,7 +100,7 @@ public class MemoryImageSource implements ImageProducer
        this.props = props;
        int max = (( scansize > width ) ? scansize : width );
        pixeli = new int[ max  * height ];
-       System.arraycopy( pix, 0, pixeli, 0, max );
+       System.arraycopy( pix, 0, pixeli, 0, max * height );
     }
     /**
        Constructs an ImageProducer from memory using the default RGB ColorModel
@@ -226,6 +226,7 @@ public class MemoryImageSource implements ImageProducer
        if( props != null ) {
            ic.setProperties( props );
        }
+       ic.setDimensions(width, height);
        if( pixeli != null ) {
            ic.setPixels( 0, 0, width, height, cm, pixeli, offset, scansize );
        } else {
index cb03563d50e0d5a3adf359885c7128a22bddf8c9..aa0e1776dea9d4860927b932981208ef12256961 100644 (file)
@@ -140,9 +140,13 @@ public class PropertyEditorManager
             return (PropertyEditor)found.newInstance();
           }
 
+       ClassLoader contextClassLoader
+               = Thread.currentThread().getContextClassLoader();
+
         try
           {
-            found = Class.forName(editedClass.getName()+"Editor");
+            found = Class.forName(editedClass.getName()+"Editor", true,
+                                 contextClassLoader);
             registerEditor(editedClass,found);
             return (PropertyEditor)found.newInstance();
           }
@@ -150,14 +154,18 @@ public class PropertyEditorManager
           {
           }
 
-        String appendName = "." + ClassHelper.getTruncatedClassName(editedClass) + "Editor";
+        String appendName
+               = "."
+               + ClassHelper.getTruncatedClassName(editedClass)
+               + "Editor";
         synchronized(editorSearchPath)
           {
             for(int i=0;i<editorSearchPath.length;i++)
               {
                 try
                   {
-                    found = Class.forName(editorSearchPath[i] + appendName);
+                    found = Class.forName(editorSearchPath[i] + appendName,
+                                         true, contextClassLoader);
                     registerEditor(editedClass,found);
                     return (PropertyEditor)found.newInstance();
                   }
index 06238cea176d6e13a937112c7a8e265d422b383f..b6bc5414d0897f71d2d19cd04b27f24f872010b0 100644 (file)
@@ -308,7 +308,7 @@ public class ZipFile implements ZipConstants
    */
   protected void finalize() throws IOException
   {
-    if (!closed) close();
+    if (!closed && raf != null) close();
   }
 
   /**
index 20b6cc51cb3dbf9c0c06bd5e2ab6436fa7baadec..20396398d101011849d3241362e4ee48dd36e9af 100644 (file)
@@ -142,13 +142,17 @@ public class CompoundName implements Name, Cloneable, Serializable
            // Otherwise, fall through.
          }
        // Quotes are only special at the start of a component.
-       else if (new_element.length () == 0 && special == beginQuote)
+       else if (new_element.length () == 0
+                && special == beginQuote
+                && beginQuote != null)
          {
            quote = endQuote;
            i += special.length ();
            continue;
          }
-       else if (new_element.length () == 0 && special == beginQuote2)
+       else if (new_element.length () == 0
+                && special == beginQuote2
+                && beginQuote2 != null)
          {
            quote = endQuote2;
            i += special.length ();
index 6d02f9d2cba9db56dc1be7db5c6166a0061d3eb9..8b215cee5c516c673bb7aa2a7d1d53fd0c264e09 100644 (file)
@@ -83,13 +83,17 @@ public class NamingManager
 
        try
          {
-           icf = (InitialContextFactory) Class.forName (java_naming_factory_initial).newInstance ();
+           icf = (InitialContextFactory)Class.forName
+               (java_naming_factory_initial, true,
+                Thread.currentThread().getContextClassLoader())
+               .newInstance ();
          }
        catch (Exception exception)
          {
            NoInitialContextException e
-             = new NoInitialContextException ("Can't load InitialContextFactory class: "
-                                              + java_naming_factory_initial);
+             = new NoInitialContextException
+             ("Can't load InitialContextFactory class: "
+              + java_naming_factory_initial);
            e.setRootCause(exception);
            throw e;
          }
index 951650dbdbd45e4feb1e0573da07b1a39f88e1fa..d44d9775f3ac6fe2e10cb8dc6abd3313a2df66d2 100644 (file)
@@ -71,740 +71,731 @@ import javax.swing.text.AttributeSet;
 public abstract class AbstractButton extends JComponent
   implements ItemSelectable, SwingConstants
 {
-       Icon default_icon, pressed_button, disabled_button,
-       selected_button, disabled_selected_button, current_icon;
-       String text;
-
-       int vert_align = CENTER;
-       int hori_align = CENTER;
-       int hori_text_pos = CENTER;
-       int vert_text_pos = CENTER;
-
-       boolean paint_border = true, paint_focus;
-       Action action_taken;
-       ButtonModel model;
-       Insets margin;
-
-
-       public static final String FOCUS_PAINTED_CHANGED_PROPERTY = "focusPainted";
-
-       /**
-        * AccessibleAbstractButton
-        */
-       protected abstract class AccessibleAbstractButton 
-               extends AccessibleJComponent 
-               implements AccessibleAction, AccessibleValue, AccessibleText {
-
-               //-------------------------------------------------------------
-               // Initialization ---------------------------------------------
-               //-------------------------------------------------------------
-
-               /**
-                * Constructor AccessibleAbstractButton
-                * @param component TODO
-                */
-               protected AccessibleAbstractButton(AbstractButton component) {
-                       super(component);
-                       // TODO
-               } // AccessibleAbstractButton()
-
-
-               //-------------------------------------------------------------
-               // Methods ----------------------------------------------------
-               //-------------------------------------------------------------
-
-               /**
-                * getAccessibleStateSet
-                * @returns AccessibleStateSet
-                */
-               public AccessibleStateSet getAccessibleStateSet() {
-                       return null; // TODO
-               } // getAccessibleStateSet()
-
-               /**
-                * getAccessibleName
-                * @returns String
-                */
-               public String getAccessibleName() {
-                       return null; // TODO
-               } // getAccessibleName()
-
-               /**
-                * getAccessibleIcon
-                * @returns AccessibleIcon[]
-                */
-               public AccessibleIcon[] getAccessibleIcon() {
-                       return null; // TODO
-               } // getAccessibleIcon()
-
-               /**
-                * getAccessibleRelationSet
-                * @returns AccessibleRelationSet
-                */
-               public AccessibleRelationSet getAccessibleRelationSet() {
-                       return null; // TODO
-               } // getAccessibleRelationSet()
-
-               /**
-                * getAccessibleAction
-                * @returns AccessibleAction
-                */
-               public AccessibleAction getAccessibleAction() {
-                       return null; // TODO
-               } // getAccessibleAction()
-
-               /**
-                * getAccessibleValue
-                * @returns AccessibleValue
-                */
-               public AccessibleValue getAccessibleValue() {
-                       return null; // TODO
-               } // getAccessibleValue()
-
-               /**
-                * getAccessibleActionCount
-                * @returns int
-                */
-               public int getAccessibleActionCount() {
-                       return 0; // TODO
-               } // getAccessibleActionCount()
-
-               /**
-                * getAccessibleActionDescription
-                * @param value0 TODO
-                * @returns String
-                */
-               public String getAccessibleActionDescription(int value0) {
-                       return null; // TODO
-               } // getAccessibleActionDescription()
-
-               /**
-                * doAccessibleAction
-                * @param value0 TODO
-                * @returns boolean
-                */
-               public boolean doAccessibleAction(int value0) {
-                       return false; // TODO
-               } // doAccessibleAction()
-
-               /**
-                * getCurrentAccessibleValue
-                * @returns Number
-                */
-               public Number getCurrentAccessibleValue() {
-                       return null; // TODO
-               } // getCurrentAccessibleValue()
-
-               /**
-                * setCurrentAccessibleValue
-                * @param value0 TODO
-                * @returns boolean
-                */
-               public boolean setCurrentAccessibleValue(Number value0) {
-                       return false; // TODO
-               } // setCurrentAccessibleValue()
-
-               /**
-                * getMinimumAccessibleValue
-                * @returns Number
-                */
-               public Number getMinimumAccessibleValue() {
-                       return null; // TODO
-               } // getMinimumAccessibleValue()
-
-               /**
-                * getMaximumAccessibleValue
-                * @returns Number
-                */
-               public Number getMaximumAccessibleValue() {
-                       return null; // TODO
-               } // getMaximumAccessibleValue()
-
-               /**
-                * getAccessibleText
-                * @returns AccessibleText
-                */
-               public AccessibleText getAccessibleText() {
-                       return null; // TODO
-               } // getAccessibleText()
-
-               /**
-                * getIndexAtPoint
-                * @param value0 TODO
-                * @returns int
-                */
-               public int getIndexAtPoint(Point value0) {
-                       return 0; // TODO
-               } // getIndexAtPoint()
-
-               /**
-                * getCharacterBounds
-                * @param value0 TODO
-                * @returns Rectangle
-                */
-               public Rectangle getCharacterBounds(int value0) {
-                       return null; // TODO
-               } // getCharacterBounds()
-
-               /**
-                * getCharCount
-                * @returns int
-                */
-               public int getCharCount() {
-                       return 0; // TODO
-               } // getCharCount()
-
-               /**
-                * getCaretPosition
-                * @returns int
-                */
-               public int getCaretPosition() {
-                       return 0; // TODO
-               } // getCaretPosition()
-
-               /**
-                * getAtIndex
-                * @param value0 TODO
-                * @param value1 TODO
-                * @returns String
-                */
-               public String getAtIndex(int value0, int value1) {
-                       return null; // TODO
-               } // getAtIndex()
-
-               /**
-                * getAfterIndex
-                * @param value0 TODO
-                * @param value1 TODO
-                * @returns String
-                */
-               public String getAfterIndex(int value0, int value1) {
-                       return null; // TODO
-               } // getAfterIndex()
-
-               /**
-                * getBeforeIndex
-                * @param value0 TODO
-                * @param value1 TODO
-                * @returns String
-                */
-               public String getBeforeIndex(int value0, int value1) {
-                       return null; // TODO
-               } // getBeforeIndex()
-
-               /**
-                * getCharacterAttribute
-                * @param value0 TODO
-                * @returns AttributeSet
-                */
-               public AttributeSet getCharacterAttribute(int value0) {
-                       return null; // TODO
-               } // getCharacterAttribute()
-
-               /**
-                * getSelectionStart
-                * @returns int
-                */
-               public int getSelectionStart() {
-                       return 0; // TODO
-               } // getSelectionStart()
-
-               /**
-                * getSelectionEnd
-                * @returns int
-                */
-               public int getSelectionEnd() {
-                       return 0; // TODO
-               } // getSelectionEnd()
-
-               /**
-                * getSelectedText
-                * @returns String
-                */
-               public String getSelectedText() {
-                       return null; // TODO
-               } // getSelectedText()
-
-               /**
-                * getTextRectangle
-                * @returns Rectangle
-                */
-               private Rectangle getTextRectangle() {
-                       return null; // TODO
-               } // getTextRectangle()
-
-
-       } // AccessibleAbstractButton
-
-
-       static private class JFocusListener implements FocusListener
-       {
-               AbstractButton c;
-
-               JFocusListener(AbstractButton c)
-               {
-                       this.c = c;
-               }
-
-               public void focusLost(FocusEvent event)
-               {
-                       c.getModel().setArmed(false);
-
-                       System.out.println("LOST FOCUS");
-                       if (c.isFocusPainted())
-                       {
-                               c.repaint();
-                       }
-               }
-               public void focusGained(FocusEvent event)
-               {
-                       System.out.println("GAIN FOCUS");
-               }
-       }
-
-
-       /**********************************************
-        *
-        * 
-        *       Constructors
-        *
-        *
-        ****************/
-
-       AbstractButton()
-       {
-               this("",null);
-       }
-
-       AbstractButton(String text,
-                      Icon icon)
-       {
-               this.text    = text;
-               setIcon(icon);
-
-               setAlignmentX(LEFT_ALIGNMENT);
-               setAlignmentY(CENTER_ALIGNMENT);
-
-               addFocusListener( new JFocusListener(this) );
-
-               setModel(new DefaultButtonModel(this));
-
-               updateUI(); // get a proper ui
-       }
-
-
-       /**********************************************
-        *
-        * 
-        *       Actions etc
-        *
-        *
-        ****************/
-
-       public ButtonModel getModel()
-       {       return model;    }
-       public void setModel(ButtonModel newModel)
-       {       model = newModel;    }
-
-       public String getActionCommand()
-       {       return getModel().getActionCommand();    }
-       public void setActionCommand(String aCommand)
-       {   getModel().setActionCommand(aCommand);   }
-
-       public void addActionListener(ActionListener l)
-       {       getModel().addActionListener(l);    }
-       public void removeActionListener(ActionListener l)
-       {       getModel().removeActionListener(l);    }
-
-       public void addChangeListener(ChangeListener l)
-       {   getModel().addChangeListener(l);     }
-       public void removeChangeListener(ChangeListener l)
-       {  getModel().removeChangeListener(l);    }
-
-        public void addItemListener(ItemListener l)
-       {  getModel().addItemListener(l);    }
-        public void removeItemListener(ItemListener l)
-       {  getModel().removeItemListener(l);  }
-
-       public int getHorizontalAlignment()
-       {       return hori_align;    }
-       public int getHorizontalTextPosition()
-       {       return hori_text_pos;    }
-       public int getVerticalAlignment()
-       {       return vert_align;   }
-       public int getVerticalTextPosition()
-       {       return vert_text_pos;  }
-
-
-       protected  void fireItemStateChanged(ItemEvent event)
-       {    getModel().fireItemStateChanged(event);    }
-       protected  void fireStateChanged(ChangeEvent event)
-       {        getModel().fireStateChanged(event);    }
-       protected void fireActionPerformed(ActionEvent event)
-       {       getModel().fireActionPerformed(event);    }
-
-       public void setVerticalAlignment(int alignment)
-       {       vert_align = alignment;    }
-       public void setHorizontalAlignment(int alignment)
-       {   hori_align = alignment;   }
-       public void setVerticalTextPosition(int textPosition)
-       {       vert_text_pos = textPosition;    }
-       public void setHorizontalTextPosition(int textPosition)
-       {   hori_text_pos = textPosition;   }
-
-       public int getMnemonic()
-       {       return getModel().getMnemonic();    }
-       public void setMnemonic(char mne)
-       {       getModel().setMnemonic(mne);    }
-       public void setMnemonic(int mne)
-       {       getModel().setMnemonic(mne);    }
-
-       public void setRolloverEnabled(boolean b)
-       {    getModel().setRollover(b);    }
-       public boolean isRolloverEnabled()
-       {    return getModel().isRollover();     }
-
-
-       public boolean isBorderPainted()
-       {       return paint_border;    }
-       public void setBorderPainted(boolean b)
-       {
-               if (b != paint_border)
-               {
-                       paint_border = b;
-                       revalidate();
-                       repaint();
-               }
-       }
-
-       public Action getAction()
-       {       return action_taken;    }
-       public void setAction(Action a)
-       {
-               action_taken = a;
-               revalidate();
-               repaint();
-       }
-
-       public void setSelected(boolean b)
-       {       getModel().setSelected(b);    }
-       public boolean isSelected()
-       {       return getModel().isSelected();     }
-
-
-        public Icon getIcon()
-       {       return default_icon;    }
-       public void setIcon(Icon defaultIcon)
-       {
-               if (default_icon == defaultIcon)
-                       return;
-
-               default_icon = defaultIcon;
-               if (default_icon != null)
-               {
-                  // XXX FIXME - icons do not know their parent
-//                     default_icon.setParent(this);
-               }
-               revalidate();
-               repaint();
-       }
-
-       public String getText()
-       {       return text;    }
-       public void setLabel(String label)
-       {       setText(label);    }
-       public String getLabel()
-       {       return getText();    }
-       public void setText(String text)
-       {
-               this.text = text;
-               revalidate();
-               repaint();
-       }
-
-
-        public         Insets getMargin()
-       {      return margin; }
-       public void setMargin(Insets m)
-       {
-               margin = m;
-               revalidate();
-               repaint();
-       }
-
-       public void setEnabled(boolean b)
-       {
-               super.setEnabled(b);
-               getModel().setEnabled(b);
-               repaint();
-       }
-
-       public Icon getPressedIcon()
-       {       return pressed_button;    }
-       public void setPressedIcon(Icon pressedIcon)
-       {
-               pressed_button = pressedIcon;
-               revalidate();
-               repaint();
-       }
-
-
-       public Icon getDisabledIcon()
-       {       return disabled_button;    }
-       public void setDisabledIcon(Icon disabledIcon)
-       {
-               disabled_button = disabledIcon;
-               revalidate();
-               repaint();
-       }
-
-       public boolean isFocusPainted()
-       {   return paint_focus;   }
-       public void setFocusPainted(boolean b)
-       {
-               boolean old = paint_focus;
-               paint_focus = b;
-
-               firePropertyChange(FOCUS_PAINTED_CHANGED_PROPERTY,
-                                  old,
-                                  b);
-               if (hasFocus())
-               {
-                       revalidate();
-                       repaint();
-               }
-       }
-
-       public boolean isFocusTraversable()
-       {
-               //Identifies whether or not this component can receive the focus.
-               return true;
-       }
-
-
-       protected  int checkHorizontalKey(int key, String exception)
-       {
-               //       Verify that key is a legal value for the horizontalAlignment properties.
-               return 0;
-       }
-       protected  int checkVerticalKey(int key, String exception)
-       {
-               //       Ensures that the key is a valid.
-               return 0;
-       }
-       protected  void configurePropertiesFromAction(Action a)
-       {
-               //Factory method which sets the ActionEvent source's properties according to values from the Action instance.
-       }
-
-       protected  ActionListener createActionListener()
-       {
-               return new ActionListener()
-                      {
-                              public void actionPerformed(ActionEvent e) { }
-                      };
-       }
-
-       protected  PropertyChangeListener createActionPropertyChangeListener(Action a)
-       {
-               //Factory method which creates the PropertyChangeListener used to update the ActionEvent source as properties change on its Action instance.
-               return null;
-       }
-       protected  ChangeListener createChangeListener()
-       {
-               //       Subclasses that want to handle ChangeEvents differently can override this to return another ChangeListener implementation.
-               return new ChangeListener()
-                      {
-                              public void stateChanged(ChangeEvent e) { }
-                      };
-       }
-
-       protected  ItemListener createItemListener()
-       {
-               return new ItemListener()
-                      {
-                              public void itemStateChanged(ItemEvent e) { }
-                      };
-       }
-
-
-       public void doClick()
-       {
-               doClick(100);
-       }
-       public void doClick(int pressTime)
-       {
-           //Toolkit.tlkBeep ();
-               //Programmatically perform a "click".
-       }
-
-
-       public Icon getDisabledSelectedIcon()
-       {
-               //Returns the icon used by the button when it's disabled and selected.
-               return disabled_selected_button;
-       }
-
-
-       public Icon getRolloverIcon()
-       {
-               //       Returns the rollover icon for the button.
-               return null;
-       }
-
-       Icon getRolloverSelectedIcon()
-       {
-               //       Returns the rollover selection icon for the button.
-               return null;
-       }
-       Icon getSelectedIcon()
-       {
-               //       Returns the selected icon for the button.
-               return selected_button;
-       }
-
-
-       public Object[] getSelectedObjects()
-       {
-               //Returns an array (length 1) containing the label or null if the button is not selected.
-               return null;
-       }
-
-
-       public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
-       {
-               //This is overridden to return false if the current Icon's Image is not equal to the passed in Image img.
-               return current_icon == img;
-       }
-
-        public boolean isContentAreaFilled()
-       {
-               //       Checks whether the "content area" of the button should be filled.
-               return false;
-       }
-
-
-
-       protected  void paintBorder(Graphics g)
-       {
-               //       Paint the button's border if BorderPainted property is true.
-               if (isBorderPainted())
-                       super.paintBorder(g);
-       }
-       protected  String paramString()
-       {
-               //        Returns a string representation of this AbstractButton.
-               return "AbstractButton";
-       }
-
-
-       public void setContentAreaFilled(boolean b)
-       {
-               //Sets whether the button should paint the content area or leave it transparent.
-       }
-
-
-       public void setDisabledSelectedIcon(Icon disabledSelectedIcon)
-       {
-               //          Sets the disabled selection icon for the button.
-       }
-
-       public void setRolloverIcon(Icon rolloverIcon)
-       {
-               //       Sets the rollover icon for the button.
-       }
-        public void setRolloverSelectedIcon(Icon rolloverSelectedIcon)
-       {
-               //       Sets the rollover selected icon for the button.
-       }
-
-
-       public void setSelectedIcon(Icon selectedIcon)
-       {
-               //       Sets the selected icon for the button.
-       }
-
-
-       public void setUI(ButtonUI ui)
-       {       //       Sets the L&F object that renders this component.
-               super.setUI(ui);
-       }
-
-       public ButtonUI getUI()
-       {
-               //Returns the L&F object that renders this component.
-               return (ButtonUI) ui;
-       }
-
-        public void updateUI()
-       {
-               /*
-                 //          Notification from the UIFactory that the L&F has changed.
-                 if (getUI() == null)
-                 {
-                 setUI(getUI());
-                 }
-               */
-       }
-
-       protected void processActionEvent(ActionEvent e)
-       {
-               System.out.println("PROCESS-ACTION-EVENT: " + e);
-       }
-
-
-       protected void processMouseEvent(MouseEvent e)
-       {
-               //      System.out.println("PROCESS-MOUSE-EVENT: " + e + ", PRESSED-IN-MODEL="+getModel().isPressed());
-
-               switch (e.getID())
-               {
-               case MouseEvent.MOUSE_MOVED:
-                       {
-                               break;
-                       }
-               case MouseEvent.MOUSE_PRESSED:
-                       {
-                               if (! isEnabled())
-                               {
-                                       System.out.println("button not enabled, ignoring press");
-                               }
-                               else
-                               {
-                                       System.out.println("telling model:press: " + getModel());
-                                       getModel().setPressed(true);
-                                       repaint();
-                               }
-                               break;
-                       }
-
-               case MouseEvent.MOUSE_RELEASED:
-                       {
-                               if (! isEnabled())
-                               {
-                                       System.out.println("button not enabled, ignoring release");
-                               }
-                               else
-                               {
-                                       int flags = 0;
-
-                                       System.out.println("        XXX--> " + getActionCommand());
-
-                                       fireActionPerformed(new ActionEvent(this,
-                                                                           ActionEvent.ACTION_PERFORMED,
-                                                                           getActionCommand(),
-                                                                           flags));
-
-                                       //System.out.println("telling model:release");
-                                       getModel().setPressed(false);
-                                       repaint();
-                               }
-                               break;
-                       }
-               case MouseEvent.MOUSE_CLICKED:
-                       {
-                               break;
-                       }
-               }
-       }
+  Icon default_icon, pressed_button, disabled_button,
+    selected_button, disabled_selected_button, current_icon;
+  String text;
+
+  int vert_align = CENTER;
+  int hori_align = CENTER;
+  int hori_text_pos = CENTER;
+  int vert_text_pos = CENTER;
+
+  boolean paint_border = true, paint_focus;
+  Action action_taken;
+  ButtonModel model;
+  Insets margin;
+
+  public static final String FOCUS_PAINTED_CHANGED_PROPERTY = "focusPainted";
+
+  /**
+   * AccessibleAbstractButton
+   */
+  protected abstract class AccessibleAbstractButton 
+    extends AccessibleJComponent 
+    implements AccessibleAction, AccessibleValue, AccessibleText {
+
+    /**
+     * Constructor AccessibleAbstractButton
+     * @param component TODO
+     */
+    protected AccessibleAbstractButton(AbstractButton component) {
+      super(component);
+      // TODO
+    } // AccessibleAbstractButton()
+
+    /**
+     * getAccessibleStateSet
+     * @returns AccessibleStateSet
+     */
+    public AccessibleStateSet getAccessibleStateSet() {
+      return null; // TODO
+    } // getAccessibleStateSet()
+
+    /**
+     * getAccessibleName
+     * @returns String
+     */
+    public String getAccessibleName() {
+      return null; // TODO
+    } // getAccessibleName()
+
+    /**
+     * getAccessibleIcon
+     * @returns AccessibleIcon[]
+     */
+    public AccessibleIcon[] getAccessibleIcon() {
+      return null; // TODO
+    } // getAccessibleIcon()
+
+    /**
+     * getAccessibleRelationSet
+     * @returns AccessibleRelationSet
+     */
+    public AccessibleRelationSet getAccessibleRelationSet() {
+      return null; // TODO
+    } // getAccessibleRelationSet()
+
+    /**
+     * getAccessibleAction
+     * @returns AccessibleAction
+     */
+    public AccessibleAction getAccessibleAction() {
+      return null; // TODO
+    } // getAccessibleAction()
+
+    /**
+     * getAccessibleValue
+     * @returns AccessibleValue
+     */
+    public AccessibleValue getAccessibleValue() {
+      return null; // TODO
+    } // getAccessibleValue()
+
+    /**
+     * getAccessibleActionCount
+     * @returns int
+     */
+    public int getAccessibleActionCount() {
+      return 0; // TODO
+    } // getAccessibleActionCount()
+
+    /**
+     * getAccessibleActionDescription
+     * @param value0 TODO
+     * @returns String
+     */
+    public String getAccessibleActionDescription(int value0) {
+      return null; // TODO
+    } // getAccessibleActionDescription()
+
+    /**
+     * doAccessibleAction
+     * @param value0 TODO
+     * @returns boolean
+     */
+    public boolean doAccessibleAction(int value0) {
+      return false; // TODO
+    } // doAccessibleAction()
+
+    /**
+     * getCurrentAccessibleValue
+     * @returns Number
+     */
+    public Number getCurrentAccessibleValue() {
+      return null; // TODO
+    } // getCurrentAccessibleValue()
+
+    /**
+     * setCurrentAccessibleValue
+     * @param value0 TODO
+     * @returns boolean
+     */
+    public boolean setCurrentAccessibleValue(Number value0) {
+      return false; // TODO
+    } // setCurrentAccessibleValue()
+
+    /**
+     * getMinimumAccessibleValue
+     * @returns Number
+     */
+    public Number getMinimumAccessibleValue() {
+      return null; // TODO
+    } // getMinimumAccessibleValue()
+
+    /**
+     * getMaximumAccessibleValue
+     * @returns Number
+     */
+    public Number getMaximumAccessibleValue() {
+      return null; // TODO
+    } // getMaximumAccessibleValue()
+
+    /**
+     * getAccessibleText
+     * @returns AccessibleText
+     */
+    public AccessibleText getAccessibleText() {
+      return null; // TODO
+    } // getAccessibleText()
+
+    /**
+     * getIndexAtPoint
+     * @param value0 TODO
+     * @returns int
+     */
+    public int getIndexAtPoint(Point value0) {
+      return 0; // TODO
+    } // getIndexAtPoint()
+
+    /**
+     * getCharacterBounds
+     * @param value0 TODO
+     * @returns Rectangle
+     */
+    public Rectangle getCharacterBounds(int value0) {
+      return null; // TODO
+    } // getCharacterBounds()
+
+    /**
+     * getCharCount
+     * @returns int
+     */
+    public int getCharCount() {
+      return 0; // TODO
+    } // getCharCount()
+
+    /**
+     * getCaretPosition
+     * @returns int
+     */
+    public int getCaretPosition() {
+      return 0; // TODO
+    } // getCaretPosition()
+
+    /**
+     * getAtIndex
+     * @param value0 TODO
+     * @param value1 TODO
+     * @returns String
+     */
+    public String getAtIndex(int value0, int value1) {
+      return null; // TODO
+    } // getAtIndex()
+
+    /**
+     * getAfterIndex
+     * @param value0 TODO
+     * @param value1 TODO
+     * @returns String
+     */
+    public String getAfterIndex(int value0, int value1) {
+      return null; // TODO
+    } // getAfterIndex()
+
+    /**
+     * getBeforeIndex
+     * @param value0 TODO
+     * @param value1 TODO
+     * @returns String
+     */
+    public String getBeforeIndex(int value0, int value1) {
+      return null; // TODO
+    } // getBeforeIndex()
+
+    /**
+     * getCharacterAttribute
+     * @param value0 TODO
+     * @returns AttributeSet
+     */
+    public AttributeSet getCharacterAttribute(int value0) {
+      return null; // TODO
+    } // getCharacterAttribute()
+
+    /**
+     * getSelectionStart
+     * @returns int
+     */
+    public int getSelectionStart() {
+      return 0; // TODO
+    } // getSelectionStart()
+
+    /**
+     * getSelectionEnd
+     * @returns int
+     */
+    public int getSelectionEnd() {
+      return 0; // TODO
+    } // getSelectionEnd()
+
+    /**
+     * getSelectedText
+     * @returns String
+     */
+    public String getSelectedText() {
+      return null; // TODO
+    } // getSelectedText()
+
+    /**
+     * getTextRectangle
+     * @returns Rectangle
+     */
+    private Rectangle getTextRectangle() {
+      return null; // TODO
+    } // getTextRectangle()
+
+
+  } // AccessibleAbstractButton
+
+
+  static private class JFocusListener implements FocusListener
+  {
+    AbstractButton c;
+
+    JFocusListener(AbstractButton c)
+    {
+      this.c = c;
+    }
+
+    public void focusLost(FocusEvent event)
+    {
+      c.getModel().setArmed(false);
+
+      System.out.println("LOST FOCUS");
+      if (c.isFocusPainted())
+        {
+          c.repaint();
+        }
+    }
+    public void focusGained(FocusEvent event)
+    {
+      System.out.println("GAIN FOCUS");
+    }
+  }
+
+  AbstractButton()
+  {
+    this("",null);
+  }
+
+  AbstractButton(String text,
+                 Icon icon)
+  {
+    this.text    = text;
+    setIcon(icon);
+
+    setAlignmentX(LEFT_ALIGNMENT);
+    setAlignmentY(CENTER_ALIGNMENT);
+
+    addFocusListener( new JFocusListener(this) );
+
+    setModel(new DefaultButtonModel(this));
+
+    updateUI(); // get a proper ui
+  }
+
+  public ButtonModel getModel()
+  {    return model;    }
+
+  public void setModel(ButtonModel newModel)
+  {    model = newModel;    }
+
+  public String getActionCommand()
+  {    return getModel().getActionCommand();    }
+
+  public void setActionCommand(String aCommand)
+  {   getModel().setActionCommand(aCommand);   }
+
+  public void addActionListener(ActionListener l)
+  {    getModel().addActionListener(l);    }
+
+  public void removeActionListener(ActionListener l)
+  {    getModel().removeActionListener(l);    }
+
+  public void addChangeListener(ChangeListener l)
+  {   getModel().addChangeListener(l);     }
+
+  public void removeChangeListener(ChangeListener l)
+  {  getModel().removeChangeListener(l);    }
+
+  public void addItemListener(ItemListener l)
+  {  getModel().addItemListener(l);    }
+
+  public void removeItemListener(ItemListener l)
+  {  getModel().removeItemListener(l);  }
+
+  public int getHorizontalAlignment()
+  {    return hori_align;    }
+
+  public int getHorizontalTextPosition()
+  {    return hori_text_pos;    }
+
+  public int getVerticalAlignment()
+  {    return vert_align;   }
+
+  public int getVerticalTextPosition()
+  {    return vert_text_pos;  }
+
+  protected  void fireItemStateChanged(ItemEvent event)
+  {
+  }
+  
+  protected  void fireStateChanged(ChangeEvent event)
+  {
+  }
+  
+  protected void fireActionPerformed(ActionEvent event)
+  {
+  }
+
+  public void setVerticalAlignment(int alignment)
+  {    vert_align = alignment;    }
+
+  public void setHorizontalAlignment(int alignment)
+  {   hori_align = alignment;   }
+
+  public void setVerticalTextPosition(int textPosition)
+  {    vert_text_pos = textPosition;    }
+
+  public void setHorizontalTextPosition(int textPosition)
+  {   hori_text_pos = textPosition;   }
+
+  public int getMnemonic()
+  {    return getModel().getMnemonic();    }
+
+  public void setMnemonic(char mne)
+  {    getModel().setMnemonic(mne);    }
+
+  public void setMnemonic(int mne)
+  {    getModel().setMnemonic(mne);    }
+
+  public void setRolloverEnabled(boolean b)
+  {    getModel().setRollover(b);    }
+
+  public boolean isRolloverEnabled()
+  {    return getModel().isRollover();     }
+
+  public boolean isBorderPainted()
+  {    return paint_border;    }
+
+  public void setBorderPainted(boolean b)
+  {
+    if (b != paint_border)
+      {
+        paint_border = b;
+        revalidate();
+        repaint();
+      }
+  }
+
+  public Action getAction()
+  {    return action_taken;    }
+
+  public void setAction(Action a)
+  {
+    action_taken = a;
+    revalidate();
+    repaint();
+  }
+
+  public void setSelected(boolean b)
+  {    getModel().setSelected(b);    }
+
+  public boolean isSelected()
+  {    return getModel().isSelected();     }
+
+  public Icon getIcon()
+  {    return default_icon;    }
+
+  public void setIcon(Icon defaultIcon)
+  {
+    if (default_icon == defaultIcon)
+      return;
+
+    default_icon = defaultIcon;
+    if (default_icon != null)
+      {
+        // XXX FIXME - icons do not know their parent
+        //                     default_icon.setParent(this);
+      }
+    revalidate();
+    repaint();
+  }
+
+  public String getText()
+  {    return text;    }
+
+  public void setLabel(String label)
+  {    setText(label);    }
+
+  public String getLabel()
+  {    return getText();    }
+
+  public void setText(String text)
+  {
+    this.text = text;
+    revalidate();
+    repaint();
+  }
+
+  public       Insets getMargin()
+  {      return margin; }
+
+  public void setMargin(Insets m)
+  {
+    margin = m;
+    revalidate();
+    repaint();
+  }
+
+  public void setEnabled(boolean b)
+  {
+    super.setEnabled(b);
+    getModel().setEnabled(b);
+    repaint();
+  }
+
+  public Icon getPressedIcon()
+  {    return pressed_button;    }
+
+  public void setPressedIcon(Icon pressedIcon)
+  {
+    pressed_button = pressedIcon;
+    revalidate();
+    repaint();
+  }
+
+  public Icon getDisabledIcon()
+  {    return disabled_button;    }
+
+  public void setDisabledIcon(Icon disabledIcon)
+  {
+    disabled_button = disabledIcon;
+    revalidate();
+    repaint();
+  }
+
+  public boolean isFocusPainted()
+  {   return paint_focus;   }
+
+  public void setFocusPainted(boolean b)
+  {
+    boolean old = paint_focus;
+    paint_focus = b;
+
+    firePropertyChange(FOCUS_PAINTED_CHANGED_PROPERTY,
+                       old,
+                       b);
+    if (hasFocus())
+      {
+        revalidate();
+        repaint();
+      }
+  }
+
+  public boolean isFocusTraversable()
+  {
+    //Identifies whether or not this component can receive the focus.
+    return true;
+  }
+
+
+  protected  int checkHorizontalKey(int key, String exception)
+  {
+    //       Verify that key is a legal value for the horizontalAlignment properties.
+    return 0;
+  }
+
+  protected  int checkVerticalKey(int key, String exception)
+  {
+    //       Ensures that the key is a valid.
+    return 0;
+  }
+
+  protected  void configurePropertiesFromAction(Action a)
+  {
+    //Factory method which sets the ActionEvent source's properties according to values from the Action instance.
+  }
+
+  protected  ActionListener createActionListener()
+  {
+    return new ActionListener()
+      {
+        public void actionPerformed(ActionEvent e) { }
+      };
+  }
+
+  protected  PropertyChangeListener createActionPropertyChangeListener(Action a)
+  {
+    //Factory method which creates the PropertyChangeListener used to update the ActionEvent source as properties change on its Action instance.
+    return null;
+  }
+
+  protected  ChangeListener createChangeListener()
+  {
+    //       Subclasses that want to handle ChangeEvents differently can override this to return another ChangeListener implementation.
+    return new ChangeListener()
+      {
+        public void stateChanged(ChangeEvent e) { }
+      };
+  }
+
+  protected  ItemListener createItemListener()
+  {
+    return new ItemListener()
+      {
+        public void itemStateChanged(ItemEvent e) { }
+      };
+  }
+
+  public void doClick()
+  {
+    doClick(100);
+  }
+
+  public void doClick(int pressTime)
+  {
+    //Toolkit.tlkBeep ();
+    //Programmatically perform a "click".
+  }
+
+  public Icon getDisabledSelectedIcon()
+  {
+    //Returns the icon used by the button when it's disabled and selected.
+    return disabled_selected_button;
+  }
+
+  public Icon getRolloverIcon()
+  {
+    //       Returns the rollover icon for the button.
+    return null;
+  }
+
+  Icon getRolloverSelectedIcon()
+  {
+    //       Returns the rollover selection icon for the button.
+    return null;
+  }
+
+  Icon getSelectedIcon()
+  {
+    //       Returns the selected icon for the button.
+    return selected_button;
+  }
+
+  public Object[] getSelectedObjects()
+  {
+    //Returns an array (length 1) containing the label or null if the button is not selected.
+    return null;
+  }
+
+  public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
+  {
+    //This is overridden to return false if the current Icon's Image is not equal to the passed in Image img.
+    return current_icon == img;
+  }
+
+  public boolean isContentAreaFilled()
+  {
+    //       Checks whether the "content area" of the button should be filled.
+    return false;
+  }
+
+  protected  void paintBorder(Graphics g)
+  {
+    //       Paint the button's border if BorderPainted property is true.
+    if (isBorderPainted())
+      super.paintBorder(g);
+  }
+
+  protected  String paramString()
+  {
+    //        Returns a string representation of this AbstractButton.
+    return "AbstractButton";
+  }
+
+  public void setContentAreaFilled(boolean b)
+  {
+    //Sets whether the button should paint the content area or leave it transparent.
+  }
+
+  public void setDisabledSelectedIcon(Icon disabledSelectedIcon)
+  {
+    //          Sets the disabled selection icon for the button.
+  }
+
+  public void setRolloverIcon(Icon rolloverIcon)
+  {
+    //       Sets the rollover icon for the button.
+  }
+  public void setRolloverSelectedIcon(Icon rolloverSelectedIcon)
+  {
+    //       Sets the rollover selected icon for the button.
+  }
+
+  public void setSelectedIcon(Icon selectedIcon)
+  {
+    //       Sets the selected icon for the button.
+  }
+
+  public void setUI(ButtonUI ui)
+  {    //       Sets the L&F object that renders this component.
+    super.setUI(ui);
+  }
+
+  public ButtonUI getUI()
+  {
+    //Returns the L&F object that renders this component.
+    return (ButtonUI) ui;
+  }
+
+  public void updateUI()
+  {
+    /*
+    //          Notification from the UIFactory that the L&F has changed.
+    if (getUI() == null)
+    {
+    setUI(getUI());
+    }
+    */
+  }
+
+  protected void processActionEvent(ActionEvent e)
+  {
+    System.out.println("PROCESS-ACTION-EVENT: " + e);
+  }
+
+  protected void processMouseEvent(MouseEvent e)
+  {
+    // System.out.println("PROCESS-MOUSE-EVENT: " + e + ", PRESSED-IN-MODEL="+getModel().isPressed());
+
+    switch (e.getID())
+      {
+      case MouseEvent.MOUSE_MOVED:
+        {
+          break;
+        }
+      case MouseEvent.MOUSE_PRESSED:
+        {
+          if (! isEnabled())
+            {
+              System.out.println("button not enabled, ignoring press");
+            }
+          else
+            {
+              System.out.println("telling model:press: " + getModel());
+              getModel().setPressed(true);
+              repaint();
+            }
+          break;
+        }
+
+      case MouseEvent.MOUSE_RELEASED:
+        {
+          if (! isEnabled())
+            {
+              System.out.println("button not enabled, ignoring release");
+            }
+          else
+            {
+              int flags = 0;
+
+              System.out.println("        XXX--> " + getActionCommand());
+
+              fireActionPerformed(new ActionEvent(this,
+                                                  ActionEvent.ACTION_PERFORMED,
+                                                  getActionCommand(),
+                                                  flags));
+
+              //System.out.println("telling model:release");
+              getModel().setPressed(false);
+              repaint();
+            }
+          break;
+        }
+      case MouseEvent.MOUSE_CLICKED:
+        {
+          break;
+        }
+      }
+  }
 }
index 6d6aa7abbf2eaef7c82528ecaae7cc8f023aa7d8..ae0c721003b6f96eec36c91ba19f1f154215d6d9 100644 (file)
@@ -76,12 +76,4 @@ public interface ButtonModel extends ItemSelectable
 
     void setSelected(boolean b);
     boolean isSelected();
-
-
-    // there are not in the spec !!
-
-
-    void fireItemStateChanged(ItemEvent event);
-    void fireStateChanged(ChangeEvent event);    
-    void fireActionPerformed(ActionEvent event);
 }
index a123ad834385c94f1209fb79dc7cab25d671307e..a9113f0ff406b4e472096b0c5d9eb48aa798e033 100644 (file)
@@ -58,70 +58,71 @@ import javax.accessibility.AccessibleStateSet;
 public class SwingUtilities implements SwingConstants
 {
   public static FontMetrics getFontMetrics (Font font)
-{
-       return Toolkit.getDefaultToolkit().getFontMetrics(font);
-    }
+  {
+    return Toolkit.getDefaultToolkit ().getFontMetrics (font);
+  }
 
   public static JRootPane getRootPane (Component a)
-    {
-       if (a instanceof JRootPane)
-           return (JRootPane) a;
+  {
+    if (a instanceof JRootPane)
+      return (JRootPane) a;
        
-       a = a.getParent();
-
-       if (a != null)
-           {
-               return getRootPane(a);
-           }
+    a = a.getParent();
 
-       return null;
-    }
+    if (a != null)
+      {
+        return getRootPane(a);
+      }
+    
+    return null;
+  }
 
   public static void updateComponentTreeUI(JFrame comp)
-    {
-    }
+  {
+  }
 
   public static String layoutCompoundLabel(JComponent c, 
-                                            FontMetrics fm,
-                                            String text,
-                                            Icon i,
-                                            int vert_a, 
-                                            int hor_i, 
-                                            int vert_text_pos,
-                                            int hor_text_pos, 
-                                            Rectangle vr,
-                                            Rectangle ir, 
-                                            Rectangle tr,
-                                            int gap)
-    {
-       // view rect 'vr' already ok, 
-       // we need to compute ir (icon rect) and tr (text-rect)
+                                           FontMetrics fm,
+                                           String text,
+                                           Icon i,
+                                           int vert_a, 
+                                           int hor_i, 
+                                           int vert_text_pos,
+                                           int hor_text_pos, 
+                                           Rectangle vr,
+                                           Rectangle ir, 
+                                           Rectangle tr,
+                                           int gap)
+  {
+    // view rect 'vr' already ok, 
+    // we need to compute ir (icon rect) and tr (text-rect)
        
-       int next_x = 0;//vr.x;
-       int next_y = 0;//vr.y;
+    int next_x = 0;//vr.x;
+    int next_y = 0;//vr.y;
        
-       ir.height = ir.width = ir.y = ir.x = 0;
+    ir.height = ir.width = ir.y = ir.x = 0;
 
-       if (i != null)
-           {
-               ir.x = vr.x;
-               ir.y = vr.y;
-               ir.width = i.getIconWidth();
-               ir.height = i.getIconWidth();
+    if (i != null)
+      {
+        ir.x = vr.x;
+        ir.y = vr.y;
+        ir.width = i.getIconWidth();
+        ir.height = i.getIconWidth();
 
 
-               next_x += gap + i.getIconWidth();
-               next_y += gap + i.getIconHeight();
-           }
+        next_x += gap + i.getIconWidth();
+        next_y += gap + i.getIconHeight();
+      }
        
-       tr.x = next_x;
-       tr.y = vr.y + (vr.height/2);
+    tr.x = next_x;
+    tr.y = vr.y + (vr.height/2);
+
+    tr.width  = fm.stringWidth(text);
+    tr.height = fm.getHeight() +  fm.getAscent()/2;
 
-       tr.width  = fm.stringWidth(text);
-       tr.height = fm.getHeight() +  fm.getAscent()/2;
+    return text;
+  }
 
-       return text;
-    }
 }
 
 
index 556e8fffdf7c5273d775fd9cad5bf4662db9efd6..7defebd2b095b4fe9c6ab84f6dfe8ffb19f942d6 100644 (file)
@@ -50,131 +50,137 @@ import javax.swing.plaf.metal.MetalLookAndFeel;
 
 public class UIManager implements Serializable
 {
-  static final long serialVersionUID = -5547433830339189365L;
-
-    static class LookAndFeelInfo
-    {
-       String name, clazz;
+  public static class LookAndFeelInfo
+  {
+    String name, clazz;
        
-       LookAndFeelInfo(String name, 
-                       String clazz)
-       {
-           this.name  = name;
-           this.clazz = clazz;
-       }
-       String getName()      { return name;  }
-       String getClassName() { return clazz; }
+    LookAndFeelInfo(String name, 
+                    String clazz)
+    {
+      this.name  = name;
+      this.clazz = clazz;
     }
 
-    
-    static LookAndFeelInfo [] installed = {
-       new LookAndFeelInfo("Metal",
-                           "javax.swing.plaf.metal.MetalLookAndFeel")
-    };
+    String getName()      { return name;  }
+    String getClassName() { return clazz; }
+  }
 
+  private static final long serialVersionUID = -5547433830339189365L;
+
+  static LookAndFeelInfo [] installed = {
+    new LookAndFeelInfo ("Metal", "javax.swing.plaf.metal.MetalLookAndFeel")
+  };
+
+  static LookAndFeel[] aux_installed;
+  
+  static LookAndFeel look_and_feel = new MetalLookAndFeel();
     
-    static LookAndFeel[] aux_installed;
-    
-    static LookAndFeel look_and_feel  = new MetalLookAndFeel();
-    
+  public UIManager()
+  {
+    // Do nothing here.
+  }
 
-    UIManager()
-    {
-    }
+  public static void addPropertyChangeListener (PropertyChangeListener listener)
+  {
+    // FIXME
+  }
 
-    public static  void addPropertyChangeListener(PropertyChangeListener listener)
-    {
-       //      Add a PropertyChangeListener to the listener list. 
-    }
+  public static void removePropertyChangeListener (PropertyChangeListener listener)
+    // Remove a PropertyChangeListener from the listener list. 
+  {
+    // FIXME
+  }
 
-    public static  void addAuxiliaryLookAndFeel(LookAndFeel l)
-    {
-       //          Add a LookAndFeel to the list of auxiliary look and feels. 
-       if (aux_installed == null)
-           {
-               aux_installed = new LookAndFeel[1];
-               aux_installed[0] = l;
-               return;
-           }
+  /**
+   * @since 1.4
+   */
+  public static PropertyChangeListener[] getPropertyChangeListeners ()
+  {
+    // FIXME
+    throw new Error ("Not implemented");
+  }
+
+  public static void addAuxiliaryLookAndFeel (LookAndFeel l)
+  {
+    // Add a LookAndFeel to the list of auxiliary look and feels. 
+    if (aux_installed == null)
+      {
+        aux_installed = new LookAndFeel[1];
+        aux_installed[0] = l;
+        return;
+      }
        
-       LookAndFeel[] T = new LookAndFeel[ aux_installed.length+1 ];
-       System.arraycopy(aux_installed, 0,
-                        T,             0,
-                        aux_installed.length);                  
-       aux_installed = T;
-       aux_installed[aux_installed.length-1] = l;
-    }
+    LookAndFeel[] T = new LookAndFeel[ aux_installed.length+1 ];
+    System.arraycopy(aux_installed, 0, T, 0, aux_installed.length);                     
+    aux_installed = T;
+    aux_installed[aux_installed.length-1] = l;
+  }
     
-    public static  boolean removeAuxiliaryLookAndFeel(LookAndFeel laf)
-    {
-       if (aux_installed == null)
-           return false;
-
-       for (int i=0;i<aux_installed.length;i++)
-           {
-               if (aux_installed[i] == laf)
-                   {
-                       aux_installed[ i ] = aux_installed[aux_installed.length-1];
-                       
-                       LookAndFeel[] T = new LookAndFeel[ aux_installed.length-1 ];
-                       System.arraycopy(aux_installed, 0,
-                                        T,             0,
-                                        aux_installed.length-1);                        
-                       aux_installed = T;
-                       return true;
-                   }           
-           }
-       return false;
-    }
-
-    public static  LookAndFeel[] getAuxiliaryLookAndFeels()
-    {  return aux_installed;    }
+  public static boolean removeAuxiliaryLookAndFeel(LookAndFeel laf)
+  {
+    if (aux_installed == null)
+      return false;
+
+    for (int i=0;i<aux_installed.length;i++)
+      {
+        if (aux_installed[i] == laf)
+          {
+            aux_installed[ i ] = aux_installed[aux_installed.length-1];
+            LookAndFeel[] T = new LookAndFeel[ aux_installed.length-1 ];
+            System.arraycopy (aux_installed, 0, T, 0, aux_installed.length-1);
+            aux_installed = T;
+            return true;
+          }            
+      }
+    return false;
+  }
 
+  public static  LookAndFeel[] getAuxiliaryLookAndFeels()
+  {    return aux_installed;    }
 
-    public static  Object get(Object key)
-    {  return getLookAndFeel().getDefaults().get(key);    }
+  public static  Object get(Object key)
+  {    return getLookAndFeel().getDefaults().get(key);    }
     
-    /**
-     * Returns a border from the defaults table. 
-     */
-    public static  Border getBorder(Object key)
-    {
-       return (Border) getLookAndFeel().getDefaults().get(key);
-    }
+  /**
+   * Returns a border from the defaults table. 
+   */
+  public static Border getBorder(Object key)
+  {
+    return (Border) getLookAndFeel().getDefaults().get(key);
+  }
     
-    /**
-     * Returns a drawing color from the defaults table. 
-     */
-    public static  Color getColor(Object key)
-    {
-       return (Color) getLookAndFeel().getDefaults().get(key);
-    }
-
-    /**
-     * this string can be passed to Class.forName()
-     */
-    public static  String getCrossPlatformLookAndFeelClassName()
-    {  
-       return "javax.swing.plaf.metal.MetalLookAndFeel";
-    }
+  /**
+   * Returns a drawing color from the defaults table. 
+   */
+  public static  Color getColor(Object key)
+  {
+    return (Color) getLookAndFeel().getDefaults().get(key);
+  }
 
-    /**
-     * Returns the default values for this look and feel. 
-     */
-    static  UIDefaults getDefaults()
-    {
-       return getLookAndFeel().getDefaults();
-    }
+  /**
+   * this string can be passed to Class.forName()
+   */
+  public static  String getCrossPlatformLookAndFeelClassName()
+  {    
+    return "javax.swing.plaf.metal.MetalLookAndFeel";
+  }
 
-    /**
-     * Returns a dimension from the defaults table. 
-     */
-    static  Dimension getDimension(Object key)
-    {
-       System.out.println("UIManager.getDim");
-       return new Dimension(200,100);
-    }
+  /**
+   * Returns the default values for this look and feel. 
+   */
+  static  UIDefaults getDefaults()
+  {
+    return getLookAndFeel().getDefaults();
+  }
 
+  /**
+   * Returns a dimension from the defaults table. 
+   */
+  static  Dimension getDimension(Object key)
+  {
+    System.out.println("UIManager.getDim");
+    return new Dimension(200,100);
+  }
 
   /**
    * Retrieves a font from the defaults table of the current
@@ -189,34 +195,35 @@ public class UIManager implements Serializable
     return (Font) getLookAndFeel().getDefaults().get(key);
   }
 
-    static  Icon getIcon(Object key)
-    //      Returns an Icon from the defaults table. 
-    {
-       return (Icon) getLookAndFeel().getDefaults().get(key);
-    }
-    static  Insets getInsets(Object key)
-    //      Returns an Insets object from the defaults table. 
-    {
-       return (Insets) getLookAndFeel().getDefaults().getInsets(key);
-    }
+  static Icon getIcon(Object key)
+    // Returns an Icon from the defaults table. 
+  {
+    return (Icon) getLookAndFeel().getDefaults().get(key);
+  }
+  
+  static Insets getInsets(Object key)
+    // Returns an Insets object from the defaults table. 
+  {
+    return (Insets) getLookAndFeel().getDefaults().getInsets(key);
+  }
 
-    static LookAndFeelInfo[] getInstalledLookAndFeels()
-    {
-       return installed;
-    }
+  static LookAndFeelInfo[] getInstalledLookAndFeels()
+  {
+    return installed;
+  }
 
-    static  int getInt(Object key)
-    {
-       Integer x = (Integer) getLookAndFeel().getDefaults().get(key);
-       if (x == null)
-           return 0;
-       return x.intValue();
-    }
-    static  LookAndFeel getLookAndFeel()
-    {
-       return look_and_feel;
-    }
+  static  int getInt(Object key)
+  {
+    Integer x = (Integer) getLookAndFeel().getDefaults().get(key);
+    if (x == null)
+      return 0;
+    return x.intValue();
+  }
 
+  static  LookAndFeel getLookAndFeel()
+  {
+    return look_and_feel;
+  }
 
   /**
    * Returns the <code>UIDefaults</code> table of the currently active
@@ -227,73 +234,67 @@ public class UIManager implements Serializable
     return getLookAndFeel().getDefaults();
   }
 
+  static String getString(Object key)
+    // Returns a string from the defaults table. 
+  {
+    return (String) getLookAndFeel().getDefaults().get(key);
+  }
+  
+  static String getSystemLookAndFeelClassName()
+    // Returns the name of the LookAndFeel class that implements the native systems look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class. 
+  {
+    return getCrossPlatformLookAndFeelClassName();
+  }
 
-    static  String getString(Object key)
-    //      Returns a string from the defaults table. 
-    {
-       return (String) getLookAndFeel().getDefaults().get(key);
-    }
-    static  String getSystemLookAndFeelClassName()
-    //      Returns the name of the LookAndFeel class that implements the native systems look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class. 
-    {
-       return getCrossPlatformLookAndFeelClassName();
-    }
+  public static ComponentUI getUI(JComponent target)
+    // Returns the L&F object that renders the target component. 
+  {
+    ComponentUI ui = getDefaults().getUI(target);
+    //System.out.println("GET-UI-> " + ui + ", for " + target);
+    return ui;
+  }
 
+  public static void installLookAndFeel(String name, String className)
+    // Creates a new look and feel and adds it to the current array. 
+  {
+  }
 
-    public static  ComponentUI getUI(JComponent target)
-    //      Returns the L&F object that renders the target component. 
-    {
-       ComponentUI ui = getDefaults().getUI(target);
-       //System.out.println("GET-UI-> " + ui + ", for " + target);
-       return ui;
-    }
+  public static void installLookAndFeel(LookAndFeelInfo info)
+    // Adds the specified look and feel to the current array and then calls setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[]). 
+  {
+  }
 
+  public static Object put(Object key, Object value)
+    // Stores an object in the defaults table. 
+  {
+    return getLookAndFeel().getDefaults().put(key,value);
+  }
 
-    public static  void installLookAndFeel(String name, String className)
-    //      Creates a new look and feel and adds it to the current array. 
-    {
-    }
-    public static  void installLookAndFeel(LookAndFeelInfo info)
-    //      Adds the specified look and feel to the current array and then calls setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[]). 
-    {
-    }
-    public static  Object put(Object key, Object value)
-    //      Stores an object in the defaults table. 
-    {
-       return getLookAndFeel().getDefaults().put(key,value);
-    }
-    public static  void removePropertyChangeListener(PropertyChangeListener listener)
-    //      Remove a PropertyChangeListener from the listener list. 
-    {
-    }
-    public static  void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos)
-    //      Replaces the current array of installed LookAndFeelInfos. 
-    {
-    }
-    public static  void setLookAndFeel(LookAndFeel newLookAndFeel)
-    {
-       if (look_and_feel != null)
-           look_and_feel.uninitialize();
+  public static void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos)
+    // Replaces the current array of installed LookAndFeelInfos. 
+  {
+  }
+  
+  public static void setLookAndFeel(LookAndFeel newLookAndFeel)
+  {
+    if (look_and_feel != null)
+      look_and_feel.uninitialize();
 
-       //      Set the current default look and feel using a LookAndFeel object. 
-       look_and_feel = newLookAndFeel;
-       look_and_feel.initialize();
+    // Set the current default look and feel using a LookAndFeel object. 
+    look_and_feel = newLookAndFeel;
+    look_and_feel.initialize();
        
-       //      revalidate();
-       //      repaint();
-    }
-
-    public static  void setLookAndFeel(String className)
-        throws ClassNotFoundException, 
-               InstantiationException, 
-               IllegalAccessException,
-              UnsupportedLookAndFeelException
-    {
-       //          Set the current default look and feel using a class name.
-       Class c = Class.forName(className);
-       LookAndFeel a = (LookAndFeel) c.newInstance(); // throws class-cast-exception
-       setLookAndFeel(a);
-    }
-
+    //revalidate();
+    //repaint();
+  }
 
+  public static void setLookAndFeel (String className)
+    throws ClassNotFoundException, InstantiationException, IllegalAccessException,
+    UnsupportedLookAndFeelException
+  {
+    //          Set the current default look and feel using a class name.
+    Class c = Class.forName(className);
+    LookAndFeel a = (LookAndFeel) c.newInstance(); // throws class-cast-exception
+    setLookAndFeel(a);
+  }
 }
index 1aa51fd64c09f1aad3d62440d2868e6f46390b1c..43df7edffb9f23c11a90de409ed11d0d30eb0c1a 100644 (file)
@@ -52,90 +52,90 @@ import javax.swing.event.EventListenerList;
 public class DefaultColorSelectionModel 
   implements ColorSelectionModel, Serializable
 {
-  static final long serialVersionUID = 580150227676302096L;
-
-       //-------------------------------------------------------------
-       // Variables --------------------------------------------------
-       //-------------------------------------------------------------
-
-       /**
-        * changeEvent
-        */
-       protected transient ChangeEvent changeEvent;
-
-       /**
-        * listenerList
-        */
-       protected EventListenerList listenerList;
-
-       /**
-        * selectedColor
-        */
-       private Color selectedColor;
-
-
-       //-------------------------------------------------------------
-       // Initialization ---------------------------------------------
-       //-------------------------------------------------------------
-
-       /**
-        * Constructor DefaultColorSelectionModel
-        */
-       public DefaultColorSelectionModel() {
-               // TODO
-       } // DefaultColorSelectionModel()
-
-       /**
-        * Constructor DefaultColorSelectionModel
-        * @param color TODO
-        */
-       public DefaultColorSelectionModel(Color color) {
-               // TODO
-       } // DefaultColorSelectionModel()
-
-
-       //-------------------------------------------------------------
-       // Methods ----------------------------------------------------
-       //-------------------------------------------------------------
-
-       /**
-        * getSelectedColor
-        * @returns Color
-        */
-       public Color getSelectedColor() {
-               return null; // TODO
-       } // getSelectedColor()
-
-       /**
-        * setSelectedColor
-        * @param color TODO
-        */
-       public void setSelectedColor(Color color) {
-               // TODO
-       } // setSelectedColor()
-
-       /**
-        * addChangeListener
-        * @param listener TODO
-        */
-       public void addChangeListener(ChangeListener listener) {
-               // TODO
-       } // addChangeListener()
-
-       /**
-        * removeChangeListener
-        * @param listener TODO
-        */
-       public void removeChangeListener(ChangeListener listener) {
-               // TODO
-       } // removeChangeListener()
-
-       /**
-        * fireStateChanged
-        */
-       protected void fireStateChanged() {
-               // TODO
-       } // fireStateChanged()
-
-
-} // DefaultColorSelectionModel
+  private static final long serialVersionUID = -8117143602864778804L;
+
+  private Color selectedColor;
+
+  protected transient ChangeEvent changeEvent = new ChangeEvent (this);
+  protected EventListenerList listenerList = new EventListenerList ();
+
+  /**
+   * Creates a new color selection model.
+   */
+  public DefaultColorSelectionModel()
+  {
+    this (Color.white);
+  }
+
+  /**
+   * Creates a new color selection model with a given selected color.
+   * 
+   * @param color The selected color.
+   */
+  public DefaultColorSelectionModel (Color color)
+  {
+    super();
+    this.selectedColor = color;
+  }
+
+  /**
+   * Returns the selected color.
+   * 
+   * @return The selected color.
+   */
+  public Color getSelectedColor()
+  {
+    return selectedColor;
+  }
+
+  /**
+   * @param color The color to set.
+   */
+  public void setSelectedColor (Color color)
+  {
+    this.selectedColor = color;
+  }
+
+  /**
+   * Adds a listener to this model.
+   * 
+   * @param listener The listener to add.
+   */
+  public void addChangeListener (ChangeListener listener)
+  {
+    listenerList.add (ChangeListener.class, listener);
+  }
+
+  /**
+   * Removes a listener from this model.
+   * 
+   * @param listener The listener to remove.
+   */
+  public void removeChangeListener (ChangeListener listener)
+  {
+    listenerList.remove (ChangeListener.class, listener);
+  }
+
+  /**
+   * Returns all currently added <code>ChangeListener</code> objects.
+   *
+   * @return Array of <code>ChangeListener</code> objects.
+   */
+  public ChangeListener[] getChangeListeners()
+  {
+    return (ChangeListener[]) listenerList.getListeners (ChangeListener.class);
+  }
+
+  /**
+   * Calls all the <code>stateChanged()</code> method of all added
+   * <code>ChangeListener</code> objects with <code>changeEvent</code>
+   * as argument.
+   */
+  protected void fireStateChanged()
+  {
+    ChangeListener[] listeners = getChangeListeners();
+
+    for (int i = 0; i < listeners.length; i++)
+      listeners [i].stateChanged (changeEvent);
+  }
+}
index c6173932bb98b2c5208960445eeebd07c6f4cd36..d62be28ba2913fbca454bad12986ab5991c1c466 100644 (file)
@@ -50,9 +50,9 @@ public class AncestorEvent extends AWTEvent
 {
   private static final long serialVersionUID = -8079801679695605002L;
   
-  public static final int ANCESTOR_ADDED = 0;
-  public static final int ANCESTOR_MOVED = 1;
+  public static final int ANCESTOR_ADDED = 1;
   public static final int ANCESTOR_REMOVED = 2;
+  public static final int ANCESTOR_MOVED = 3;
 
   private JComponent sourceComponent;
   private Container ancestor;
index 15d12f2efcf675892ec08343a5348750fb46ce71..863fd292f88707462d55e4371496ef1773e02c8d 100644 (file)
@@ -81,7 +81,7 @@ public class InternalFrameEvent extends AWTEvent
   /**
    * Internal frame iconified event
    */
-  public static final int INTERNAL_FRAME_ICONIFIED = 2552;
+  public static final int INTERNAL_FRAME_ICONIFIED = 25552;
 
   /**
    * Internal frame last event
@@ -91,7 +91,7 @@ public class InternalFrameEvent extends AWTEvent
   /**
    * Internal frame opened event
    */
-  public static final int INTERNAL_FRAME_OPENED = 25550;
+  public static final int INTERNAL_FRAME_OPENED = 25549;
 
   /**
    * Creates a <code>JInternalFrameEvent</code> object.