test/java/awt/xembed/server/TestXEmbedServer.java

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.awt.*;
  25 import java.awt.event.*;
  26 import javax.swing.*;
  27 import java.io.*;
  28 import java.util.logging.*;
  29 import sun.awt.WindowIDProvider;


  30 import java.awt.dnd.*;
  31 import java.awt.datatransfer.*;
  32 
  33 public abstract class TestXEmbedServer {
  34     // vertical position of server AND client windows
  35     private static final int VERTICAL_POSITION = 200;
  36 
  37     private static final Logger log = Logger.getLogger("test.xembed");
  38     Frame f;
  39     Canvas client;
  40     Button toFocus;
  41     Button b_modal;
  42     JButton b_close;
  43     JDialog modal_d;
  44     JFrame dummy;
  45     Container clientCont;
  46     boolean passed;
  47 
  48     public boolean isPassed() {
  49         return passed;


 165         dummy.getContentPane().add(new JButton("Button"));
 166         dummy.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
 167         dummy.setBounds(0, VERTICAL_POSITION, 100, 100);
 168         dummy.setVisible(true);
 169 
 170         f.setBounds(300, VERTICAL_POSITION, 800, 300);
 171         f.setVisible(true);
 172     }
 173 
 174     public abstract Process startClient(Rectangle bounds[], long window);
 175 
 176     public void addClient() {
 177         client = new Canvas() {
 178                 public void paint(Graphics g) {
 179                     super.paint(g);
 180                 }
 181             };
 182         client.setBackground(new Color(30, 220, 40));
 183         clientCont.add(client);
 184         clientCont.validate();
 185         WindowIDProvider pid = (WindowIDProvider)client.getPeer();

 186         log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow());
 187         Rectangle toFocusBounds = toFocus.getBounds();
 188         toFocusBounds.setLocation(toFocus.getLocationOnScreen());
 189         f.validate();
 190 
 191         // KDE doesn't accept clicks on title as activation - click below title
 192         Rectangle fbounds = f.getBounds();
 193         fbounds.y += f.getInsets().top;
 194         fbounds.height -= f.getInsets().top;
 195 
 196         Process proc = startClient(new Rectangle[] {fbounds, dummy.getBounds(), toFocusBounds,
 197                                                     new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()),
 198                                                     new Rectangle(10, 130, 20, 20)}, pid.getWindow());
 199         new ClientWatcher(client, proc, clientCont).start();
 200     }
 201 
 202     public void dispose() {
 203         f.dispose();
 204         f = null;
 205         dummy.dispose();




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.awt.*;
  25 import java.awt.event.*;
  26 import javax.swing.*;
  27 import java.io.*;
  28 import java.util.logging.*;
  29 import sun.awt.WindowIDProvider;
  30 import sun.awt.AWTAccessor;
  31 import sun.awt.AWTAccessor.ComponentAccessor;
  32 import java.awt.dnd.*;
  33 import java.awt.datatransfer.*;
  34 
  35 public abstract class TestXEmbedServer {
  36     // vertical position of server AND client windows
  37     private static final int VERTICAL_POSITION = 200;
  38 
  39     private static final Logger log = Logger.getLogger("test.xembed");
  40     Frame f;
  41     Canvas client;
  42     Button toFocus;
  43     Button b_modal;
  44     JButton b_close;
  45     JDialog modal_d;
  46     JFrame dummy;
  47     Container clientCont;
  48     boolean passed;
  49 
  50     public boolean isPassed() {
  51         return passed;


 167         dummy.getContentPane().add(new JButton("Button"));
 168         dummy.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
 169         dummy.setBounds(0, VERTICAL_POSITION, 100, 100);
 170         dummy.setVisible(true);
 171 
 172         f.setBounds(300, VERTICAL_POSITION, 800, 300);
 173         f.setVisible(true);
 174     }
 175 
 176     public abstract Process startClient(Rectangle bounds[], long window);
 177 
 178     public void addClient() {
 179         client = new Canvas() {
 180                 public void paint(Graphics g) {
 181                     super.paint(g);
 182                 }
 183             };
 184         client.setBackground(new Color(30, 220, 40));
 185         clientCont.add(client);
 186         clientCont.validate();
 187         final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); 
 188         WindowIDProvider pid = (WindowIDProvider)acc.getPeer(client);
 189         log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow());
 190         Rectangle toFocusBounds = toFocus.getBounds();
 191         toFocusBounds.setLocation(toFocus.getLocationOnScreen());
 192         f.validate();
 193 
 194         // KDE doesn't accept clicks on title as activation - click below title
 195         Rectangle fbounds = f.getBounds();
 196         fbounds.y += f.getInsets().top;
 197         fbounds.height -= f.getInsets().top;
 198 
 199         Process proc = startClient(new Rectangle[] {fbounds, dummy.getBounds(), toFocusBounds,
 200                                                     new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()),
 201                                                     new Rectangle(10, 130, 20, 20)}, pid.getWindow());
 202         new ClientWatcher(client, proc, clientCont).start();
 203     }
 204 
 205     public void dispose() {
 206         f.dispose();
 207         f = null;
 208         dummy.dispose();