Package java.awt

Examples of java.awt.Canvas


   * applet is destroyed.
   */
  public void init() {
    setLayout(new BorderLayout());
    try {
      display_parent = new Canvas() {
        public void addNotify() {
          super.addNotify();
          startLWJGL();
        }
        public void removeNotify() {
View Full Code Here


  boolean killswitch;
  public DisplayParentTest() throws LWJGLException {
    setTitle("LWJGL Display Parent Test");
    setSize(640, 320);
    setLayout(new GridLayout(1, 2));
    final Canvas display_parent = new Canvas();
    display_parent.setFocusable(true);
    display_parent.setIgnoreRepaint(true);
    add(display_parent);
    addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        killswitch = true;
      }
    });
    setResizable(true);
    setVisible(true);
    Display.setParent(display_parent);
    Display.setVSyncEnabled(true);
    Display.create();
    float angle = 0f;

    while (isVisible() && !killswitch) {
      angle += 1.0f;
      int width;
      int height;
      if (!Display.isFullscreen()) {
        width = display_parent.getWidth();
        height = display_parent.getHeight();
      } else {
        width = Display.getDisplayMode().getWidth();
        height = Display.getDisplayMode().getHeight();
      }
View Full Code Here

    System.out.println("*** init ***");

    setLayout(new BorderLayout());
    try {
      test = (Test) Class.forName(getParameter("test")).newInstance();
      Canvas canvas = (Canvas) test;
      canvas.setSize(getWidth(), getHeight());
      add(canvas);
    } catch (Exception e) {
      e.printStackTrace();
    }
    test.start();
View Full Code Here

   * applet is destroyed.
   */
  public void init() {
    setLayout(new BorderLayout());
    try {
      display_parent = new Canvas() {
        public void addNotify() {
          super.addNotify();
          startLWJGL();
        }
        public void removeNotify() {
View Full Code Here

            w.getContentPane().setBackground(new Color(0,0,0,255));

            //JAWTUtils my = new JAWTUtils();
            //w.getContentPane().add(my);
            Canvas c = new Canvas();
            w.getContentPane().add(c);

            w.setBounds(0,0,600,500);

            //System.out.println("getWindowHandle: " + JAWTUtils.getWindowHandle(c));
View Full Code Here

        final String overlayFactory = Platform.isWindows() ? "directdrawsink" : "xvimagesink";
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
               
                JFrame frame = new JFrame("Overlay Test");
                final Canvas canvas = new Canvas();
                canvas.setPreferredSize(new Dimension(640, 480));
                frame.add(canvas, BorderLayout.CENTER);               
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.pack();
                frame.setVisible(true);
                               
View Full Code Here

    Graphics2D g2 = (Graphics2D) result.getGraphics();
   
    g2.setColor(Color.WHITE);
    g2.fillRect(0, 0, width, height);
   
    Canvas canvas = new Canvas();
    Image tImage = image.getScaledInstance(width, height, quality);

    g2.drawImage(tImage, 0, 0, canvas);

    return result;
View Full Code Here

            // must be called after the fullscreen stuff, but before
            // getting our BufferStrategy
            setVisible(true);

            canvas = new Canvas() {
                @Override public void paint(Graphics g) {
                    // Try to redraw the front buffer when the OS says it has stomped
                    // on it, using the back buffer. Calling bufferStrategy.show() here
                    // sometimes throws NullPointerException or IllegalStateException,
                    // but otherwise seems to work fine.
View Full Code Here

        _platform = platform;

        _frame = new JFrame(config.appName);
        _frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Canvas canvas = new Canvas();
        canvas.setName("GLCanvas");
        int width = platform.graphics().ctx().scale.scaledCeil(config.width);
        int height = platform.graphics().ctx().scale.scaledCeil(config.height);
        canvas.setPreferredSize(new Dimension(width, height));
        _frame.getContentPane().add(canvas);

        canvas.addMouseListener(new MouseAdapter() {
            @Override public void mousePressed (MouseEvent e) {
                for (JavaNativeOverlay overlay : _overlays) {
                    final Component comp = overlay.component;
                    if (comp.contains(e.getX() - comp.getX(), e.getY() - comp.getY())) {
                        EventQueue.invokeLater(new Runnable() {
View Full Code Here

            }
        });
    }

    public CaptureTest() {
        canvas = new Canvas();
        canvas.setBackground(Color.black);

        contentPane = new JPanel();
        contentPane.setBackground(Color.black);
        contentPane.setLayout(new BorderLayout());
View Full Code Here

TOP

Related Classes of java.awt.Canvas

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.