< prev index next >

test/javax/swing/JButton/JButtonPaintNPE/JButtonPaintNPE.java

Print this page
rev 14031 : 8160974: [TESTBUG] Mark more headful tests with @key headful.

This is a backport of fe58d505fffd from jdk9. 228/596 hunks apply without
modifications. 16 hunks required manual rework. The remainder were for files
not present in jdk8u.


  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 import java.awt.Graphics;
  26 import java.awt.Toolkit;
  27 import java.awt.image.BufferedImage;
  28 import java.lang.reflect.InvocationTargetException;
  29 
  30 import javax.swing.JButton;
  31 import javax.swing.JFrame;
  32 import javax.swing.SwingUtilities;
  33 
  34 import sun.awt.SunToolkit;
  35 
  36 /**
  37  * @test

  38  * @bug 8009919
  39  * @author Sergey Bylokhov
  40  */
  41 public final class JButtonPaintNPE {
  42 
  43     private static JFrame frame;
  44 
  45     public static void main(final String[] args)
  46             throws InvocationTargetException, InterruptedException {
  47         SwingUtilities.invokeAndWait(() -> {
  48             frame = new JFrame();
  49             frame.add(new JButton() {
  50                 @Override
  51                 protected void paintComponent(final Graphics g) {
  52                     Graphics gg = new BufferedImage(getWidth(), getHeight(),
  53                                   BufferedImage.TYPE_INT_ARGB).createGraphics();
  54                     super.paintComponent(gg);
  55                     gg.dispose();
  56                 }
  57             });


  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 import java.awt.Graphics;
  26 import java.awt.Toolkit;
  27 import java.awt.image.BufferedImage;
  28 import java.lang.reflect.InvocationTargetException;
  29 
  30 import javax.swing.JButton;
  31 import javax.swing.JFrame;
  32 import javax.swing.SwingUtilities;
  33 
  34 import sun.awt.SunToolkit;
  35 
  36 /**
  37  * @test
  38  * @key headful
  39  * @bug 8009919
  40  * @author Sergey Bylokhov
  41  */
  42 public final class JButtonPaintNPE {
  43 
  44     private static JFrame frame;
  45 
  46     public static void main(final String[] args)
  47             throws InvocationTargetException, InterruptedException {
  48         SwingUtilities.invokeAndWait(() -> {
  49             frame = new JFrame();
  50             frame.add(new JButton() {
  51                 @Override
  52                 protected void paintComponent(final Graphics g) {
  53                     Graphics gg = new BufferedImage(getWidth(), getHeight(),
  54                                   BufferedImage.TYPE_INT_ARGB).createGraphics();
  55                     super.paintComponent(gg);
  56                     gg.dispose();
  57                 }
  58             });
< prev index next >