Esempio n. 1
0
  private static void init() {
    // *** Create instructions for the user here ***
    String[] instructions = {
      "This is an AUTOMATIC test, simply wait until it is done.",
      "The result (passed or failed) will be shown in the",
      "message window below."
    };
    Sysout.createDialog();
    Sysout.printInstructions(instructions);

    Frame frame = new Frame("test for 6418028");
    frame.setLayout(new FlowLayout());
    Button btn1 = new Button("Button1");
    frame.add(btn1);
    TestButton btn2 = new TestButton("Button2");
    frame.add(btn2);
    frame.pack();
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent we) {
            we.getWindow().dispose();
          }
        });
    frame.setVisible(true);

    Util.waitForIdle(null);

    btn2.instrumentPeer();
    btn2.requestFocusInWindow();
    btn2.restorePeer();
    frame.dispose();
    RequestOnCompWithNullParent1.pass();
  } // End  init()
Esempio n. 2
0
 /*    */ public static void main(String[] args) /*    */ {
   /* 59 */ System.out.println("");
   /* 60 */ for (int i = 0; i < credits.length; i++) /* 61 */ System.out.println(credits[i]);
   /* 62 */ System.out.println("");
   /*    */ try
   /*    */ {
     /* 65 */ Frame f = new Frame(credits[0]);
     /* 66 */ f.setLayout(new GridLayout(credits.length, 1));
     /* 67 */ for (int i = 0; i < credits.length; i++) /* 68 */ f.add(new Label(credits[i], 1));
     /* 69 */ f.pack();
     /* 70 */ Toolkit t = f.getToolkit();
     /* 71 */ f.setLocation(
         (t.getScreenSize().width - f.getSize().width) / 2,
         (t.getScreenSize().height - f.getSize().height) / 2);
     /* 72 */ f.addWindowListener(
         new WindowAdapter() {
           /*    */ public void windowClosing(WindowEvent e) {
             /* 74 */ System.exit(0);
             /*    */ }
           /* 76 */ });
     /* 77 */ f.show();
     /*    */ }
   /*    */ catch (Exception localException) {
   }
   /*    */ }
Esempio n. 3
0
  @SuppressWarnings("deprecation")
  public static void main(String[] args) {
    System.out.println("");
    for (int i = 0; i < credits.length; i++) System.out.println(credits[i]);
    System.out.println("");

    try {
      java.awt.Frame f = new java.awt.Frame(credits[0]);
      f.setLayout(new java.awt.GridLayout(credits.length, 1));
      for (int i = 0; i < credits.length; i++)
        f.add(new java.awt.Label(credits[i], java.awt.Label.CENTER));
      f.pack();
      java.awt.Toolkit t = f.getToolkit();
      f.setLocation(
          (t.getScreenSize().width - f.getSize().width) / 2,
          (t.getScreenSize().height - f.getSize().height) / 2);
      f.addWindowListener(
          new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent e) {
              System.exit(0);
            } // end windowClosed
          }); // end WindowAdapter
      f.show();
    } // end try
    catch (Exception e) {
    }
  } // end main
  public static void main(String[] args) {
    // Initialization
    // Setting up GL
    GLProfile.initSingleton();
    GLProfile glp = GLProfile.getDefault();
    GLCapabilities caps = new GLCapabilities(glp);
    GLCanvas canvas = new GLCanvas(caps);

    // Making the AWT frame window
    Frame frame = new Frame("Assignment 1");
    frame.setSize(800, 600);
    frame.add(canvas);
    frame.setVisible(true);

    // Adding a render listener
    canvas.addGLEventListener(new Assignment1());

    // Fixes so the exit button exits the program
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
Esempio n. 5
0
  public static void main(String[] args) {
    Frame frame = new Frame("Simple JOGL Application");
    GLCanvas canvas = new GLCanvas();

    canvas.addGLEventListener(new Project1());
    frame.add(canvas);
    frame.setSize(600, 600);
    final Animator animator = new Animator(canvas);
    frame.addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(WindowEvent e) {
            new Thread(
                    new Runnable() {

                      public void run() {
                        animator.stop();
                        System.exit(0);
                      }
                    })
                .start();
          }
        });

    frame.setVisible(true);
    animator.start();
  }
