This patch (committed) removes one of the 'Close' buttons from the demo panels when they are launched from the main Swing demo:

2006-01-30  David Gilbert  <[EMAIL PROTECTED]>

        * examples/gnu/classpath/examples/swing/ButtonDemo.java
        (ButtonDemo): Move content initialisation to new method,
        (initFrameContent): New method,
        (main): Call initFrameContent(),
        * examples/gnu/classpath/examples/swing/ComboBoxDemo.java: Likewise,
        * examples/gnu/classpath/examples/swing/FileChooserDemo.java: Likewise,
        * examples/gnu/classpath/examples/swing/ScrollBarDemo.java: Likewise,
        * examples/gnu/classpath/examples/swing/SliderDemo.java: Likewise,
        * examples/gnu/classpath/examples/swing/TextFieldDemo.java: Likewise.

Regards,

Dave
Index: examples/gnu/classpath/examples/swing/ButtonDemo.java
===================================================================
RCS file: 
/sources/classpath/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java,v
retrieving revision 1.5
diff -u -r1.5 ButtonDemo.java
--- examples/gnu/classpath/examples/swing/ButtonDemo.java       27 Jan 2006 
21:56:31 -0000      1.5
+++ examples/gnu/classpath/examples/swing/ButtonDemo.java       30 Jan 2006 
23:07:13 -0000
@@ -1,5 +1,5 @@
 /* ButtonDemo.java -- An example showing various buttons in Swing.
-   Copyright (C) 2005,  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath examples.
 
@@ -79,6 +79,19 @@
   {
     super(title);
     JPanel content = createContent();
+    // initFrameContent() is only called (from main) when running this app 
+    // standalone
+  }
+  
+  /**
+   * When the demo is run independently, the frame is displayed, so we should
+   * initialise the content panel (including the demo content and a close 
+   * button).  But when the demo is run as part of the Swing activity board,
+   * only the demo content panel is used, the frame itself is never displayed,
+   * so we can avoid this step.
+   */
+  public void initFrameContent() 
+  {
     JPanel closePanel = new JPanel();
     JButton closeButton = new JButton("Close");
     closeButton.setActionCommand("CLOSE");
@@ -282,6 +295,7 @@
   public static void main(String[] args) 
   {
     ButtonDemo app = new ButtonDemo("Button Demo");
+    app.initFrameContent();
     app.pack();
     app.setVisible(true);
   }
Index: examples/gnu/classpath/examples/swing/ComboBoxDemo.java
===================================================================
RCS file: 
/sources/classpath/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java,v
retrieving revision 1.6
diff -u -r1.6 ComboBoxDemo.java
--- examples/gnu/classpath/examples/swing/ComboBoxDemo.java     27 Jan 2006 
21:56:31 -0000      1.6
+++ examples/gnu/classpath/examples/swing/ComboBoxDemo.java     30 Jan 2006 
23:07:13 -0000
@@ -1,5 +1,5 @@
 /* ComboBoxDemo.java -- An example showing various combo boxes in Swing.
-   Copyright (C) 2005,  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath examples.
 
@@ -103,6 +103,19 @@
   {
     super(title);
     JPanel content = createContent();
+    // initFrameContent() is only called (from main) when running this app 
+    // standalone
+  }
+  
+  /**
+   * When the demo is run independently, the frame is displayed, so we should
+   * initialise the content panel (including the demo content and a close 
+   * button).  But when the demo is run as part of the Swing activity board,
+   * only the demo content panel is used, the frame itself is never displayed,
+   * so we can avoid this step.
+   */
+  public void initFrameContent() 
+  {
     JPanel closePanel = new JPanel();
     JButton closeButton = new JButton("Close");
     closeButton.setActionCommand("CLOSE");
@@ -357,6 +370,7 @@
         e.printStackTrace();
     }
     ComboBoxDemo app = new ComboBoxDemo("ComboBox Demo");
+    app.initFrameContent();
     app.pack();
     app.setVisible(true);
   }
