[Patch][gui] JApplet, JInternalFrame and JWindow

Michael Koch konqueror@gmx.de
Wed Dec 22 21:45:00 GMT 2004


Hi list,


I just commited the attached patch to merge it from GNU classpath.



Michael


2004-12-22  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JApplet.java
	(HIDE_ON_CLOSE): Removed.
	(EXIT_ON_CLOSE): Likewise.
	(DISPOSE_ON_CLOSE): Likewise.
	(DO_NOTHING_ON_CLOSE): Likewise.
	(close_action): Likewise.
	(getDefaultCloseOperation): Likewise.
	(setDefaultCloseOperation): Likewise.
	(processWindowEvent): Likewise.
	(getPreferredSize): Simplified.
	* javax/swing/JInternalFrame.java
	(setDefaultCloseOperation): Fixed throwing exception on wrong argument
	value.
	* javax/swing/JWindow.java
	(HIDE_ON_CLOSE): Removed.
	(EXIT_ON_CLOSE): Likewise.
	(DISPOSE_ON_CLOSE): Likewise.
	(DO_NOTHING_ON_CLOSE): Likewise.
	(close_action): Likewise.
	(processKeyEvent): Likewise.
	(setDefaultCloseOperation): Likewise.
	(getPreferredSize): Simplified.

-------------- next part --------------
Index: javax/swing/JApplet.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JApplet.java,v
retrieving revision 1.3.2.6
diff -u -r1.3.2.6 JApplet.java
--- javax/swing/JApplet.java	22 Oct 2004 12:41:11 -0000	1.3.2.6
+++ javax/swing/JApplet.java	22 Dec 2004 21:39:56 -0000
@@ -55,13 +55,6 @@
 {
   private static final long serialVersionUID = 7269359214497372587L;
   
-  public static final int HIDE_ON_CLOSE = 0;
-  public static final int EXIT_ON_CLOSE = 1;
-  public static final int DISPOSE_ON_CLOSE = 2;
-  public static final int DO_NOTHING_ON_CLOSE = 3;
-  
-  private int close_action = EXIT_ON_CLOSE;
-
   protected JRootPane rootPane;
   protected boolean rootPaneCheckingEnabled;
 
@@ -83,10 +76,7 @@
 
   public Dimension getPreferredSize()
   {
-    Dimension d = super.getPreferredSize();
-    System.out.println("JFrame.getPrefSize(): " + d + " , comp="
-                       + getComponentCount() + ", layout=" + getLayout());
-    return d;
+    return super.getPreferredSize();
   }
 
   public void setLayout(LayoutManager manager)
@@ -155,11 +145,6 @@
     return null;
   }
 
