< prev index next >
test/jdk/java/awt/Graphics/LCDTextAndGraphicsState.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 21,41 ****
* questions.
*/
/**
* @test
! * @bug 6576507
* @summary Both lines of text should be readable
! * @run main/manual=yesno LCDTextAndGraphicsState
*/
! import java.awt.*;
! import java.awt.geom.*;
public class LCDTextAndGraphicsState extends Component {
String text = "This test passes only if this text appears SIX TIMES";
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g.create();
g2d.setColor(Color.white);
g2d.fillRect(0,0,getSize().width, getSize().height);
--- 21,110 ----
* questions.
*/
/**
* @test
! * @bug 6576507 8202841
* @summary Both lines of text should be readable
! * @run main/manual LCDTextAndGraphicsState
*/
! import java.awt.Component;
! import java.awt.Graphics;
! import java.awt.Graphics2D;
! import java.awt.Color;
! import java.awt.RenderingHints;
! import java.awt.AlphaComposite;
! import java.awt.GradientPaint;
! import java.awt.Shape;
! import java.awt.Dimension;
! import java.awt.Frame;
! import java.awt.BorderLayout;
! import java.awt.Button;
! import java.awt.TextArea;
! import java.awt.FlowLayout;
! import java.awt.event.ActionEvent;
! import java.awt.event.ActionListener;
! import java.awt.geom.RoundRectangle2D;
public class LCDTextAndGraphicsState extends Component {
String text = "This test passes only if this text appears SIX TIMES";
+ private static Button passButton;
+ private static Button failButton;
+ private static TextArea instructions;
+ private static Frame frame;
+ private static Frame instructionFrame;
+ private static Thread mainThread = null;
+ private static int sleepTime = 300000;
+ private static int sleepLoopTime = 1000;
+ private static volatile boolean continueTest = true;
+
+ public void createAndShowInstructionFrame() {
+ passButton = new Button("Pass");
+ passButton.setEnabled(true);
+
+ failButton = new Button("Fail");
+ failButton.setEnabled(true);
+
+ instructions = new TextArea(5, 60);
+ instructions.setText(" This is a manual test\n\n" +
+ " 1) Press PASS if both lines of text are readable and appear 6 times\n" +
+ " 2) Press FAIL otherwise");
+
+ instructionFrame = new Frame("Test Instructions");
+ instructionFrame.add(passButton);
+ instructionFrame.add(failButton);
+ instructionFrame.add(instructions);
+ instructionFrame.setSize(200,200);
+ instructionFrame.setLayout(new FlowLayout());
+ instructionFrame.pack();
+ instructionFrame.setVisible(true);
+
+ passButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ dispose();
+ continueTest = false;
+ }
+ });
+
+ failButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ dispose();
+ continueTest = false;
+ throw new RuntimeException("Both lines of text are not readable or do not appear SIX TIMES !!!");
+ }
+ });
+ }
+
+ private static void dispose() {
+ frame.dispose();
+ instructionFrame.dispose();
+ }
+
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g.create();
g2d.setColor(Color.white);
g2d.fillRect(0,0,getSize().width, getSize().height);
*** 80,92 ****
public Dimension getPreferredSize() {
return new Dimension(500,600);
}
public static void main(String[] args) throws Exception {
! Frame f = new Frame("Composite and Text Test");
! f.add(new LCDTextAndGraphicsState(), BorderLayout.CENTER);
! f.pack();
! f.setVisible(true);
}
}
--- 149,182 ----
public Dimension getPreferredSize() {
return new Dimension(500,600);
}
+ public void createAndShowFrame() {
+ frame = new Frame("Composite and Text Test");
+ frame.add(new LCDTextAndGraphicsState(), BorderLayout.CENTER);
+ frame.setLocationRelativeTo(instructionFrame);
+ frame.pack();
+ frame.setVisible(true);
+ }
+
public static void main(String[] args) throws Exception {
! mainThread = Thread.currentThread();
! LCDTextAndGraphicsState lcdTest = new LCDTextAndGraphicsState();
! lcdTest.createAndShowInstructionFrame();
! lcdTest.createAndShowFrame();
!
! int remainingSleepTime = sleepTime;
! while(remainingSleepTime > 0 && continueTest) {
! mainThread.sleep(sleepLoopTime);
! remainingSleepTime -= sleepLoopTime;
! }
!
! if (continueTest) {
! lcdTest.dispose();
! throw new RuntimeException("Timed out after " + (sleepTime - remainingSleepTime) / 1000
! + " seconds");
! }
}
}
+
< prev index next >