Esempio n. 6
0
	public static void Field1(){
		fieldT.Label();
		fieldT.panel();
		f1.setSize(400, 400);
		
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); // 화면 픽셀 계산
		Dimension frm = f1.getSize();//창 크기 계산

		int xpos = (int)(screen.getWidth() / 2 - frm.getWidth() / 2); // 창 중앙 위치 계산
		int ypos = (int)(screen.getHeight() / 2 - frm.getHeight() / 2);


		f1.setLayout(new GridLayout(4, 4));// 프레임 레이아웃
		f1.setBackground(Color.cyan); //프레임 배경
		f1.addWindowListener(new WEventHandler());
		f1.addKeyListener(new KEventHandler());
		f1.setResizable(false);
		for(int i =0;i<4;i++){
			for(int j=0;j<4;j++){
				f1.add(p[i][j]);
			}
		}
		f1.setLocation(xpos, ypos);
		f1.setVisible(true);
	}
Esempio n. 7
0
 public void init() {
   frame = new Frame("PictureViewer");
   Panel pb = new Panel();
   Button select = new Button("choose pic");
   previous = new Button("previous");
   next = new Button("next");
   select.addActionListener(this);
   previous.addActionListener(this);
   next.addActionListener(this);
   pb.add(select);
   pb.add(previous);
   pb.add(next);
   mc = new MyCanvas();
   mc.setBackground(new Color(200, 210, 230));
   mc.addComponentListener(mc);
   frame.add(pb, "North");
   frame.add(mc, "Center");
   frame.setSize(360, 360);
   frame.setLocation(400, 200);
   frame.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   frame.setVisible(true);
   this.validateButton();
   filter = new MyFilter();
   fd_load = new FileDialog(frame, "Open file", FileDialog.LOAD);
   fd_load.setFilenameFilter(filter);
 }
 public static void main(java.lang.String[] args) {
   String className = null;
   try {
     System.err.println("logging is done using log4j.");
     final ICQMessagingTest_Applet applet = new ICQMessagingTest_Applet();
     className = cfg.REQPARAM_MESSAGING_NETWORK_IMPL_CLASS_NAME.trim();
     CAT.info("Instantiating class \"" + className + "\"...");
     try {
       applet.plugin = (MessagingNetwork) Class.forName(className).newInstance();
       applet.plugin.init();
     } catch (Throwable tr) {
       CAT.error("ex in main", tr);
       System.exit(1);
     }
     java.awt.Frame frame = new java.awt.Frame("MessagingTest");
     frame.addWindowListener(
         new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
             applet.quit();
           }
         });
     frame.add("Center", applet);
     frame.setSize(800, 650);
     frame.setLocation(150, 100);
     applet.init();
     frame.show();
     frame.invalidate();
     frame.validate();
     applet.start();
   } catch (Throwable tr) {
     CAT.error("exception", tr);
     System.exit(1);
   }
 }
Esempio n. 9
0
  public SingleARMarker(NyARParam i_cparam) throws Exception {
    JmfCaptureDeviceList devlist = new JmfCaptureDeviceList();
    this._ar_param = i_cparam;

    // キャプチャリソースの準備
    this._capture = devlist.getDevice(0);
    if (!this._capture.setCaptureFormat(SCREEN_X, SCREEN_Y, 30.0f)) {
      throw new NyARException();
    }
    this._capture.setOnCapture(this);
    this._cap_image = new JmfNyARRGBRaster(this._capture.getCaptureFormat());

    this._code_table[0] = NyARCode.createFromARPattFile(new FileInputStream(CARCODE_FILE1), 16, 16);
    this._code_table[1] = NyARCode.createFromARPattFile(new FileInputStream(CARCODE_FILE2), 16, 16);

    // OpenGLフレームの準備(OpenGLリソースの初期化、カメラの撮影開始は、initコールバック関数内で実行)
    Frame frame = new Frame("NyARToolkit[" + this.getClass().getName() + "]");
    GLCanvas canvas = new GLCanvas();
    frame.add(canvas);
    canvas.addGLEventListener(this);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // ウインドウサイズの調整
    frame.setVisible(true);
    Insets ins = frame.getInsets();
    frame.setSize(SCREEN_X + ins.left + ins.right, SCREEN_Y + ins.top + ins.bottom);
    canvas.setBounds(ins.left, ins.top, SCREEN_X, SCREEN_Y);
    return;
  }