Index: examples/gnu/classpath/examples/swing/FileChooserDemo.java
===================================================================
RCS file: 
/sources/classpath/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java,v
retrieving revision 1.2
diff -u -r1.2 FileChooserDemo.java
--- examples/gnu/classpath/examples/swing/FileChooserDemo.java  27 Jan 2006 
21:56:31 -0000      1.2
+++ examples/gnu/classpath/examples/swing/FileChooserDemo.java  30 Jan 2006 
23:07:14 -0000
@@ -1,5 +1,5 @@
 /* FileChooserDemo.java -- An example showing file choosers in Swing.
-   Copyright (C) 2005,  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath examples.
 
@@ -87,6 +87,19 @@
   {
     super(frameTitle);
     JPanel content = createContent();
+    // initFrameContent() is only called (from main) when running this app 
+    // standalone
+  }
+  
+  /**
+   * When the demo is run independently, the frame is displayed, so we should
+   * initialise the content panel (including the demo content and a close 
+   * button).  But when the demo is run as part of the Swing activity board,
+   * only the demo content panel is used, the frame itself is never displayed,
+   * so we can avoid this step.
+   */
+  public void initFrameContent() 
+  {
     JPanel closePanel = new JPanel();
     JButton closeButton = new JButton("Close");
     closeButton.setActionCommand("CLOSE");
@@ -227,6 +240,7 @@
   public static void main(String[] args) 
   {
     FileChooserDemo app = new FileChooserDemo("File Chooser Demo");
+    app.initFrameContent();
     app.pack();
     app.setVisible(true);
   }
Index: examples/gnu/classpath/examples/swing/ScrollBarDemo.java
===================================================================
RCS file: 
/sources/classpath/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java,v
retrieving revision 1.4
diff -u -r1.4 ScrollBarDemo.java
--- examples/gnu/classpath/examples/swing/ScrollBarDemo.java    27 Jan 2006 
21:56:31 -0000      1.4
+++ examples/gnu/classpath/examples/swing/ScrollBarDemo.java    30 Jan 2006 
23:07:14 -0000
@@ -1,5 +1,5 @@
 /* ScrollBarDemo.java -- An example showing scroll bars in Swing.
-   Copyright (C) 2005,  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath examples.
 
@@ -51,6 +51,19 @@
   {
     super(title);
     JPanel content = createContent();
+    // initFrameContent() is only called (from main) when running this app 
+    // standalone
+  }
+  
+  /**
+   * When the demo is run independently, the frame is displayed, so we should
+   * initialise the content panel (including the demo content and a close 
+   * button).  But when the demo is run as part of the Swing activity board,
+   * only the demo content panel is used, the frame itself is never displayed,
+   * so we can avoid this step.
+   */
+  public void initFrameContent()
+  {
     JPanel closePanel = new JPanel();
     JButton closeButton = new JButton("Close");
     closeButton.setActionCommand("CLOSE");
@@ -139,6 +152,7 @@
   public static void main(String[] args) 
   {
     ScrollBarDemo app = new ScrollBarDemo("ScrollBar Demo");
+    app.initFrameContent();
     app.pack();
     app.setVisible(true);
   }
Index: examples/gnu/classpath/examples/swing/SliderDemo.java
===================================================================
RCS file: 
/sources/classpath/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java,v
retrieving revision 1.4
diff -u -r1.4 SliderDemo.java
--- examples/gnu/classpath/examples/swing/SliderDemo.java       27 Jan 2006 
21:56:31 -0000      1.4
+++ examples/gnu/classpath/examples/swing/SliderDemo.java       30 Jan 2006 
23:07:14 -0000
@@ -1,5 +1,5 @@
 /* SliderDemo.java -- An example showing JSlider in various configurations.
-   Copyright (C) 2005,  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath examples.
 
@@ -61,13 +61,26 @@
   public SliderDemo(String frameTitle) 
   {
     super(frameTitle);
-    JPanel cont = createContent();
+    content = createContent();
+    // initFrameContent() is only called (from main) when running this app 
+    // standalone
+  }
+  
+  /**
+   * When the demo is run independently, the frame is displayed, so we should
+   * initialise the content panel (including the demo content and a close 
+   * button).  But when the demo is run as part of the Swing activity board,
+   * only the demo content panel is used, the frame itself is never displayed,
+   * so we can avoid this step.
+   */
+  public void initFrameContent()
+  {
     JPanel closePanel = new JPanel();
     JButton closeButton = new JButton("Close");
     closeButton.setActionCommand("CLOSE");
     closeButton.addActionListener(this);
     closePanel.add(closeButton);
-    cont.add(closePanel, BorderLayout.SOUTH);
+    content.add(closePanel, BorderLayout.SOUTH);
     getContentPane().add(content);
   }
        
@@ -247,6 +260,7 @@
   public static void main(String[] args) 
   {
     SliderDemo app = new SliderDemo("Slider Demo");
+    app.initFrameContent();
     app.pack();
     app.setVisible(true);
   }
Index: examples/gnu/classpath/examples/swing/TextFieldDemo.java
===================================================================
RCS file: 
/sources/classpath/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java,v
retrieving revision 1.2
diff -u -r1.2 TextFieldDemo.java
--- examples/gnu/classpath/examples/swing/TextFieldDemo.java    27 Jan 2006 
21:56:31 -0000      1.2
+++ examples/gnu/classpath/examples/swing/TextFieldDemo.java    30 Jan 2006 
23:07:15 -0000
@@ -1,5 +1,5 @@
 /* TextFieldDemo.java -- An example showing various textfields in Swing.
-   Copyright (C) 2005,  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath examples.
 
@@ -117,7 +117,7 @@
   JTextField textfield3;
   JCheckBox enabled1;
   JCheckBox editable1;
-JPanel textFieldPanel1;
+  JPanel textFieldPanel1;
   /**
    * The right aligned textfields and state buttons.
    */
@@ -164,6 +164,19 @@
   {
     super(title);
     JPanel content = createContent();
+    // initFrameContent() is only called (from main) when running this app 
+    // standalone
+  }
+  
+  /**
+   * When the demo is run independently, the frame is displayed, so we should
+   * initialise the content panel (including the demo content and a close 
+   * button).  But when the demo is run as part of the Swing activity board,
+   * only the demo content panel is used, the frame itself is never displayed,
+   * so we can avoid this step.
+   */
+  public void initFrameContent() 
+  {
     JPanel closePanel = new JPanel();
     JButton closeButton = new JButton("Close");
     closeButton.setActionCommand("CLOSE");
@@ -486,6 +499,7 @@
   public static void main(String[] args) 
   {
     TextFieldDemo app = new TextFieldDemo("TextField Demo");
+    app.initFrameContent();
     app.pack();
     app.setVisible(true);
   }

Reply via email to