< prev index next >

test/jdk/javax/swing/AbstractButton/5049549/bug5049549.java

Print this page

  1 /*
  2  * Copyright (c) 2006, 2022, 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 /* @test
 25    @bug 5049549 7132413
 26    @summary Tests that the proper icon is used for different states.
 27    @library ../../regtesthelpers
 28    @build Blocker
 29    @run main/manual bug5049549
 30 */
 31 
 32 import javax.swing.BoxLayout;
 33 import javax.swing.Icon;
 34 import javax.swing.ImageIcon;
 35 import javax.swing.JButton;
 36 import javax.swing.JFrame;
 37 import javax.swing.JLabel;
 38 import javax.swing.JPanel;
 39 import javax.swing.SwingUtilities;
 40 import javax.swing.UIManager;
 41 








 42 public class bug5049549 {
 43 
 44     private static ImageIcon DE = new ImageIcon(bug5049549.class.getResource("DE1.gif"));
 45     private static ImageIcon DI = new ImageIcon(bug5049549.class.getResource("DI1.gif"));
 46     private static ImageIcon DS = new ImageIcon(bug5049549.class.getResource("DS1.gif"));
 47     private static ImageIcon RO = new ImageIcon(bug5049549.class.getResource("RO1.gif"));
 48     private static ImageIcon RS = new ImageIcon(bug5049549.class.getResource("RS1.gif"));
 49     private static ImageIcon SE = new ImageIcon(bug5049549.class.getResource("SE1.gif"));
 50     private static ImageIcon PR = new ImageIcon(bug5049549.class.getResource("PR1.gif"));
 51 
 52     private static Blocker blocker = new Blocker();














 53 
 54     private static class KButton extends JButton {
 55 
 56             KButton(String ex) {
 57                 super(ex);
 58             }
 59 
 60             private Icon disabledIcon;
 61             private Icon disabledSelectedIcon;
 62 
 63             public Icon getDisabledIcon() {
 64                 return disabledIcon;
 65             }
 66 
 67             public Icon getDisabledSelectedIcon() {
 68                 return disabledSelectedIcon;
 69             }
 70 
 71             public void setDisabledIcon(Icon icon) {
 72                 disabledIcon = icon;

  1 /*
  2  * Copyright (c) 2006, 2023, 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.Color;
 25 import java.awt.Font;
 26 import java.awt.Graphics;
 27 import java.awt.image.BufferedImage;




 28 import javax.swing.BoxLayout;
 29 import javax.swing.Icon;
 30 import javax.swing.ImageIcon;
 31 import javax.swing.JButton;
 32 import javax.swing.JFrame;
 33 import javax.swing.JLabel;
 34 import javax.swing.JPanel;
 35 import javax.swing.SwingUtilities;
 36 import javax.swing.UIManager;
 37 
 38 /*
 39  * @test
 40  * @bug 5049549 7132413
 41  * @summary Tests that the proper icon is used for different states.
 42  * @library ../../regtesthelpers
 43  * @build Blocker
 44  * @run main/manual bug5049549
 45  */
 46 public class bug5049549 {
 47 
 48     private static final Icon DE = generateImage("DE");
 49     private static final Icon DI = generateImage("DI");
 50     private static final Icon DS = generateImage("DS");
 51     private static final Icon RO = generateImage("RO");
 52     private static final Icon RS = generateImage("RS");
 53     private static final Icon SE = generateImage("SE");
 54     private static final Icon PR = generateImage("PR");
 55 
 56     private static final Blocker blocker = new Blocker();
 57 
 58     private static Icon generateImage(String str) {
 59         BufferedImage img = new BufferedImage(40, 30,
 60                 BufferedImage.TYPE_INT_RGB);
 61         Graphics g = img.createGraphics();
 62         g.setColor(Color.WHITE);
 63         g.fillRect(0, 0, img.getWidth(), img.getHeight());
 64         g.setColor(Color.RED);
 65         Font font = new Font(Font.SANS_SERIF, Font.BOLD, 22);
 66         g.setFont(font);
 67         g.drawString(str, 5, 25);
 68         g.dispose();
 69         return new ImageIcon(img);
 70     }
 71 
 72     private static class KButton extends JButton {
 73 
 74             KButton(String ex) {
 75                 super(ex);
 76             }
 77 
 78             private Icon disabledIcon;
 79             private Icon disabledSelectedIcon;
 80 
 81             public Icon getDisabledIcon() {
 82                 return disabledIcon;
 83             }
 84 
 85             public Icon getDisabledSelectedIcon() {
 86                 return disabledSelectedIcon;
 87             }
 88 
 89             public void setDisabledIcon(Icon icon) {
 90                 disabledIcon = icon;
< prev index next >