Esempio n. 10
0
 public static void startMainThread(String s, String s1, String s2) {
   boolean flag = false;
   String s3 = s;
   Frame frame = new Frame("Minecraft");
   Canvas canvas = new Canvas();
   frame.setLayout(new BorderLayout());
   frame.add(canvas, "Center");
   canvas.setPreferredSize(new Dimension(854, 480));
   frame.pack();
   frame.setLocationRelativeTo(null);
   MinecraftImpl minecraftimpl = new MinecraftImpl(frame, canvas, null, 854, 480, flag, frame);
   Thread thread = new Thread(minecraftimpl, "Minecraft main thread");
   thread.setPriority(10);
   minecraftimpl.minecraftUri = "www.minecraft.net";
   if (s3 != null && s1 != null) {
     minecraftimpl.session = new Session(s3, s1);
   } else {
     minecraftimpl.session =
         new Session(
             (new StringBuilder())
                 .append("Player")
                 .append(System.currentTimeMillis() % 1000L)
                 .toString(),
             "");
   }
   if (s2 != null) {
     String as[] = s2.split(":");
     minecraftimpl.setServer(as[0], Integer.parseInt(as[1]));
   }
   frame.setVisible(true);
   frame.addWindowListener(new GameWindowListener(minecraftimpl, thread));
   thread.start();
 }
Esempio n. 11
0
 public void go() {
   f = new Frame("좋아하는 선수 고르기");
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           f.setVisible(false);
           f.dispose();
           System.exit(0);
         }
       });
   lstSunsu = new List(4, true); // 4개 보여주고,여러명 선택가능
   lstSunsu.addItemListener(this); // 2. step
   lstSunsu.add("==선수선택==");
   lstSunsu.add("조오련");
   lstSunsu.add("박찬호");
   lstSunsu.add("박세리");
   lstSunsu.add("안정환");
   lstSunsu.add("이천수");
   lstSunsu.add("이영표");
   lstSunsu.add("차범근");
   lstSunsu.add("김남일");
   lstSunsu.add("차두리");
   tf = new TextField();
   f.add(new Label("좋아하는 선수를 여러명 선택하세요"), "North");
   f.add(lstSunsu, "Center");
   f.add(tf, "South");
   f.setSize(200, 300);
   f.setVisible(true);
 }
  public static void main(final String[] argv) {
    final Frame frame = new Frame("Cg demo (runtime_ogl_vertex_fragment)");
    final GLCanvas canvas = new GLCanvas();
    canvas.addGLEventListener(new runtime_ogl_vertex_fragment());

    frame.add(canvas);
    frame.setSize(512, 512);
    final Animator animator = new Animator(canvas);
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(@SuppressWarnings("unused") final WindowEvent e) {
            // Run this on another thread than the AWT event queue to
            // make sure the call to Animator.stop() completes before
            // exiting
            new Thread(
                    new Runnable() {
                      public void run() {
                        animator.stop();
                        System.exit(0);
                      }
                    })
                .start();
          }
        });
    frame.setVisible(true);
    animator.start();

    // and all the rest happens in the display function...
  }
  public SimpleLiteMStandard(INyARMarkerSystemConfig i_config) throws NyARException {
    JmfCaptureDeviceList devlist = new JmfCaptureDeviceList();
    JmfCaptureDevice d = devlist.getDevice(0);
    d.setCaptureFormat(i_config.getScreenSize(), 30.0f);
    this._camera = new NyARJmfCamera(d); // create sensor system
    this._nyar = new NyARGlMarkerSystem(i_config); // create MarkerSystem
    this.ids[0] = this._nyar.addARMarker(ARCODE_FILE2, 16, 25, 80);
    this.ids[1] = this._nyar.addARMarker(ARCODE_FILE, 16, 25, 80);

    Frame frame = new Frame("NyARTK program");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    GLCanvas canvas = new GLCanvas();
    frame.add(canvas);
    canvas.addGLEventListener(this);
    NyARIntSize s = i_config.getNyARParam().getScreenSize();

    frame.setVisible(true);
    Insets ins = frame.getInsets();
    frame.setSize(s.w + ins.left + ins.right, s.h + ins.top + ins.bottom);
    canvas.setBounds(ins.left, ins.top, s.w, s.h);

    this._camera.start();
  }
Esempio n. 14
0
  public static void main(String[] args) {
    Frame fr = new Frame();
    fr.setSize(300, 300);
    fr.setVisible(true);
    fr.addWindowListener(new MyWindowListener());
    // fr.setIconImage(new ImageIcon( "e:\\3.gif").getImage());

  }
