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  * @bug  6396526
  27  * @summary  Verify below-the-spot IM in the swing L&F JFrame.
  28  *           Although the swing component is decorated with L&F
  29  *           the IM window should have no decoration.
  30  * @author yuriko.yamasaki
  31  */
  32 
  33 import java.awt.*;
  34 import javax.swing.*;
  35 
  36 public class IMLookAndFeel {
  37     /**
  38      * Create the GUI and show it.  For thread safety,
  39      * this method should be invoked from the
  40      * event-dispatching thread.
  41      */
  42     private static void createAndShowGUI() {
  43         //Suggest that the L&F (rather than the system)
  44         //decorate all windows.  This must be invoked before
  45         //creating the JFrame.  Native look and feels will
  46         //ignore this hint.
  47         //Create and set up the window.
  48 
  49         JFrame.setDefaultLookAndFeelDecorated(true);
  50         JFrame frame = new JFrame("IM with L&F");
  51         //frame.setUndecorated( true );
  52 
  53         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  54         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");
  55         description.setPreferredSize(new Dimension(250, 70));
  56         description.setEditable(false);
  57         frame.getContentPane().add(description, BorderLayout.NORTH);
  58 
  59         JTextField textField = new JTextField();
  60         textField.setPreferredSize(new Dimension(275, 50));
  61         frame.getContentPane().add(textField, BorderLayout.CENTER);
  62 
  63         //Display the window.
  64         frame.pack();
  65         frame.setVisible(true);
  66     }
  67 
  68     public static void main(String[] args) {
  69         //Schedule a job for the event-dispatching thread:
  70         //creating and showing this application's GUI.
  71         javax.swing.SwingUtilities.invokeLater(new Runnable() {
  72             public void run() {
  73                 createAndShowGUI();
  74             }
  75         });
  76     }
  77 }