-  int getDefaultCloseOperation()
-  {
-    return close_action;
-  }
-
   public JMenuBar getJMenuBar()
   {
     return getRootPane().getJMenuBar();
@@ -179,56 +164,12 @@
   {
     super.processKeyEvent(e);
   }
-
-  protected void processWindowEvent(WindowEvent e)
-  {
-    //      System.out.println("PROCESS_WIN_EV-1: " + e);
-    //        super.processWindowEvent(e); 
-    //      System.out.println("PROCESS_WIN_EV-2: " + e);
-    switch (e.getID())
-      {
-      case WindowEvent.WINDOW_CLOSING:
-        {
-	  switch (close_action)
-	    {
-	    case EXIT_ON_CLOSE:
-	      {
-		System.out.println("user requested exit on close");
-		System.exit(1);
-		break;
-	      }
-	    case DISPOSE_ON_CLOSE:
-	      {
-		System.out.println("user requested dispose on close");
-		//dispose();
-		break;
-	      }
-	    case HIDE_ON_CLOSE:
-	    case DO_NOTHING_ON_CLOSE:
-	      break;
-	    }
-	  break;
-        }
-      case WindowEvent.WINDOW_CLOSED:
-      case WindowEvent.WINDOW_OPENED:
-      case WindowEvent.WINDOW_ICONIFIED:
-      case WindowEvent.WINDOW_DEICONIFIED:
-      case WindowEvent.WINDOW_ACTIVATED:
-      case WindowEvent.WINDOW_DEACTIVATED:
-	break;
-      }
-  }
-
+  
   public void remove(Component comp)
   {
     getContentPane().remove(comp);
   }
 
-  void setDefaultCloseOperation(int operation)
-  {
-    close_action = operation;
-  }
-
   protected boolean isRootPaneCheckingEnabled()
   {
     return rootPaneCheckingEnabled;
Index: javax/swing/JInternalFrame.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JInternalFrame.java,v
retrieving revision 1.2.18.7
diff -u -r1.2.18.7 JInternalFrame.java
--- javax/swing/JInternalFrame.java	13 Dec 2004 19:09:07 -0000	1.2.18.7
+++ javax/swing/JInternalFrame.java	22 Dec 2004 21:39:56 -0000
@@ -1272,8 +1272,9 @@
    */
   public void setDefaultCloseOperation(int operation)
   {
-    if (operation != DO_NOTHING_ON_CLOSE || operation != HIDE_ON_CLOSE
-        || operation != DISPOSE_ON_CLOSE)
+    if (operation != DO_NOTHING_ON_CLOSE
+	&& operation != HIDE_ON_CLOSE
+        && operation != DISPOSE_ON_CLOSE)
       throw new Error("Close operation must be one of DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE");
     defaultCloseOperation = operation;
   }
Index: javax/swing/JWindow.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JWindow.java,v
retrieving revision 1.3.18.8
diff -u -r1.3.18.8 JWindow.java
--- javax/swing/JWindow.java	22 Oct 2004 17:43:52 -0000	1.3.18.8
+++ javax/swing/JWindow.java	22 Dec 2004 21:39:56 -0000
@@ -62,180 +62,125 @@
 {
   private static final long serialVersionUID = 5420698392125238833L;
   
-  public static final int HIDE_ON_CLOSE = 0;
-  public static final int EXIT_ON_CLOSE = 1;
-  public static final int DISPOSE_ON_CLOSE = 2;
-  public static final int DO_NOTHING_ON_CLOSE  = 3;
-
-    protected  AccessibleContext accessibleContext;
-
-    private int close_action = EXIT_ON_CLOSE;    
-    
-    
-    /***************************************************
-     *
-     *
-     *  constructors
-     *
-     *
-     *************/
-
-    public JWindow()
-    {      
-      super(SwingUtilities.getOwnerFrame());
-    }
-
-    // huuu ?
-    public JWindow(Frame f)
-    {
-	super(f);
-    }
-    
-    /***************************************************
-     *
-     *
-     *  methods, this part is shared with JDialog, JFrame
-     *
-     *
-     *************/
-
-  
-    private boolean checking;
-    protected  JRootPane         rootPane;
-
-    
-    protected  void frameInit()
-    {
-      super.setLayout(new BorderLayout(1, 1));
-      getRootPane(); // will do set/create
-    }
-  
+  protected AccessibleContext accessibleContext;
+
+  public JWindow()
+  {
+    super(SwingUtilities.getOwnerFrame());
+  }
+
+  public JWindow(Frame f)
+  {
+    super(f);
+  }
+
+  private boolean checking;
+  protected JRootPane rootPane;
+
+  protected void frameInit()
+  {
+    super.setLayout(new BorderLayout(1, 1));
+    getRootPane(); // will do set/create
+  }
+
   public Dimension getPreferredSize()
   {
-    Dimension d = super.getPreferredSize();
-    return d;
+    return super.getPreferredSize();
+  }
+
+  public void setLayout(LayoutManager manager)
+  {
+    super.setLayout(manager);
+  }
+
+  public void setLayeredPane(JLayeredPane layeredPane)
+  {
+    getRootPane().setLayeredPane(layeredPane);
+  }
+
+  public JLayeredPane getLayeredPane()
+  {
+    return getRootPane().getLayeredPane();
+  }
+
+  public JRootPane getRootPane()
+  {
+    if (rootPane == null)
+      setRootPane(createRootPane());
+    return rootPane;
+  }
+
+  public void setRootPane(JRootPane root)
+  {
+    if (rootPane != null)
+      remove(rootPane);
+
+    rootPane = root;
+    add(rootPane, BorderLayout.CENTER);
+  }
+
+  public JRootPane createRootPane()
+  {
+    return new JRootPane();
+  }
+
+  public Container getContentPane()
+  {
+    return getRootPane().getContentPane();
+  }
+
+  public void setContentPane(Container contentPane)
+  {
+    getRootPane().setContentPane(contentPane);
+  }
+
+  public Component getGlassPane()
+  {
+    return getRootPane().getGlassPane();
   }
 
-  public  void setLayout(LayoutManager manager)
-  {    super.setLayout(manager);  }
+  public void setGlassPane(Component glassPane)
+  {
+    getRootPane().setGlassPane(glassPane);
+  }
 
-    public void setLayeredPane(JLayeredPane layeredPane) 
-    {   getRootPane().setLayeredPane(layeredPane);   }
-  
-    public JLayeredPane getLayeredPane()
-    {   return getRootPane().getLayeredPane();     }
-  
-    public JRootPane getRootPane()
-    {
-	if (rootPane == null)
-	    setRootPane(createRootPane());
-	return rootPane;          
-    }
-
-    public void setRootPane(JRootPane root)
-    {
-	if (rootPane != null)
-	    remove(rootPane);
-	    
-	rootPane = root; 
-	add(rootPane, BorderLayout.CENTER);
-    }
-
-    public JRootPane createRootPane()
-    {   return new JRootPane();    }
-
-    public Container getContentPane()
-    {    return getRootPane().getContentPane();     }
-
-    public void setContentPane(Container contentPane)
-    {    getRootPane().setContentPane(contentPane);    }
-  
-    public Component getGlassPane()
-    {    return getRootPane().getGlassPane();   }
-  
-    public void setGlassPane(Component glassPane)
-    {   getRootPane().setGlassPane(glassPane);   }
-
-    
-    protected  void addImpl(Component comp, Object constraints, int index)
-    {	super.addImpl(comp, constraints, index);    }
-
-
-    public void remove(Component comp)
-    {   getContentPane().remove(comp);  }
-  
-    protected  boolean isRootPaneCheckingEnabled()
-    {    return checking;        }
-
-
-    protected  void setRootPaneCheckingEnabled(boolean enabled)
-    { checking = enabled;  }
-
-
-    public void update(Graphics g)
-    {   paint(g);  }
-
-    protected  void processKeyEvent(KeyEvent e)
-    {	super.processKeyEvent(e);    }
-
-    /////////////////////////////////////////////////////////////////////////////////
-  
-    public AccessibleContext getAccessibleContext()
-    {    return null;  }
-  
-    int getDefaultCloseOperation()
-    {    return close_action;   }    
-    
-    protected  String paramString()
-    {   return "JWindow";     }
-
-
-    protected  void processWindowEvent(WindowEvent e)
-    {
-	//	System.out.println("PROCESS_WIN_EV-1: " + e);
-	super.processWindowEvent(e); 
-	//	System.out.println("PROCESS_WIN_EV-2: " + e);
-	switch (e.getID())
-	    {
-	    case WindowEvent.WINDOW_CLOSING:
-		{
-		    switch(close_action)
-			{
-			case EXIT_ON_CLOSE:
-			    {
-				System.out.println("user requested exit on close");
-				System.exit(1);
-				break;
-			    }
-			case DISPOSE_ON_CLOSE:
-			    {
-				System.out.println("user requested dispose on close");
-				dispose();
-				break;
-			    }
-			case HIDE_ON_CLOSE:
-			    {
-				setVisible(false);
-				break;
-			    }
-			case DO_NOTHING_ON_CLOSE:
-			    break;
-			}
-		    break;
-		}
-		
-	    case WindowEvent.WINDOW_CLOSED:
-	    case WindowEvent.WINDOW_OPENED:
-	    case WindowEvent.WINDOW_ICONIFIED:
-	    case WindowEvent.WINDOW_DEICONIFIED:
-	    case WindowEvent.WINDOW_ACTIVATED:
-	    case WindowEvent.WINDOW_DEACTIVATED:
-		break;
-	    }
-    }   
- 
+  protected void addImpl(Component comp, Object constraints, int index)
+  {
+    super.addImpl(comp, constraints, index);
+  }
 
-    void setDefaultCloseOperation(int operation)
-    {  close_action = operation;   }
+  public void remove(Component comp)
+  {
+    getContentPane().remove(comp);
+  }
 
+  protected boolean isRootPaneCheckingEnabled()
+  {
+    return checking;
+  }
+
+  protected void setRootPaneCheckingEnabled(boolean enabled)
+  {
+    checking = enabled;
+  }
+
+  public void update(Graphics g)
+  {
+    paint(g);
+  }
+
+  protected void processKeyEvent(KeyEvent e)
+  {
+    super.processKeyEvent(e);
+  }
+
+  public AccessibleContext getAccessibleContext()
+  {
+    return null;
+  }
+
+  protected String paramString()
+  {
+    return "JWindow";
+  }
 }


More information about the Java-patches mailing list