Esempio n. 15
0
 public static void main(String[] args) {
   Frame f = new Frame("Viewer");
   Viewer view = new Viewer();
   f.addWindowListener(view);
   f.add(view);
   f.setSize(300, 300);
   view.init();
   view.start();
   f.setVisible(true);
 }
  // Color gre;
  Rules(String se) {
    email = se;
    conti = new Button("Continue");
    rules = new Button("ClicK Here For Rules");
    p1 = new JOptionPane();
    Icon image = new ImageIcon("books.jpg");
    Icon image1 = new ImageIcon("girl.jpg");
    Icon image2 = new ImageIcon("uit.jpg");
    gl = new GridBagLayout();
    gbc = new GridBagConstraints();
    conti.addActionListener(this);
    rules.addActionListener(this);
    // gre=new Color(117,102,185);
    p = new Panel();
    p2 = new Panel();
    p3 = new Panel();
    p4 = new Panel();
    f = new Frame();
    pic = new JLabel(image);
    pic1 = new JLabel(image1);
    pic2 = new JLabel(image2);
    gbc.anchor = GridBagConstraints.SOUTHWEST;
    gl.setConstraints(pic1, gbc);
    gbc.anchor = GridBagConstraints.SOUTHEAST;
    gl.setConstraints(pic, gbc);
    Insets is = new Insets(30, 30, 30, 30);
    gbc.insets = is;
    gbc.ipadx = 14;
    gbc.ipady = 8;
    gl.setConstraints(rules, gbc);
    gl.setConstraints(conti, gbc);
    p2.setLayout(gl);
    p4.add(pic2);
    p2.add(pic);
    p3.setLayout(gl);
    p3.add(pic1);
    p.add(conti);
    p.add(rules);
    p.setLayout(gl);
    f.add(p4, "North");
    f.add(p3, "East");
    f.add(p2, "West");

    f.add(p, "Center");
    f.setTitle("RULES BOOK");
    // f.setBackground(gre);
    f.setVisible(true);
    f.setSize(900, 600);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            System.exit(0);
          }
        });
  }
Esempio n. 17
0
  public static void main(String[] args) {
    GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice displayDevice = environment.getDefaultScreenDevice();

    frame = new Frame(displayDevice.getDefaultConfiguration());
    frame.setBackground(new Color(0xCC, 0xCC, 0xCC));
    frame.setTitle("TestBug735Inv0AppletAWT");

    try {
      Class<?> c =
          Thread.currentThread()
              .getContextClassLoader()
              .loadClass(Bug735Inv0AppletAWT.class.getName());
      applet = (Bug735Inv0AppletAWT) c.newInstance();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    frame.setLayout(null);
    frame.add(applet);
    frame.pack();
    frame.setResizable(false);

    applet.init();

    Insets insets = frame.getInsets();
    int windowW = applet.width + insets.left + insets.right;
    int windowH = applet.height + insets.top + insets.bottom;
    frame.setSize(windowW, windowH);

    Rectangle screenRect = displayDevice.getDefaultConfiguration().getBounds();
    frame.setLocation(
        screenRect.x + (screenRect.width - applet.width) / 2,
        screenRect.y + (screenRect.height - applet.height) / 2);

    int usableWindowH = windowH - insets.top - insets.bottom;
    applet.setBounds(
        (windowW - applet.width) / 2,
        insets.top + (usableWindowH - applet.height) / 2,
        applet.width,
        applet.height);

    // This allows to close the frame.
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    applet.initGL();
    frame.setVisible(true);
    applet.start();
  }
Esempio n. 18
0
 public static void main(String[] args) {
   Frame f = new ToeTestNew();
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setSize(200, 100);
   f.setVisible(true);
 }
Esempio n. 19
0
 public static void main(String[] args) {
   // TODO 自动生成的方法存根
   Frame f = new DynamicEvents();
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setSize(300, 200);
   f.show();
 }
Esempio n. 20
0
 public static void main(String args[]) {
   Frame F = new Frame();
   Mouse1 P = new Mouse1(args[0]);
   F.add(P, BorderLayout.CENTER);
   F.setSize(500, 200);
   F.setVisible(true);
   F.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
 }
Esempio n. 21
0
 public void init() {
   // 以匿名内部类的形式来创建事件监听器对象
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           ta.append("用户试图关闭窗口!\n");
           System.exit(0);
         }
       });
   f.add(ta);
   f.pack();
   f.setVisible(true);
 }
