Author: [EMAIL PROTECTED]
Date: Sun Nov  9 03:01:04 2008
New Revision: 412

Modified:
     
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PComboBox.java
     
piccolo2d.java/trunk/extras/src/test/java/edu/umd/cs/piccolox/pswing/TestPSwing.java

Log:
Fix for Issue 9: PComboBox does not work when nested in a Panel
Modified TestPSwing to demonstrate the defect and patched PComboBox with  
the fix.


Modified:  
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PComboBox.java
==============================================================================
---  
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PComboBox.java
      
(original)
+++  
piccolo2d.java/trunk/extras/src/main/java/edu/umd/cs/piccolox/pswing/PComboBox.java
      
Sun Nov  9 03:01:04 2008
@@ -184,7 +184,7 @@
              throw new RuntimeException(
                      "PComboBox.setEnvironment( swing, pCanvas );//has to  
be done manually at present");
          }
-        Rectangle2D r1c = pSwing.getBounds();
+        Rectangle2D r1c = new Rectangle2D.Double(pSwing.getX(),  
pSwing.getY(), getWidth(), getHeight());
          pSwing.localToGlobal(r1c);
          canvas.getCamera().globalToLocal(r1c);
          r1c =  
canvas.getCamera().getViewTransform().createTransformedShape(r1c).getBounds2D();

Modified:  
piccolo2d.java/trunk/extras/src/test/java/edu/umd/cs/piccolox/pswing/TestPSwing.java
==============================================================================
---  
piccolo2d.java/trunk/extras/src/test/java/edu/umd/cs/piccolox/pswing/TestPSwing.java
     
(original)
+++  
piccolo2d.java/trunk/extras/src/test/java/edu/umd/cs/piccolox/pswing/TestPSwing.java
     
Sun Nov  9 03:01:04 2008
@@ -154,10 +154,14 @@
          root.translate(300, 200);
          pCanvas.getLayer().addChild(root);

+        // A Combo Box
+        JPanel comboPanel = new JPanel();
+        comboPanel.setBorder( BorderFactory.createTitledBorder( "Combo  
Box" ) );
          String[] listItems = { "Summer Teeth", "Mermaid Avenue", "Being  
There", "A.M." };
          PComboBox box = new PComboBox(listItems);
-        swing = new PSwing(box);
-        swing.translate(200, 250);
+        comboPanel.add(box);
+        swing = new PSwing(comboPanel);
+        swing.translate( 200, 230 );
          pCanvas.getLayer().addChild(swing);
          box.setEnvironment(swing, pCanvas);// has to be done manually at  
present


--~--~---------~--~----~------------~-------~--~----~
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to