Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/misctests/fpustack/GraphApplet.java
40948 views
/*1* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @key headful26*27* @summary converted from VM Testbase jit/misctests/fpustack.28* VM Testbase keywords: [jit, desktop, jdk_desktop, quick]29*30* @library /vmTestbase31* /test/lib32* @run main/othervm jit.misctests.fpustack.GraphApplet33*/3435package jit.misctests.fpustack;3637import java.util.*;38import java.awt.*;39import java.applet.Applet;40import nsk.share.TestFailure;414243public class GraphApplet extends Applet {44private GraphPanel panel;45private boolean isApplet = true;46private boolean initialized = false;4748/**49** main method for testing that class50**51**/52public static void main( String[] args ) {53Frame f = new Frame("GraphApplet");54GraphApplet app = new GraphApplet();55app.isApplet = false;56app.setSize(600,400);57f.setLayout( new BorderLayout() );58f.add("Center",app);59f.setSize(600,400);6061app.init();62// f.pack();63f.show(true);64app.start();6566try {67Thread.currentThread().sleep(5*1000);68} catch (InterruptedException e) {69}7071f.show(false);72app.stop();73f.dispose();74return;75}7677/**78** init-Method in applet's lifecycle.79** the graphic panel is build up and the date is filled.80**/81public synchronized void init() {82System.out.println( "GraphApplet : init");83setLayout(new BorderLayout());8485panel = new GraphPanel(this, new layout() );86fill( panel );87add("Center", panel);88Panel p = new Panel();89add("South", p);90initialized = true;91}9293public synchronized void start() {94System.out.println( "GraphApplet : start");95panel.formatNodes();96}97public synchronized void stop() {98initialized = false;99System.out.println( "GraphApplet : stop");100}101102public synchronized void destroy() {103System.out.println( "GraphApplet : destroy");104}105106/**107** paint the Applet108**/109public synchronized void paint(Graphics g) {110try {111while ( ! initialized )112Thread.currentThread().sleep(5);113} catch (InterruptedException e) {}114if (g instanceof PrintGraphics )115System.out.println( "printing GraphApplet ...");116}117118public synchronized void print(Graphics g) {119try {120while ( ! initialized )121Thread.currentThread().sleep(5);122} catch (InterruptedException e) {}123System.out.println( "Print Applet " + g);124panel.print(g);125}126127public void print() {128// System.out.println( "Print Applet");129Toolkit kit = getToolkit();130try {131132PrintJob job = kit.getPrintJob( new Frame("x"), "PrintableFrame print job",133null);134// do the printing if the user didn't cancel the print job135if (job != null) {136Graphics g = job.getGraphics();137printAll(g); // not paint(g)138g.dispose(); // finish with this page139job.end(); // finish with the PrintJob140}141} catch (Exception ex) {142System.out.println( "print exception " + ex);143}144}145146/**147**148** @param panel the container for nodes149**150**/151private void152fill( GraphPanel panel ) {153panel.addNodes("Node1", "Node2", "Node3" );154}155}156157158