Esempio n. 22
0
  /** Prepare the window that shall show the openGL content. */
  private void initWindow() {
    IllarionLookAndFeel.setupLookAndFeel();
    // create canvas that shall show the openGL content
    display = Graphics.getInstance().getRenderDisplay();
    display.getRenderArea().setBackground(Color.red);

    configChanged(IllaClient.getCfg(), CFG_RESOLUTION);

    final Component displayParent = display.getRenderArea();
    displayParent.setBackground(Color.green);
    displayParent.setVisible(true);

    // set up the window settings
    displayFrame = new Frame();
    displayFrame.setLayout(new BorderLayout(0, 0));
    displayFrame.setTitle(IllaClient.getVersionText());
    displayFrame.setBackground(Color.black);

    setIcon(displayFrame);

    displayFrame.addWindowListener(new ClientWindowListener());
    displayFrame.setResizable(false);
    displayFrame.setFocusable(false);
    displayFrame.setFocusableWindowState(true);
    displayFrame.setFocusTraversalKeysEnabled(false);
    displayParent.setFocusable(true);
    displayParent.setFocusTraversalKeysEnabled(false);

    // add the canvas to the window and make the canvas the openGL render
    // target.
    displayFrame.add(displayParent, BorderLayout.CENTER);
    displayFrame.pack();

    displayFrame.setLocationRelativeTo(null);
    displayFrame.setVisible(true);

    displayParent.requestFocusInWindow();

    final RenderDisplay usedDisplay = display;
    Graphics.getInstance()
        .getRenderManager()
        .addTask(
            new RenderTask() {
              @Override
              public boolean render(final int delta) {
                usedDisplay.startRendering();
                return false;
              }
            });
  }
Esempio n. 23
0
  public Bai2() {

    lbNumber1.setText("a =");
    lbNumber2.setText("b =");
    lbResult.setText("Kết quả:");
    txtNumber1.setText("0");
    txtNumber2.setText("0");
    txtResult.setText("0");
    btResult.setLabel("Thực hiện");
    choCalculator.add("Cộng");
    choCalculator.add("Trừ");
    choCalculator.add("Nhân");
    choCalculator.add("Chia");
    choCalculator.add("UCLN");
    choCalculator.add("BCNN");

    frMain.setBounds(100, 100, 400, 300);
    frMain.setBackground(Color.LIGHT_GRAY);
    frMain.setLayout(null);

    lbNumber1.setBounds(30, 50, 50, 20);
    lbNumber2.setBounds(30, 70, 50, 20);
    lbResult.setBounds(30, 140, 50, 20);

    choCalculator.setBounds(300, 70, 60, 20);

    btResult.setBounds(100, 100, 100, 20);

    txtNumber1.setBounds(100, 50, 150, 20);
    txtNumber2.setBounds(100, 70, 150, 20);
    txtResult.setBounds(100, 140, 150, 20);

    frMain.add(lbNumber1);
    frMain.add(lbNumber2);
    frMain.add(lbResult);
    frMain.add(txtNumber1);
    frMain.add(txtNumber2);
    frMain.add(txtResult);
    frMain.add(btResult);
    frMain.add(choCalculator);

    btResult.addActionListener(new ProcessButton());

    frMain.addWindowListener(
        new WindowAdapter() {
          public void windowsClosing(WindowEvent evt) {
            System.exit(0);
          }
        });
  }
Esempio n. 24
0
 public static void main(String[] args) {
   Counterl applet = new Counterl();
   Frame aFrame = new Frame("Counter1");
   aFrame.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   aFrame.add(applet, BorderLayout.CENTER);
   aFrame.setSize(300, 200);
   applet.init();
   applet.start();
   aFrame.setVisible(true);
 }
Esempio n. 25
0
  public static void main(String[] args) {
    Frame f = new Frame("hello window !");
    Panel p = new Panel();
    p.setSize(100, 100);
    // p.setb
    // f.setLayout(new FlowLayout());4
    f.add(p);
    f.setSize(500, 600);
    // f.add(new Label("hello"));
    // f.add(new Checkbox("check me"));
    // f.add(new Button("click me"));
    f.setVisible(true);

    f.addWindowListener(new DieuKhienCuaSo());
  }
