harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r509503 - in /harmony/enhanced/classlib/trunk/modules: awt/ awt/src/main/java/common/java/awt/ awt/src/test/api/java/common/org/apache/harmony/awt/ swing/src/main/java/common/javax/swing/
Date Tue, 20 Feb 2007 10:42:03 GMT
Author: apetrenko
Date: Tue Feb 20 02:42:02 2007
New Revision: 509503

URL: http://svn.apache.org/viewvc?view=rev&rev=509503
Log:
Patch for HARMONY-3168 "[classlib][awt] Headless mode implementation (without font rendering)"

Added:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java   (with props)
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessGraphicsEnvironment.java   (with props)
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessToolkit.java   (with props)
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/HeadlessTest.java   (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/awt/build.xml
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Canvas.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventDispatchThread.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventQueueCore.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Panel.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/SystemColor.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ToolkitImpl.java
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/RepaintManager.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/build.xml?view=diff&rev=509503&r1=509502&r2=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/build.xml (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/build.xml Tue Feb 20 02:42:02 2007
@@ -322,15 +322,54 @@
                 <fileset dir="${hy.awt.src.test.api}/java/common">
                     <include name="**/*Test.java"/>
                     <excludesfile name="${awt.exclude.file}" />
+                    <exclude name="**/*Headless*Test.java"/>
                 </fileset>
                 <fileset dir="${hy.awt.src.test.api.java.platform}">
                     <include name="**/*Test*.java"/>
                     <excludesfile name="${awt.exclude.file}" />
+                    <exclude name="**/*Headless*Test*.java"/>
                 </fileset>
             </batchtest>  
         </junit>
+
+        <junit fork="yes"
+               forkmode="${hy.test.forkmode}"
+               timeout="${hy.test.timeout}"
+               printsummary="withOutAndErr"
+               errorproperty="test.errors"
+               failureproperty="test.failures"
+               showoutput="on"
+               dir="${basedir}"
+               jvm="${test.jre.home}/bin/java">
+
+            <jvmarg line="${hy.test.vmargs}" />
+
+            <jvmarg value="-DTEST_SRC_DIR=${hy.awt.bin.test}"/>
+            <jvmarg value="-Djava.awt.headless=true"/>
+            <jvmarg value="-Xbootclasspath/a:${hy.awt.bin.test}${path.separator}${basedir}/../../${junit.jar}"/>
+
+            <formatter type="xml" />
+
+            <test name="${test.case}" todir="${hy.tests.reports}"
+                 if="test.case" />
+
+            <batchtest todir="${hy.tests.reports}" haltonfailure="no"
+                unless="test.case">
+
+                <fileset dir="${hy.awt.src.test.api}/java/common">
+                    <include name="**/*Headless*Test.java"/>
+                    <excludesfile name="${awt.exclude.file}" />
+                </fileset>
+                <fileset dir="${hy.awt.src.test.api.java.platform}">
+                    <include name="**/*Headless*Test*.java"/>
+                    <excludesfile name="${awt.exclude.file}" />
+                </fileset>
+            </batchtest>  
+        </junit>
+
         <antcall target="touch-failures-file" />
         <antcall target="touch-errors-file" />
+
     </target>
 
     <target name="touch-failures-file" if="test.failures">

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Canvas.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Canvas.java?view=diff&rev=509503&r1=509502&r2=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Canvas.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Canvas.java Tue Feb 20 02:42:02 2007
@@ -126,8 +126,10 @@
     }
 
     @Override
-    ComponentBehavior createBehavior() {
-        return new HWBehavior(this);
+    ComponentBehavior createBehavior() {        
+        return GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance() ? 
+                new LWBehavior(this) : 
+                new HWBehavior(this) ;
     }
 
     @Override

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java?view=diff&rev=509503&r1=509502&r2=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Component.java Tue Feb 20 02:42:02 2007
@@ -69,12 +69,14 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleComponent;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
 import javax.accessibility.AccessibleState;
 import javax.accessibility.AccessibleStateSet;
+
 import org.apache.harmony.awt.ClipRegion;
 import org.apache.harmony.awt.FieldsAccessor;
 import org.apache.harmony.awt.gl.MultiRectArea;
@@ -4050,7 +4052,6 @@
     }
 
     public Point getMousePosition() throws HeadlessException {
-        Toolkit.checkHeadless();
         Point absPointerPos = MouseInfo.getPointerInfo().getLocation();
         Window winUnderPtr = toolkit.dispatcher.mouseDispatcher.findWindowAt(absPointerPos);
         Point pointerPos = MouseDispatcher.convertPoint(null, absPointerPos, winUnderPtr);

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventDispatchThread.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventDispatchThread.java?view=diff&rev=509503&r1=509502&r2=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventDispatchThread.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventDispatchThread.java Tue Feb 20 02:42:02 2007
@@ -23,7 +23,7 @@
 import org.apache.harmony.awt.wtk.NativeEvent;
 import org.apache.harmony.awt.wtk.NativeEventQueue;
 
-final class EventDispatchThread extends Thread  {
+class EventDispatchThread extends Thread  {
     
     private static final class MarkerEvent extends AWTEvent {
         MarkerEvent(Object source, int id) {
@@ -35,7 +35,7 @@
     final Toolkit toolkit;
     private NativeEventQueue nativeQueue;
 
-    private volatile boolean shutdownPending = false;
+    protected volatile boolean shutdownPending = false;
 
     /**
      * Initialise and run the main event loop

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventQueueCore.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventQueueCore.java?view=diff&rev=509503&r1=509502&r2=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventQueueCore.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/EventQueueCore.java Tue Feb 20 02:42:02 2007
@@ -88,7 +88,9 @@
         // TODO: add event coalescing
         if (toolkit != null) {
             toolkit.shutdownWatchdog.setAwtQueueEmpty(false);
-            notifyEventMonitor(toolkit);
+            if (!GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
+                notifyEventMonitor(toolkit);
+            }
         }
         notifyAll();
     }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java?view=diff&rev=509503&r1=509502&r2=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GraphicsEnvironment.java Tue Feb 20 02:42:02 2007
@@ -24,8 +24,8 @@
 import java.awt.image.BufferedImage;
 import java.util.Locale;
 
-import org.apache.harmony.awt.*;
-import org.apache.harmony.awt.gl.*;
+import org.apache.harmony.awt.ContextStorage;
+import org.apache.harmony.awt.gl.CommonGraphics2DFactory;
 
 
 public abstract class GraphicsEnvironment {
@@ -34,11 +34,16 @@
     public static GraphicsEnvironment getLocalGraphicsEnvironment() {
         synchronized(ContextStorage.getContextLock()) {
             if (ContextStorage.getGraphicsEnvironment() == null) {
-                CommonGraphics2DFactory g2df =
-                        (CommonGraphics2DFactory) Toolkit.getDefaultToolkit().getGraphicsFactory();
-                ContextStorage.setGraphicsEnvironment(
-                        g2df.createGraphicsEnvironment(ContextStorage.getWindowFactory())
-                );
+                if (isHeadless()) {                    
+                    ContextStorage.setGraphicsEnvironment(new HeadlessGraphicsEnvironment());                    
+                } else {
+                    CommonGraphics2DFactory g2df =
+                            (CommonGraphics2DFactory) Toolkit.getDefaultToolkit().getGraphicsFactory();
+                    
+                    ContextStorage.setGraphicsEnvironment( 
+                            g2df.createGraphicsEnvironment(ContextStorage.getWindowFactory())
+                    );
+                }
             }
 
             return ContextStorage.getGraphicsEnvironment();
@@ -46,18 +51,11 @@
     }
 
     public boolean isHeadlessInstance() {
-        // At present headless mode not supported, HeadlessException will never be thrown
-        try {
-            getDefaultScreenDevice();
-        } catch (HeadlessException e) {
-            return true;
-        }
-
         return false;
     }
 
     public static boolean isHeadless() {
-        return getLocalGraphicsEnvironment().isHeadlessInstance();
+        return "true".equals(System.getProperty("java.awt.headless"));
     }
 
     public Rectangle getMaximumWindowBounds() throws HeadlessException {

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java?view=auto&rev=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java Tue Feb 20 02:42:02 2007
@@ -0,0 +1,63 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package java.awt;
+
+final class HeadlessEventDispatchThread extends EventDispatchThread  {
+
+    HeadlessEventDispatchThread(Toolkit toolkit, Dispatcher dispatcher ) {
+        super(toolkit, dispatcher);
+    }
+
+    /**
+     * Initialise and run the main event loop
+     */
+    @Override
+    public void run() {
+        try {
+            runModalLoop(null);
+        } finally {
+            toolkit.shutdownWatchdog.forceShutdown();
+        }
+    }
+    
+    void runModalLoop(ModalContext context) {
+        long lastPaintTime = System.currentTimeMillis();
+        while (!shutdownPending && (context == null || context.isModalLoopRunning())) {
+            try {
+                EventQueue eventQueue = toolkit.getSystemEventQueueImpl();
+    
+                toolkit.shutdownWatchdog.setNativeQueueEmpty(true);
+                AWTEvent ae = eventQueue.getNextEventNoWait();
+                if (ae != null) {
+                    eventQueue.dispatchEvent(ae);
+                    long curTime = System.currentTimeMillis();
+                    if (curTime - lastPaintTime > 10) {
+                        toolkit.onQueueEmpty();
+                        lastPaintTime = System.currentTimeMillis();
+                    }
+                } else {
+                    toolkit.shutdownWatchdog.setAwtQueueEmpty(true);
+                    toolkit.onQueueEmpty();
+                    lastPaintTime = System.currentTimeMillis();
+                }
+            } catch (Throwable t) {
+                t.printStackTrace();
+            }
+        }
+    }   
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessEventDispatchThread.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessGraphicsEnvironment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessGraphicsEnvironment.java?view=auto&rev=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessGraphicsEnvironment.java (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessGraphicsEnvironment.java Tue Feb 20 02:42:02 2007
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package java.awt;
+
+import java.awt.GraphicsDevice;
+import java.awt.HeadlessException;
+
+import org.apache.harmony.awt.gl.CommonGraphicsEnvironment;
+
+public class HeadlessGraphicsEnvironment extends CommonGraphicsEnvironment {
+    
+    @Override
+    public boolean isHeadlessInstance() {
+        return true;
+    }
+    
+    @Override
+    public GraphicsDevice getDefaultScreenDevice() throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    public GraphicsDevice[] getScreenDevices() throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessGraphicsEnvironment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessToolkit.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessToolkit.java?view=auto&rev=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessToolkit.java (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessToolkit.java Tue Feb 20 02:42:02 2007
@@ -0,0 +1,286 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package java.awt;
+
+import java.awt.datatransfer.Clipboard;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.im.InputMethodHighlight;
+import java.awt.image.ColorModel;
+import java.awt.peer.*;
+import java.beans.PropertyChangeSupport;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.harmony.awt.ComponentInternals;
+import org.apache.harmony.awt.datatransfer.DTK;
+import org.apache.harmony.awt.wtk.GraphicsFactory;
+import org.apache.harmony.awt.wtk.NativeEventQueue;
+import org.apache.harmony.awt.wtk.WindowFactory;
+
+public final class HeadlessToolkit extends ToolkitImpl {
+    
+    @Override
+    protected ButtonPeer createButton(Button a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    protected CheckboxPeer createCheckbox(Checkbox a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    protected ChoicePeer createChoice(Choice a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    public Cursor createCustomCursor(Image img, Point hotSpot, String name)
+    throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected DialogPeer createDialog(Dialog a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    public <T extends DragGestureRecognizer> T createDragGestureRecognizer(
+            Class<T> recognizerAbstractClass, DragSource ds, Component c, int srcActions,
+            DragGestureListener dgl) {
+        return null;
+    }
+
+    @Override
+    public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge)
+    throws InvalidDnDOperationException {
+        throw new InvalidDnDOperationException();
+    }
+
+    @Override
+    protected FileDialogPeer createFileDialog(FileDialog a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected FramePeer createFrame(Frame a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected LabelPeer createLabel(Label a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected ListPeer createList(List a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected MenuPeer createMenu(Menu a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected MenuBarPeer createMenuBar(MenuBar a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected MenuItemPeer createMenuItem(MenuItem a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected PopupMenuPeer createPopupMenu(PopupMenu a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected ScrollbarPeer createScrollbar(Scrollbar a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected ScrollPanePeer createScrollPane(ScrollPane a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected TextAreaPeer createTextArea(TextArea a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected TextFieldPeer createTextField(TextField a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    protected WindowPeer createWindow(Window a0) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    public Dimension getBestCursorSize(int prefWidth, int prefHeight) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    public ColorModel getColorModel() throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    GraphicsFactory getGraphicsFactory() throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    public boolean getLockingKeyState(int keyCode) throws UnsupportedOperationException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    public int getMaximumCursorColors() throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    public int getMenuShortcutKeyMask() throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    NativeEventQueue getNativeEventQueue() throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    public PrintJob getPrintJob(Frame frame, String jobtitle, JobAttributes jobAttributes, 
+            PageAttributes pageAttributes) throws IllegalArgumentException {
+        throw new IllegalArgumentException();        
+    }
+    
+    @Override
+    public PrintJob getPrintJob(Frame frame, String jobtitle, Properties props) throws NullPointerException  {
+        throw new NullPointerException();
+    }
+    
+    @Override
+    public Insets getScreenInsets(GraphicsConfiguration gc) throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    public int getScreenResolution() throws HeadlessException {
+        throw new HeadlessException();
+    }    
+    
+    @Override
+    public Dimension getScreenSize() throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    public Clipboard getSystemClipboard() throws HeadlessException {
+        throw new HeadlessException();
+    }    
+    
+    @Override
+    public Clipboard getSystemSelection() throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    WindowFactory getWindowFactory() throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    protected void init() {
+        lockAWT();
+        try {
+            ComponentInternals.setComponentInternals(new ComponentInternalsImpl());
+            new EventQueue(this); // create the system EventQueue
+            dispatcher = new Dispatcher(this);
+            desktopProperties = new HashMap<String, Object>();
+            desktopPropsSupport = new PropertyChangeSupport(this);
+            awtEventsManager = new AWTEventsManager();
+            dispatchThread = new HeadlessEventDispatchThread(this, dispatcher);            
+            dtk = DTK.getDTK();
+            dispatchThread.start();            
+        } finally {
+            unlockAWT();
+        }
+    }
+    
+    @Override
+    public boolean isDynamicLayoutActive() throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    protected boolean isDynamicLayoutSet() throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    public boolean isFrameStateSupported(int state) throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    protected void loadSystemColors(int[] systemColors) throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    public Map<java.awt.font.TextAttribute, ?> mapInputMethodHighlight(
+            InputMethodHighlight highlight) throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    Map<java.awt.font.TextAttribute, ?> mapInputMethodHighlightImpl(
+            InputMethodHighlight highlight) throws HeadlessException {
+        throw new HeadlessException();
+    }
+
+    @Override
+    public void setDynamicLayout(boolean dynamic) throws HeadlessException {
+        throw new HeadlessException();
+    }
+    
+    @Override
+    public void setLockingKeyState(int keyCode, boolean on) throws UnsupportedOperationException {
+        throw new HeadlessException();
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/HeadlessToolkit.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Panel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Panel.java?view=diff&rev=509503&r1=509502&r2=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Panel.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Panel.java Tue Feb 20 02:42:02 2007
@@ -88,8 +88,10 @@
     }
 
     @Override
-    ComponentBehavior createBehavior() {
-        return new HWBehavior(this);
+    ComponentBehavior createBehavior() {        
+        return GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance() ? 
+                new LWBehavior(this) : 
+                new HWBehavior(this) ;
     }
 
     @Override

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/SystemColor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/SystemColor.java?view=diff&rev=509503&r1=509502&r2=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/SystemColor.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/SystemColor.java Tue Feb 20 02:42:02 2007
@@ -141,6 +141,88 @@
     public static final SystemColor infoText = new SystemColor(INFO_TEXT);
 
     private final transient Toolkit toolkit = Toolkit.getDefaultToolkit();
+    
+    private int getHeadlessSystemColorARGB(int index) {
+        switch(index) {
+        // Grey-blue
+        case SystemColor.ACTIVE_CAPTION:
+            return 0xff336699;
+        case SystemColor.ACTIVE_CAPTION_BORDER:
+            return 0xffcccccc;
+        case SystemColor.ACTIVE_CAPTION_TEXT:
+            return 0xffffffff;
+        // Light grey
+        case SystemColor.CONTROL:
+            return 0xffdddddd;
+        // Dark grey
+        case SystemColor.CONTROL_DK_SHADOW:
+            return 0xff777777;
+        // Almost white
+        case SystemColor.CONTROL_HIGHLIGHT:
+            return 0xffeeeeee;
+        // White
+        case SystemColor.CONTROL_LT_HIGHLIGHT:
+            return 0xffffffff;
+        // Grey
+        case SystemColor.CONTROL_SHADOW:
+            return 0xff999999;
+        // Black
+        case SystemColor.CONTROL_TEXT:
+            return 0xff000000;
+        // Dark blue
+        case SystemColor.DESKTOP:
+            return 0xff224466;
+        // Another grey
+        case SystemColor.INACTIVE_CAPTION:
+            return 0xff888888;
+        // Grey
+        case SystemColor.INACTIVE_CAPTION_BORDER:
+            return 0xffcccccc;
+        // Light grey
+        case SystemColor.INACTIVE_CAPTION_TEXT:
+            return 0xffdddddd;
+        // Almost white
+        case SystemColor.INFO:
+            return 0xffeeeeee;
+        case SystemColor.INFO_TEXT:
+            return 0xff222222;
+        // Light grey
+        case SystemColor.MENU:
+            return 0xffdddddd;
+        // Black
+        case SystemColor.MENU_TEXT:
+            return 0xff000000;
+        // Grey
+        case SystemColor.SCROLLBAR:
+            return 0xffcccccc;
+        // White
+        case SystemColor.TEXT:
+            return 0xffffffff;
+        // Grey blue
+        case SystemColor.TEXT_HIGHLIGHT:
+            return 0xff336699;
+        // White
+        case SystemColor.TEXT_HIGHLIGHT_TEXT:
+            return 0xffffffff;
+        // Almost white
+        case SystemColor.TEXT_INACTIVE_TEXT:
+            return 0xffdddddd;
+        // Black
+        case SystemColor.TEXT_TEXT:
+            return 0xff000000;
+        // White
+        case SystemColor.WINDOW:
+            return 0xffffffff;
+        // Black
+        case SystemColor.WINDOW_BORDER:
+            return 0xff000000;
+        // Black
+        case SystemColor.WINDOW_TEXT:
+            return 0xff000000;
+        }
+        // Black
+        return 0xFF000000;
+    }
 
     private final int index;
     @Override
@@ -159,8 +241,10 @@
         value = getRGB();
     }
 
-    private int getARGB() {
-        return toolkit.getWTK().getSystemProperties().getSystemColorARGB(index);
+    private int getARGB() {        
+        return GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance() ?
+                getHeadlessSystemColorARGB(index) : 
+                toolkit.getWTK().getSystemProperties().getSystemColorARGB(index);
     }
 
     @Override

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java?view=diff&rev=509503&r1=509502&r2=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Toolkit.java Tue Feb 20 02:42:02 2007
@@ -71,6 +71,7 @@
 import java.util.MissingResourceException;
 import java.util.Properties;
 import java.util.ResourceBundle;
+
 import org.apache.harmony.awt.ChoiceStyle;
 import org.apache.harmony.awt.ComponentInternals;
 import org.apache.harmony.awt.ContextStorage;
@@ -100,15 +101,15 @@
 
     private static final ResourceBundle properties = loadResources(RECOURCE_PATH);
 
-    final Dispatcher dispatcher;
+    Dispatcher dispatcher;
 
     private EventQueueCore systemEventQueueCore;
 
-    final EventDispatchThread dispatchThread;
+    EventDispatchThread dispatchThread;
 
     NativeEventThread nativeThread;
 
-    private final AWTEventsManager awtEventsManager;
+    protected AWTEventsManager awtEventsManager;
 
     /* key = nativeWindow, value = Component, should be Map<NativeWindow, Component> */
     private final Map<NativeWindow, Object> windowComponentMap = new HashMap<NativeWindow, Object>();
@@ -150,9 +151,9 @@
      */
     private final HashSet<String> userPropSet = new HashSet<String>();
 
-    protected final Map<String, Object> desktopProperties;
+    protected Map<String, Object> desktopProperties;
 
-    protected final PropertyChangeSupport desktopPropsSupport;
+    protected PropertyChangeSupport desktopPropsSupport;
 
     /**
      * For this component the native window is being created
@@ -167,9 +168,9 @@
 
     private WTK wtk;
 
-    final DTK dtk;
+    DTK dtk;
 
-    private final class ComponentInternalsImpl extends ComponentInternals {
+    protected final class ComponentInternalsImpl extends ComponentInternals {
         @Override
         public NativeWindow getNativeWindow(Component component) {
             lockAWT();
@@ -382,9 +383,8 @@
      * if <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>.
      */
     static void checkHeadless() throws HeadlessException {
-        if (GraphicsEnvironment.isHeadless()) {
+        if (GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance())
             throw new HeadlessException();
-        }
     }
 
     final void lockAWT() {
@@ -401,7 +401,7 @@
 
     static final void staticUnlockAWT() {
         ContextStorage.getSynchronizer().unlock();
-    }
+    }    
 
     /**
      * InvokeAndWait under AWT lock. W/o this method system can hang up.
@@ -467,7 +467,8 @@
             }
             staticLockAWT();
             try {
-                defToolkit = new ToolkitImpl();
+                defToolkit = GraphicsEnvironment.isHeadless() ?
+                        new HeadlessToolkit() : new ToolkitImpl();
                 ContextStorage.setDefaultToolkit(defToolkit);
                 return defToolkit;
             } finally {
@@ -524,15 +525,19 @@
         return windowFocusProxyMap.get(getWindowFactory().getWindowById(id));
     }
 
-    final WindowFactory getWindowFactory() {
+    WindowFactory getWindowFactory() {
         return wtk.getWindowFactory();
     }
 
-    final GraphicsFactory getGraphicsFactory() {
+    GraphicsFactory getGraphicsFactory() {
         return wtk.getGraphicsFactory();
     }
+    
+    public Toolkit() {        
+        init();
+    }
 
-    public Toolkit() {
+    protected void init() {
         lockAWT();
         try {
             ComponentInternals.setComponentInternals(new ComponentInternalsImpl());
@@ -662,7 +667,6 @@
 
     Map<java.awt.font.TextAttribute, ?> mapInputMethodHighlightImpl(
             InputMethodHighlight highlight) throws HeadlessException {
-        checkHeadless();
         HashMap<java.awt.font.TextAttribute, ?> map = new HashMap<java.awt.font.TextAttribute, Object>();
         wtk.getSystemProperties().mapInputMethodHighlight(highlight, map);
         return Collections.<java.awt.font.TextAttribute, Object> unmodifiableMap(map);
@@ -729,7 +733,6 @@
             throws IndexOutOfBoundsException, HeadlessException {
         lockAWT();
         try {
-            checkHeadless();
             int w = img.getWidth(null), x = hotSpot.x;
             int h = img.getHeight(null), y = hotSpot.y;
             if (x < 0 || x >= w || y < 0 || y >= h) {
@@ -758,7 +761,6 @@
     public Dimension getBestCursorSize(int prefWidth, int prefHeight) throws HeadlessException {
         lockAWT();
         try {
-            checkHeadless();
             return wtk.getCursorFactory().getBestCursorSize(prefWidth, prefHeight);
         } finally {
             unlockAWT();
@@ -802,7 +804,6 @@
     public int getMaximumCursorColors() throws HeadlessException {
         lockAWT();
         try {
-            checkHeadless();
             return wtk.getCursorFactory().getMaximumCursorColors();
         } finally {
             unlockAWT();
@@ -812,7 +813,6 @@
     public int getMenuShortcutKeyMask() throws HeadlessException {
         lockAWT();
         try {
-            checkHeadless();
             return InputEvent.CTRL_MASK;
         } finally {
             unlockAWT();
@@ -862,7 +862,6 @@
     public Clipboard getSystemSelection() throws HeadlessException {
         lockAWT();
         try {
-            checkHeadless();
             SecurityManager security = System.getSecurityManager();
             if (security != null) {
                 security.checkSystemClipboardAccess();
@@ -888,7 +887,6 @@
     public boolean isDynamicLayoutActive() throws HeadlessException {
         lockAWT();
         try {
-            checkHeadless();
             // always return true
             return true;
         } finally {
@@ -899,7 +897,6 @@
     protected boolean isDynamicLayoutSet() throws HeadlessException {
         lockAWT();
         try {
-            checkHeadless();
             return bDynamicLayoutSet;
         } finally {
             unlockAWT();
@@ -909,7 +906,6 @@
     public boolean isFrameStateSupported(int state) throws HeadlessException {
         lockAWT();
         try {
-            checkHeadless();
             return wtk.getWindowFactory().isWindowStateSupported(state);
         } finally {
             unlockAWT();
@@ -944,7 +940,6 @@
     public void setDynamicLayout(boolean dynamic) throws HeadlessException {
         lockAWT();
         try {
-            checkHeadless();
             bDynamicLayoutSet = dynamic;
         } finally {
             unlockAWT();

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ToolkitImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ToolkitImpl.java?view=diff&rev=509503&r1=509502&r2=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ToolkitImpl.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ToolkitImpl.java Tue Feb 20 02:42:02 2007
@@ -48,10 +48,9 @@
     }
 
     @Override
-    protected TextAreaPeer createTextArea(TextArea a0) throws HeadlessException {
+    protected TextAreaPeer createTextArea(TextArea a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -117,7 +116,7 @@
     }
 
     @Override
-    public ColorModel getColorModel() throws HeadlessException {
+    public ColorModel getColorModel() {
         lockAWT();
         try {
             return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
@@ -166,10 +165,9 @@
     }
 
     @Override
-    protected ButtonPeer createButton(Button a0) throws HeadlessException {
+    protected ButtonPeer createButton(Button a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -187,10 +185,9 @@
     }
 
     @Override
-    protected CheckboxPeer createCheckbox(Checkbox a0) throws HeadlessException {
+    protected CheckboxPeer createCheckbox(Checkbox a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -202,7 +199,6 @@
             throws HeadlessException {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -210,10 +206,9 @@
     }
 
     @Override
-    protected ChoicePeer createChoice(Choice a0) throws HeadlessException {
+    protected ChoicePeer createChoice(Choice a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -221,10 +216,9 @@
     }
 
     @Override
-    protected DialogPeer createDialog(Dialog a0) throws HeadlessException {
+    protected DialogPeer createDialog(Dialog a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -238,10 +232,9 @@
     }
 
     @Override
-    protected FileDialogPeer createFileDialog(FileDialog a0) throws HeadlessException {
+    protected FileDialogPeer createFileDialog(FileDialog a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -249,10 +242,9 @@
     }
 
     @Override
-    protected FramePeer createFrame(Frame a0) throws HeadlessException {
+    protected FramePeer createFrame(Frame a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -260,10 +252,9 @@
     }
 
     @Override
-    protected LabelPeer createLabel(Label a0) throws HeadlessException {
+    protected LabelPeer createLabel(Label a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -271,10 +262,9 @@
     }
 
     @Override
-    protected ListPeer createList(List a0) throws HeadlessException {
+    protected ListPeer createList(List a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -282,10 +272,9 @@
     }
 
     @Override
-    protected MenuPeer createMenu(Menu a0) throws HeadlessException {
+    protected MenuPeer createMenu(Menu a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -293,10 +282,9 @@
     }
 
     @Override
-    protected MenuBarPeer createMenuBar(MenuBar a0) throws HeadlessException {
+    protected MenuBarPeer createMenuBar(MenuBar a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -304,10 +292,9 @@
     }
 
     @Override
-    protected MenuItemPeer createMenuItem(MenuItem a0) throws HeadlessException {
+    protected MenuItemPeer createMenuItem(MenuItem a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -325,10 +312,9 @@
     }
 
     @Override
-    protected PopupMenuPeer createPopupMenu(PopupMenu a0) throws HeadlessException {
+    protected PopupMenuPeer createPopupMenu(PopupMenu a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -336,10 +322,9 @@
     }
 
     @Override
-    protected ScrollPanePeer createScrollPane(ScrollPane a0) throws HeadlessException {
+    protected ScrollPanePeer createScrollPane(ScrollPane a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -347,10 +332,9 @@
     }
 
     @Override
-    protected ScrollbarPeer createScrollbar(Scrollbar a0) throws HeadlessException {
+    protected ScrollbarPeer createScrollbar(Scrollbar a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -358,10 +342,9 @@
     }
 
     @Override
-    protected TextFieldPeer createTextField(TextField a0) throws HeadlessException {
+    protected TextFieldPeer createTextField(TextField a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -369,10 +352,9 @@
     }
 
     @Override
-    protected WindowPeer createWindow(Window a0) throws HeadlessException {
+    protected WindowPeer createWindow(Window a0) {
         lockAWT();
         try {
-            checkHeadless();
             return null;
         } finally {
             unlockAWT();
@@ -465,7 +447,7 @@
     }
 
     @Override
-    public Dimension getScreenSize() throws HeadlessException {
+    public Dimension getScreenSize() {
         lockAWT();
         try {
             DisplayMode dm = GraphicsEnvironment.getLocalGraphicsEnvironment()
@@ -477,10 +459,9 @@
     }
 
     @Override
-    public Clipboard getSystemClipboard() throws HeadlessException {
+    public Clipboard getSystemClipboard() {
         lockAWT();
         try {
-            checkHeadless();
             SecurityManager security = System.getSecurityManager();
             if (security != null) {
                 security.checkSystemClipboardAccess();

Added: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/HeadlessTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/HeadlessTest.java?view=auto&rev=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/HeadlessTest.java (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/HeadlessTest.java Tue Feb 20 02:42:02 2007
@@ -0,0 +1,77 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.awt;
+
+import java.awt.Canvas;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Panel;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+
+import junit.framework.TestCase;
+
+public class HeadlessTest extends TestCase {    
+
+    public void testJButton(){
+        JButton jb = new JButton();
+        jb.addNotify();
+    }
+
+    public void testJPanel(){
+        JPanel jp = new JPanel();
+        jp.addNotify();
+    }
+    
+    public void testPanel(){
+        Panel p = new Panel();
+        p.addNotify();
+    }
+
+    public void testCanvas(){
+        Canvas cnv = new Canvas();
+        cnv.addNotify();
+    }
+
+    public void testBufferedImage(){
+        BufferedImage bi = new BufferedImage(800,600,BufferedImage.TYPE_3BYTE_BGR);
+        Graphics2D g2 = (Graphics2D)(bi.getGraphics()); 
+        g2.setColor(Color.RED);
+        g2.fillRect(200,100,600,500);
+        g2.setColor(Color.GREEN);
+        g2.drawOval(500,300,100,100);
+        Image i = null;
+        try{
+            File f = new File("test.jpg");
+            f.createNewFile();
+            ImageIO.write(bi, "jpg", f);
+            i = ImageIO.read(f);
+            f.delete();
+        }catch(IOException e){
+            throw new AssertionError(e); 
+        }
+    }
+}
+
+

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/HeadlessTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/RepaintManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/RepaintManager.java?view=diff&rev=509503&r1=509502&r2=509503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/RepaintManager.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/RepaintManager.java Tue Feb 20 02:42:02 2007
@@ -27,6 +27,7 @@
 import java.awt.Dimension;
 import java.awt.EventQueue;
 import java.awt.Graphics;
+import java.awt.GraphicsEnvironment;
 import java.awt.Image;
 import java.awt.Rectangle;
 import java.awt.Toolkit;
@@ -51,7 +52,7 @@
     private Image offscreenImage;
     private VolatileImage volatileOffscreenImage;
 
-    private Dimension maximumSize = Toolkit.getDefaultToolkit().getScreenSize();
+    private Dimension maximumSize;
     private boolean doubleBufferingEnabled = true;
     private Map dirtyRegions = new Hashtable();
     private Map optimizedDirtyRegions = new HashMap();
@@ -60,6 +61,12 @@
     private static final Rectangle COMPLETELY_DIRTY_RECT = new Rectangle(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
 
     private static RepaintManager instance;
+    
+    RepaintManager() {
+        maximumSize = GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance() ? 
+                new Dimension(0,0)
+                : Toolkit.getDefaultToolkit().getScreenSize();
+    }
 
     private final Runnable paintEvent = new Runnable() {
         public void run() {



Mime
View raw message