< prev index next >

test/jdk/javax/swing/JSpinner/WrongEditorTextFieldFont/FontSetByUser.java

Print this page


   1 /*
   2  * Copyright (c) 2015, 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 import java.awt.FlowLayout;
  25 import java.awt.Font;
  26 
  27 import javax.swing.JFrame;
  28 import javax.swing.JSpinner;
  29 import javax.swing.SwingUtilities;
  30 import javax.swing.UIManager;
  31 import javax.swing.UnsupportedLookAndFeelException;
  32 import javax.swing.plaf.UIResource;
  33 
  34 import static javax.swing.JSpinner.*;
  35 import static javax.swing.UIManager.getInstalledLookAndFeels;
  36 
  37 /**
  38  * @test
  39  * @key headful
  40  * @bug 5036022
  41  * @author Sergey Bylokhov
  42  */
  43 public class WrongEditorTextFieldFont implements Runnable {
  44 
  45     private static final Font USERS_FONT = new Font("dialog", Font.BOLD, 41);
  46 
  47     public static void main(final String[] args) throws Exception {
  48         for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
  49             SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf));
  50             SwingUtilities.invokeAndWait(new WrongEditorTextFieldFont());
  51         }
  52     }
  53 
  54     @Override
  55     public void run() {
  56         final JFrame frame1 = new JFrame();
  57         try {
  58             testDefaultFont(frame1);
  59         } finally {
  60             frame1.dispose();
  61         }
  62     }
  63 
  64     private static void testDefaultFont(final JFrame frame) {
  65         final JSpinner spinner = new JSpinner();
  66         final JSpinner spinner_u = new JSpinner();
  67         frame.setLayout(new FlowLayout(FlowLayout.CENTER, 50, 50));
  68         frame.getContentPane().add(spinner);
  69         frame.getContentPane().add(spinner_u);
  70         frame.pack();


   1 /*
   2  * Copyright (c) 2015, 2018, 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 import java.awt.FlowLayout;
  25 import java.awt.Font;
  26 
  27 import javax.swing.JFrame;
  28 import javax.swing.JSpinner;
  29 import javax.swing.SwingUtilities;
  30 import javax.swing.UIManager;
  31 import javax.swing.UnsupportedLookAndFeelException;
  32 import javax.swing.plaf.UIResource;
  33 
  34 import static javax.swing.JSpinner.*;
  35 import static javax.swing.UIManager.getInstalledLookAndFeels;
  36 
  37 /**
  38  * @test
  39  * @key headful
  40  * @bug 5036022

  41  */
  42 public class FontSetByUser implements Runnable {
  43 
  44     private static final Font USERS_FONT = new Font("dialog", Font.BOLD, 41);
  45 
  46     public static void main(final String[] args) throws Exception {
  47         for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
  48             SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf));
  49             SwingUtilities.invokeAndWait(new FontSetByUser());
  50         }
  51     }
  52 
  53     @Override
  54     public void run() {
  55         final JFrame frame1 = new JFrame();
  56         try {
  57             testDefaultFont(frame1);
  58         } finally {
  59             frame1.dispose();
  60         }
  61     }
  62 
  63     private static void testDefaultFont(final JFrame frame) {
  64         final JSpinner spinner = new JSpinner();
  65         final JSpinner spinner_u = new JSpinner();
  66         frame.setLayout(new FlowLayout(FlowLayout.CENTER, 50, 50));
  67         frame.getContentPane().add(spinner);
  68         frame.getContentPane().add(spinner_u);
  69         frame.pack();


< prev index next >