Esempio n. 26
0
 /** ClipboardTest constructor comment. */
 public DictAWTView(String cfg) {
   super();
   IDictEngine e = org.dict.server.DatabaseFactory.getEngine(cfg);
   this.engine = e;
   f = new Frame("Dictionary lookup");
   f.setSize(600, 400);
   f.setLayout(new BorderLayout());
   ta = new TextArea();
   ta.setBackground(Color.white);
   ta.setForeground(Color.black);
   ta.addMouseListener(new ML());
   ta.addFocusListener(new FL());
   Button prev = new Button("History");
   prev.addActionListener(new History());
   mode = new Checkbox("Automatic", false);
   db = new Choice();
   for (int i = 0; i < e.getDatabases().length; i++) {
     db.add(e.getDatabases()[i].getName());
   }
   db.add("Any database");
   fontChoice = new Choice();
   fontChoice.add("serif");
   fontChoice.add("monospaced");
   fontChoice.add("dialog");
   fontChoice.addItemListener(new IL());
   sizeChoice = new Choice();
   sizeChoice.add("10");
   sizeChoice.add("12");
   sizeChoice.add("15");
   sizeChoice.addItemListener(new IL());
   Panel north = new Panel();
   north.setBackground(Color.lightGray);
   north.add(mode);
   north.add(db);
   north.add(fontChoice);
   north.add(sizeChoice);
   north.add(prev);
   f.add(north, "North");
   f.add(ta, "Center");
   f.addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setVisible(true);
 }
Esempio n. 27
0
  /** Builds the fractal. Draws the fractal on screen. Writes the fractal to image. */
  public BuildFractal() {

    pix = new int[width * height];
    int index = 0;
    for (int y = hOffset; y < height + hOffset; y++) {
      for (int x = wOffset; x < width + wOffset; x++) {
        pix[index] = Fractal.countVariable(x, y, 0xFF000000, variablesCollection);
        // pix[index] = Fractal.countDrippingMatrix(x, y);
        index++;
      }
      if (y % 1000 == 0) System.out.println("Lines " + y);
    }

    System.gc();

    i =
        Toolkit.getDefaultToolkit()
            .createImage(new MemoryImageSource(width, height, pix, 0, width));
    bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    bi.getGraphics().drawImage(i, 0, 0, null);

    Frame frame = new Frame("Fractal");
    frame.add(new DrawFractal(this));
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    frame.setSize(
        Toolkit.getDefaultToolkit().getScreenSize().width / 2,
        Toolkit.getDefaultToolkit().getScreenSize().height / 2);

    file = new File(imgName + ".jpg");
    try {
      ImageIO.write(bi, "jpg", file);
    } catch (IOException e) {
      e.printStackTrace();
    }

    frame.setVisible(true);

    while (file.canRead() == false) {}

    // System.exit(0);

  }
Esempio n. 28
0
  public static void main(String[] args) {
    Frame f = new JFrame("YAY it Works");
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            System.exit(0);
          }
        });
    JApplet applet = new midapp();
    ((RootPaneContainer) f).getContentPane().add("Center", applet);
    f.add(p2, BorderLayout.EAST);

    applet.init();
    f.pack();
    f.setSize(new Dimension(653, 437));
    f.setVisible(true);
  }
  public static void main(String[] args) {

    Frame frame = new Frame("Simple JOGL Application");

    // use GL2 profile since we only use the old OpenGL 2.x fixed function pipeline
    GLCapabilities capabilities = new GLCapabilities(GLProfile.get(GLProfile.GL2));

    // try to enable 2x anti aliasing - should be supported on most hardware
    //        capabilities.setNumSamples(2);
    //        capabilities.setSampleBuffers(true);

    GLCanvas canvas = new GLCanvas(capabilities);

    canvas.addGLEventListener(new SimpleJOGL());
    frame.add(canvas);

    // use JOGL's Animator utility for rendering
    final Animator animator = new Animator(canvas);

    // stop the Animator when we receive a window closing event
    frame.addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(WindowEvent e) {
            // Run this on another thread than the AWT event queue to
            // make sure the call to Animator.stop() completes before
            // exiting
            new Thread(
                    new Runnable() {

                      public void run() {
                        animator.stop();
                        System.exit(0);
                      }
                    })
                .start();
          }
        });

    // Center frame, set its size and start rendering
    frame.setSize(640, 480);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    animator.start();
  }
Esempio n. 30
0
  /**
   * This method is called if the applet is run as an standalone program. It creates a frame for the
   * applet and adds the applet to that frame.
   */
  public static void main(String args[]) {
    Evaluator a = new Evaluator();
    a.init();
    a.start();

    Frame f = new Frame("Evaluator");
    f.add("Center", a);
    f.setSize(400, 200);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    //		f.show();
    f.setVisible(true);
  }