1 /*
   2  * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  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 /**
  25  * @test
  26  * @key headful
  27  * @bug 6396526
  28  * @summary Verify below-the-spot IM in the swing L&F JFrame.
  29  *          Although the swing component is decorated with L&F
  30  *          the IM window should have no decoration.
  31  * @author yuriko.yamasaki
  32  */
  33 
  34 import java.awt.*;
  35 import javax.swing.*;
  36 
  37 public class IMLookAndFeel {
  38     /**
  39      * Create the GUI and show it.  For thread safety,
  40      * this method should be invoked from the
  41      * event-dispatching thread.
  42      */
  43     private static void createAndShowGUI() {
  44         //Suggest that the L&F (rather than the system)
  45         //decorate all windows.  This must be invoked before
  46         //creating the JFrame.  Native look and feels will
  47         //ignore this hint.
  48         //Create and set up the window.
  49 
  50         JFrame.setDefaultLookAndFeelDecorated(true);
  51         JFrame frame = new JFrame("IM with L&F");
  52         //frame.setUndecorated( true );
  53 
  54         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  55         JTextArea description = new JTextArea("Please try typing using below-the-spot IM.\n\n eg. Use City IM with the following arguement:\n    -Djava.awt.im.style=below-the-spot");
  56         description.setPreferredSize(new Dimension(250, 70));
  57         description.setEditable(false);
  58         frame.getContentPane().add(description, BorderLayout.NORTH);
  59 
  60         JTextField textField = new JTextField();
  61         textField.setPreferredSize(new Dimension(275, 50));
  62         frame.getContentPane().add(textField, BorderLayout.CENTER);
  63 
  64         //Display the window.
  65         frame.pack();
  66         frame.setVisible(true);
  67     }
  68 
  69     public static void main(String[] args) {
  70         //Schedule a job for the event-dispatching thread:
  71         //creating and showing this application's GUI.
  72         javax.swing.SwingUtilities.invokeLater(new Runnable() {
  73             public void run() {
  74                 createAndShowGUI();
  75             }
  76         });
  77     }
  78 }