home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / JBuilder8.iso / Solaris / resource / jre / demo / jfc / Java2D / src / java2d / Java2Demo.java < prev    next >
Encoding:
Java Source  |  2002-09-06  |  20.7 KB  |  540 lines

  1. /*
  2.  * Copyright (c) 2002 Sun Microsystems, Inc. All  Rights Reserved.
  3.  * 
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions
  6.  * are met:
  7.  * 
  8.  * -Redistributions of source code must retain the above copyright
  9.  *  notice, this list of conditions and the following disclaimer.
  10.  * 
  11.  * -Redistribution in binary form must reproduct the above copyright
  12.  *  notice, this list of conditions and the following disclaimer in
  13.  *  the documentation and/or other materials provided with the distribution.
  14.  * 
  15.  * Neither the name of Sun Microsystems, Inc. or the names of contributors
  16.  * may be used to endorse or promote products derived from this software
  17.  * without specific prior written permission.
  18.  * 
  19.  * This software is provided "AS IS," without a warranty of any kind. ALL
  20.  * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
  21.  * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
  22.  * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT
  23.  * BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT
  24.  * OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS
  25.  * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
  26.  * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
  27.  * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
  28.  * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN
  29.  * IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  30.  * 
  31.  * You acknowledge that Software is not designed, licensed or intended for
  32.  * use in the design, construction, operation or maintenance of any nuclear
  33.  * facility.
  34.  */
  35.  
  36. /*
  37.  * @(#)Java2Demo.java    1.41 02/06/13
  38.  */
  39.  
  40.  
  41. package java2d;
  42.  
  43. import java.awt.*;
  44. import java.awt.event.*;
  45. import java.awt.font.TextLayout;
  46. import java.awt.font.FontRenderContext;
  47. import javax.swing.*;
  48. import javax.swing.border.*;
  49.  
  50.  
  51. /**
  52.  * A demo that shows Java 2D(TM) features.
  53.  *
  54.  * @version @(#)Java2Demo.java    1.33 99/08/16
  55.  * @author Brian Lichtenwalter  (Framework, Intro, demos)
  56.  * @author Jim Graham           (demos)
  57.  */
  58. public class Java2Demo extends JPanel implements ItemListener, ActionListener
  59. {
  60.  
  61.     static Java2Demo demo;
  62.     static GlobalControls controls;
  63.     static MemoryMonitor memorymonitor;
  64.     static PerformanceMonitor performancemonitor;
  65.     static JTabbedPane tabbedPane;
  66.     static JLabel progressLabel;
  67.     static JProgressBar progressBar;
  68.     static DemoGroup group[];
  69.     static JCheckBoxMenuItem verboseCB;
  70.     static JCheckBoxMenuItem ccthreadCB;
  71.     static JCheckBoxMenuItem printCB = new JCheckBoxMenuItem("Default Printer");
  72.     static Color backgroundColor;
  73.     static JCheckBoxMenuItem memoryCB, perfCB;
  74.     static Intro intro;
  75.     static String[][] demos = 
  76.     { 
  77.         {"Arcs_Curves", "Arcs", "BezierAnim", "Curves", "Ellipses"},
  78.         {"Clipping", "Areas", "ClipAnim", "Intersection", "Text"},
  79.         {"Colors", "BullsEye", "ColorConvert", "Rotator3D"},
  80.         {"Composite", "ACimages", "ACrules", "FadeAnim"},
  81.         {"Fonts", "AttributedStr", "Highlighting", "Outline", "Tree"},
  82.         {"Images", "DukeAnim", "ImageOps", "JPEGFlip", "WarpImage"},
  83.         {"Lines", "Caps", "Dash", "Joins", "LineAnim"},
  84.         {"Mix", "Balls", "BezierScroller", "Stars3D"},
  85.         {"Paint", "GradAnim", "Gradient", "Texture", "TextureAnim"},
  86.         {"Paths", "Append", "CurveQuadTo", "FillStroke", "WindingRule"},
  87.         {"Transforms", "Rotate", "SelectTx", "TransformAnim"}
  88.     };
  89.  
  90.     private JCheckBoxMenuItem controlsCB;
  91.     private JMenuItem runMI, cloneMI, fileMI, backgMI;
  92.     private JMenuItem ccthreadMI, verboseMI;
  93.     private RunWindow runwindow;
  94.     private CloningFeature cloningfeature;
  95.     private JFrame rf, cf;
  96.     private GlobalPanel gp;
  97.  
  98.  
  99.  
  100.     /**
  101.      * Construct the Java2D Demo.
  102.      */
  103.     public Java2Demo() {
  104.  
  105.         setLayout(new BorderLayout());
  106.         setBorder(new EtchedBorder());
  107.  
  108.         add(createMenuBar(), BorderLayout.NORTH);
  109.  
  110.         // hard coding 14 = 11 demo dirs + images + fonts + Intro
  111.         progressBar.setMaximum(13);   
  112.         progressLabel.setText("Loading images");
  113.         new DemoImages();
  114.         progressBar.setValue(progressBar.getValue() + 1);
  115.         progressLabel.setText("Loading fonts");
  116.         new DemoFonts();
  117.         progressBar.setValue(progressBar.getValue() + 1);
  118.         progressLabel.setText("Loading Intro");
  119.         intro = new Intro();
  120.         progressBar.setValue(progressBar.getValue() + 1);
  121.         UIManager.put("Button.margin", new Insets(0,0,0,0));
  122.        
  123.         controls = new GlobalControls();
  124.         memorymonitor = new MemoryMonitor();
  125.         performancemonitor = new PerformanceMonitor();
  126.  
  127.         GlobalPanel gp = new GlobalPanel();
  128.  
  129.         tabbedPane = new JTabbedPane();
  130.         tabbedPane.setFont(new Font("serif", Font.PLAIN, 12));
  131.         tabbedPane.addTab("", new J2DIcon(), gp);
  132.         tabbedPane.addChangeListener(gp);
  133.  
  134.         group = new DemoGroup[demos.length];
  135.         for (int i = 0; i < demos.length; i++) {
  136.             progressLabel.setText("Loading demos." + demos[i][0]);
  137.             group[i] = new DemoGroup(demos[i][0]);
  138.             tabbedPane.addTab(demos[i][0], null);
  139.             progressBar.setValue(progressBar.getValue() + 1);
  140.         }
  141.  
  142.         add(tabbedPane, BorderLayout.CENTER);
  143.     }
  144.  
  145.  
  146.     private JMenuBar createMenuBar() {
  147.  
  148.         JPopupMenu.setDefaultLightWeightPopupEnabled(false);
  149.         JMenuBar menuBar = new JMenuBar();
  150.  
  151.         if (Java2DemoApplet.applet == null) {
  152.             JMenu file = (JMenu) menuBar.add(new JMenu("File"));
  153.             fileMI = (JMenuItem) file.add(new JMenuItem("Exit"));
  154.             fileMI.addActionListener(this);
  155.         }
  156.  
  157.         JMenu options = (JMenu) menuBar.add(new JMenu("Options"));
  158.  
  159.         controlsCB = (JCheckBoxMenuItem) options.add(
  160.                 new JCheckBoxMenuItem("Global Controls", true));
  161.         controlsCB.addItemListener(this);
  162.  
  163.         memoryCB = (JCheckBoxMenuItem) options.add(
  164.                 new JCheckBoxMenuItem("Memory Monitor", true));
  165.         memoryCB.addItemListener(this);
  166.  
  167.         perfCB = (JCheckBoxMenuItem) options.add(
  168.                 new JCheckBoxMenuItem("Performance Monitor", true));
  169.         perfCB.addItemListener(this);
  170.  
  171.         options.add(new JSeparator());
  172.  
  173.         ccthreadCB = (JCheckBoxMenuItem) options.add(
  174.                 new JCheckBoxMenuItem("Custom Controls Thread"));
  175.         ccthreadCB.addItemListener(this);
  176.  
  177.         printCB = (JCheckBoxMenuItem) options.add(printCB);
  178.  
  179.         verboseCB = (JCheckBoxMenuItem) options.add(
  180.                 new JCheckBoxMenuItem("Verbose"));
  181.  
  182.         options.add(new JSeparator());
  183.  
  184.         backgMI = (JMenuItem) options.add(new JMenuItem("Background Color"));
  185.     backgMI.addActionListener(this);
  186.  
  187.         runMI = (JMenuItem) options.add(new JMenuItem("Run Window"));
  188.         runMI.addActionListener(this);
  189.  
  190.         cloneMI = (JMenuItem) options.add(new JMenuItem("Cloning Feature"));
  191.         cloneMI.addActionListener(this);
  192.  
  193.         return menuBar;
  194.     }
  195.  
  196.  
  197.     public void createRunWindow() {
  198.         if (rf != null) {
  199.             rf.toFront();
  200.             return;
  201.         }
  202.         runwindow = new RunWindow();
  203.         WindowListener l = new WindowAdapter() {
  204.             public void windowClosing(WindowEvent e) {
  205.                 runwindow.stop(); rf.dispose();
  206.             }
  207.             public void windowClosed(WindowEvent e) { 
  208.                 rf = null;
  209.             }
  210.         };
  211.         rf = new JFrame("Run");
  212.         rf.addWindowListener(l);
  213.         rf.getContentPane().add("Center", runwindow);
  214.         rf.pack();
  215.         if (Java2DemoApplet.applet == null) {
  216.             rf.setSize(new Dimension(200,125));
  217.         } else {
  218.             rf.setSize(new Dimension(200,150));
  219.         }
  220.         rf.setVisible(true);
  221.     }
  222.  
  223.  
  224.     public void actionPerformed(ActionEvent e) {
  225.         if (e.getSource().equals(fileMI)) {
  226.             System.exit(0);
  227.         } else if (e.getSource().equals(runMI)) {
  228.             createRunWindow();
  229.         } else if (e.getSource().equals(cloneMI)) {
  230.             if (cloningfeature == null) {
  231.                 cloningfeature = new CloningFeature();
  232.                 WindowListener l = new WindowAdapter() {
  233.                     public void windowClosing(WindowEvent e) {
  234.                         cloningfeature.stop(); cf.dispose();
  235.                     }
  236.                     public void windowClosed(WindowEvent e) {
  237.                         cloningfeature = null;
  238.                     }
  239.                 };
  240.                 cf = new JFrame("Cloning Demo");
  241.                 cf.addWindowListener(l);
  242.                 cf.getContentPane().add("Center", cloningfeature);
  243.                 cf.pack();
  244.                 cf.setSize(new Dimension(320,330));
  245.                 cf.setVisible(true);
  246.             } else {
  247.                 cf.toFront();
  248.             }
  249.         } else if (e.getSource().equals(backgMI)) {
  250.         backgroundColor = 
  251.                 JColorChooser.showDialog(this, "Background Color", Color.white);
  252.             for (int i = 1; i < tabbedPane.getTabCount(); i++) {
  253.                 JPanel p = group[i-1].getPanel();
  254.                 for (int j = 0; j < p.getComponentCount(); j++) {
  255.                     DemoPanel dp = (DemoPanel) p.getComponent(j);
  256.                     if (dp.surface != null) {
  257.                         dp.surface.setBackground(backgroundColor);
  258.                     }
  259.                 } 
  260.             } 
  261.         }
  262.     }
  263.  
  264.  
  265.     public void itemStateChanged(ItemEvent e) {
  266.         if (e.getSource().equals(controlsCB)) {
  267.             if (controls.isVisible()) {
  268.                 controls.setVisible(false);
  269.                 Component cmps[] = controls.texturechooser.getComponents();
  270.                 for (int i = 0; i < cmps.length; i++) {
  271.                     cmps[i].setVisible(false);
  272.                 }
  273.             } else {
  274.                 controls.setVisible(true);
  275.                 Component cmps[] = controls.texturechooser.getComponents();
  276.                 for (int i = 0; i < cmps.length; i++) {
  277.                     cmps[i].setVisible(true);
  278.                 }
  279.             }
  280.         } else if (e.getSource().equals(memoryCB)) {
  281.             if (memorymonitor.isVisible()) {
  282.                 memorymonitor.setVisible(false);
  283.                 memorymonitor.surf.setVisible(false);
  284.                 memorymonitor.surf.stop();
  285.             } else {
  286.                 memorymonitor.setVisible(true);
  287.                 memorymonitor.surf.setVisible(true);
  288.                 memorymonitor.surf.start();
  289.             }
  290.         } else if (e.getSource().equals(perfCB)) {
  291.             if (performancemonitor.isVisible()) {
  292.                 performancemonitor.setVisible(false);
  293.                 performancemonitor.surf.setVisible(false);
  294.                 performancemonitor.surf.stop();
  295.             } else {
  296.                 performancemonitor.setVisible(true);
  297.                 performancemonitor.surf.setVisible(true);
  298.                 performancemonitor.surf.start();
  299.             }
  300.         } else if (e.getSource().equals(ccthreadCB)) {
  301.             int state = ccthreadCB.isSelected() ? 0 : 1;
  302.             if (tabbedPane.getSelectedIndex() != 0) {
  303.                 JPanel p = group[tabbedPane.getSelectedIndex()-1].getPanel();
  304.                 for (int i = 0; i < p.getComponentCount(); i++) {
  305.                     DemoPanel dp = (DemoPanel) p.getComponent(i);
  306.                     if (dp.ccc != null) {
  307.                         dp.ccc.handleThread(state);
  308.                     }
  309.                 } 
  310.             }
  311.         }
  312.         validate();
  313.     }
  314.  
  315.  
  316.     public void start() {
  317.         if (tabbedPane.getSelectedIndex() == 0) {
  318.             intro.start();
  319.         } else {
  320.             group[tabbedPane.getSelectedIndex()-1].setup(false);
  321.             if (memorymonitor.surf.thread == null && memoryCB.getState()) {
  322.                 memorymonitor.surf.start();
  323.             }
  324.             if (performancemonitor.surf.thread == null && perfCB.getState()) {
  325.                 performancemonitor.surf.start();
  326.             }
  327.         }
  328.     }
  329.  
  330.  
  331.     public void stop() {
  332.         if (tabbedPane.getSelectedIndex() == 0) {
  333.             intro.stop();
  334.         } else {
  335.             memorymonitor.surf.stop();
  336.             performancemonitor.surf.stop();
  337.             int i = tabbedPane.getSelectedIndex()-1;
  338.             group[i].shutDown(group[i].getPanel());
  339.         }
  340.     }
  341.  
  342.  
  343.     static void addToGridBag(JPanel panel, Component comp,
  344.             int x, int y, int w, int h, double weightx, double weighty) {
  345.  
  346.         GridBagLayout gbl = (GridBagLayout) panel.getLayout();
  347.         GridBagConstraints c = new GridBagConstraints();
  348.         c.fill = GridBagConstraints.BOTH;
  349.         c.gridx = x;
  350.         c.gridy = y;
  351.         c.gridwidth = w;
  352.         c.gridheight = h;
  353.         c.weightx = weightx;
  354.         c.weighty = weighty;
  355.         panel.add(comp);
  356.         gbl.setConstraints(comp, c);
  357.     }
  358.  
  359.  
  360.     /**
  361.      * The Icon for the Intro tab.
  362.      */
  363.     static class J2DIcon implements Icon {
  364.  
  365.         private static Color blue = new Color(94, 105, 176); 
  366.         private static Color black = new Color(20, 20, 20); 
  367.         private static Font font = new Font("serif", Font.BOLD, 12);
  368.         private FontRenderContext frc = new FontRenderContext(null,true,true);
  369.         private TextLayout tl = new TextLayout("Java2D", font, frc);
  370.  
  371.         public void paintIcon(Component c, Graphics g, int x, int y ) {
  372.             Graphics2D g2 = (Graphics2D) g;
  373.             g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
  374.                                 RenderingHints.VALUE_ANTIALIAS_ON);
  375.             g2.setFont(font);
  376.             if (tabbedPane.getSelectedIndex() == 0) {
  377.                 g2.setColor(blue);
  378.             } else {
  379.                 g2.setColor(black);
  380.             }
  381.             tl.draw(g2, x, y + 15);
  382.         }
  383.  
  384.         public int getIconWidth() {
  385.             return 40;
  386.         }
  387.  
  388.         public int getIconHeight() {
  389.             return 22;
  390.         }
  391.     }
  392.  
  393.  
  394.  
  395.     public static void main(String args[]) {
  396.         for (int i = 0; i < args.length; i++) {
  397.             if (args[i].startsWith("-h") || args[i].startsWith("-help")) {
  398.                 String s = "\njava -jar Java2Demo.jar -runs=5 -delay=5 -screen=5 " +
  399.                            "-antialias=true -rendering=true -texture=true " +
  400.                            "-composite=true -verbose -print -columns=3 " +
  401.                            "-buffers=5,10 -ccthread -zoom -maxscreen \n";
  402.                 System.out.println(s);
  403.                 s = "    -runs=5       Number of runs to execute\n" +
  404.                     "    -delay=5      Sleep amount between tabs\n" +
  405.                     "    -antialias=   true or false for antialiasing\n" +
  406.                     "    -rendering=   true or false for quality or speed\n" + 
  407.                     "    -texture=     true or false for texturing\n" +
  408.                     "    -composite=   true or false for compositing\n" +
  409.                     "    -verbose      output Surface graphic states \n" +
  410.                     "    -print        during run print the Surface, " +
  411.                     "use the Default Printer\n" +
  412.                     "    -columns=3    # of columns to use in clone layout \n" +
  413.                     "    -screen=3     demos all use this screen type \n" +
  414.                     "    -buffers=5,10 during run - clone to see screens " +
  415.                     "five through ten\n" +
  416.                     "    -ccthread     Invoke the Custom Controls Thread \n" +
  417.                     "    -zoom         mouseClick on surface for zoom in  \n" +
  418.                     "    -maxscreen    take up the entire monitor screen \n";
  419.                 System.out.println(s);
  420.                 s = "Examples : \n" +
  421.                     "    Print all of the demos : \n" +
  422.                     "        java -jar Java2Demo.jar -runs=1 -delay=60 -print \n" +
  423.                     "    Run zoomed in with custom control thread \n" +
  424.                     "        java -jar Java2Demo.jar -runs=10 -zoom -ccthread\n"; 
  425.                 System.out.println(s);
  426.                 System.exit(0);
  427.             } else if (args[i].startsWith("-delay=")) {
  428.                 String s = args[i].substring(args[i].indexOf('=')+1);
  429.                 RunWindow.delay = Integer.parseInt(s);
  430.             }
  431.         }
  432.  
  433.         JFrame frame = new JFrame("Java 2D(TM) Demo");
  434.         frame.getAccessibleContext().setAccessibleDescription("A sample application to demonstrate Java2D features");
  435.         int WIDTH = 400, HEIGHT = 200;
  436.         frame.setSize(WIDTH, HEIGHT);
  437.         Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
  438.         frame.setLocation(d.width/2 - WIDTH/2, d.height/2 - HEIGHT/2);
  439.         frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
  440.         frame.addWindowListener(new WindowAdapter() {
  441.             public void windowClosing(WindowEvent e) {System.exit(0);}
  442.             public void windowDeiconified(WindowEvent e) { 
  443.                 if (demo != null) { demo.start(); }
  444.             }
  445.             public void windowIconified(WindowEvent e) { 
  446.                 if (demo != null) { demo.stop(); }
  447.             }
  448.         });
  449.         JOptionPane.setRootFrame(frame);
  450.  
  451.         JPanel progressPanel = new JPanel() {
  452.             public Insets getInsets() {
  453.                 return new Insets(40,30,20,30);
  454.             }
  455.         };
  456.         progressPanel.setLayout(new BoxLayout(progressPanel, BoxLayout.Y_AXIS));
  457.         frame.getContentPane().add(progressPanel, BorderLayout.CENTER);
  458.  
  459.         Dimension labelSize = new Dimension(400, 20);
  460.         progressLabel = new JLabel("Loading, please wait...");
  461.         progressLabel.setAlignmentX(CENTER_ALIGNMENT);
  462.         progressLabel.setMaximumSize(labelSize);
  463.         progressLabel.setPreferredSize(labelSize);
  464.         progressPanel.add(progressLabel);
  465.         progressPanel.add(Box.createRigidArea(new Dimension(1,20)));
  466.  
  467.         progressBar = new JProgressBar();
  468.         progressBar.setStringPainted(true);
  469.         progressLabel.setLabelFor(progressBar);
  470.         progressBar.setAlignmentX(CENTER_ALIGNMENT);
  471.         progressBar.setMinimum(0);
  472.         progressBar.setValue(0);
  473.         progressBar.getAccessibleContext().setAccessibleName("Java2D loading progress");
  474.         progressPanel.add(progressBar);
  475.  
  476.         frame.setVisible(true);
  477.  
  478.         demo = new Java2Demo();
  479.  
  480.         frame.getContentPane().removeAll();
  481.         frame.getContentPane().setLayout(new BorderLayout());
  482.         frame.getContentPane().add(demo, BorderLayout.CENTER);
  483.         WIDTH = 730; HEIGHT = 570;
  484.         frame.setLocation(d.width/2 - WIDTH/2, d.height/2 - HEIGHT/2);
  485.         frame.setSize(WIDTH, HEIGHT);
  486.         frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  487.  
  488.         for (int i = 0; i < args.length; i++) {
  489.             String s = args[i].substring(args[i].indexOf('=')+1);
  490.             if (args[i].startsWith("-runs=")) {
  491.                 RunWindow.numRuns = Integer.parseInt(s);
  492.                 RunWindow.exit = true;
  493.                 demo.createRunWindow();
  494.             } else if (args[i].startsWith("-screen=")) {
  495.                 demo.controls.screenCombo.setSelectedIndex(Integer.parseInt(s));
  496.             } else if (args[i].startsWith("-antialias=")) {
  497.                 demo.controls.aliasCB.setSelected(s.endsWith("true"));
  498.             } else if (args[i].startsWith("-rendering=")) {
  499.                 demo.controls.renderCB.setSelected(s.endsWith("true"));
  500.             } else if (args[i].startsWith("-texture=")) {
  501.                 demo.controls.textureCB.setSelected(s.endsWith("true"));
  502.             } else if (args[i].startsWith("-composite=")) {
  503.                 demo.controls.compositeCB.setSelected(s.endsWith("true"));
  504.             } else if (args[i].startsWith("-verbose")) {
  505.                 demo.verboseCB.setSelected(true);
  506.             } else if (args[i].startsWith("-print")) {
  507.                 demo.printCB.setSelected(true);
  508.                 RunWindow.printCB.setSelected(true);
  509.             } else if (args[i].startsWith("-columns=")) {
  510.                 DemoGroup.columns = Integer.parseInt(s);
  511.             } else if (args[i].startsWith("-buffers=")) {
  512.                 // usage -buffers=3,10
  513.                 RunWindow.buffersFlag = true;
  514.                 int i1 = args[i].indexOf('=')+1;
  515.                 int i2 = args[i].indexOf(',');
  516.                 String s1 = args[i].substring(i1, i2);
  517.                 RunWindow.bufBeg = Integer.parseInt(s1);
  518.                 s1 = args[i].substring(i2+1, args[i].length());
  519.                 RunWindow.bufEnd = Integer.parseInt(s1);
  520.             } else if (args[i].startsWith("-ccthread")) {
  521.                 demo.ccthreadCB.setSelected(true);
  522.             } else if (args[i].startsWith("-zoom")) {
  523.                 RunWindow.zoomCB.setSelected(true);
  524.             } else if (args[i].startsWith("-maxscreen")) {
  525.                 frame.setLocation(0, 0);
  526.                 frame.setSize(d.width, d.height);
  527.             }
  528.         }
  529.  
  530.         frame.validate();
  531.         frame.repaint();
  532.         demo.requestDefaultFocus();
  533.         demo.start();
  534.  
  535.         if (RunWindow.exit) {
  536.             RunWindow.runB.doClick();
  537.         }
  538.     }
  539. }
  540.