当前位置: 首页>>代码示例>>Java>>正文


Java Canvas.setIgnoreRepaint方法代码示例

本文整理汇总了Java中java.awt.Canvas.setIgnoreRepaint方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.setIgnoreRepaint方法的具体用法?Java Canvas.setIgnoreRepaint怎么用?Java Canvas.setIgnoreRepaint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Canvas的用法示例。


在下文中一共展示了Canvas.setIgnoreRepaint方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import java.awt.Canvas; //导入方法依赖的package包/类
/**
 * initialise applet by adding a canvas to it, this canvas will start the LWJGL Display and game loop
 * in another thread. It will also stop the game loop and destroy the display on canvas removal when
 * applet is destroyed.
 */
public void init() {
	setLayout(new BorderLayout());
	try {
		display_parent = new Canvas() {
			public void addNotify() {
				super.addNotify();
				startLWJGL();
			}
			public void removeNotify() {
				stopLWJGL();
				super.removeNotify();
			}
		};
		display_parent.setSize(getWidth(),getHeight());
		add(display_parent);
		display_parent.setFocusable(true);
		display_parent.requestFocus();
		display_parent.setIgnoreRepaint(true);
		setVisible(true);
	} catch (Exception e) {
		System.err.println(e);
		throw new RuntimeException("Unable to create display");
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:GameApplet.java

示例2: init

import java.awt.Canvas; //导入方法依赖的package包/类
/**
 * initialise applet by adding a canvas to it, this canvas will start the LWJGL Display and game loop
 * in another thread. It will also stop the game loop and destroy the display on canvas removal when
 * applet is destroyed.
 */
public void init() {
	setLayout(new BorderLayout());
	try {
		display_parent = new Canvas() {
			public void addNotify() {
				super.addNotify();
				startLWJGL();
			}
			public void removeNotify() {
				stopLWJGL();
				super.removeNotify();
			}
		};
		display_parent.setSize(getWidth(),getHeight());
		add(display_parent);
		display_parent.setFocusable(true);
		display_parent.requestFocus();
		display_parent.setIgnoreRepaint(true);
		//setResizable(true);
		setVisible(true);
	} catch (Exception e) {
		System.err.println(e);
		throw new RuntimeException("Unable to create display");
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:GearsApplet.java

示例3: init

import java.awt.Canvas; //导入方法依赖的package包/类
/**
 * @see java.applet.Applet#init()
 */
public void init() {
   removeAll();
   setLayout(new BorderLayout());
   setIgnoreRepaint(true);

   try {
      Game game = (Game) Class.forName(getParameter("game")).newInstance();
      
      container = new Container(game);
      canvas = new ContainerPanel(container);
      displayParent = new Canvas() {
         public final void addNotify() {
            super.addNotify();
            startLWJGL();
         }
         public final void removeNotify() {
            destroyLWJGL();
            super.removeNotify();
         }

      };

      displayParent.setSize(getWidth(), getHeight());
      add(displayParent);
      displayParent.setFocusable(true);
      displayParent.requestFocus();
      displayParent.setIgnoreRepaint(true);
      setVisible(true);
   } catch (Exception e) {
      Log.error(e);
      throw new RuntimeException("Unable to create game container");
   }
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:37,代码来源:AppletGameContainer.java

示例4: createUI

import java.awt.Canvas; //导入方法依赖的package包/类
private void createUI(final Composite parent) {

		_swtContainer = new Composite(parent, SWT.EMBEDDED | SWT.NO_BACKGROUND);
		final Frame awtContainer = SWT_AWT.new_Frame(_swtContainer);

		final Canvas awtCanvas = new Canvas();
		awtContainer.setLayout(new BorderLayout());
		awtCanvas.setIgnoreRepaint(true);

		awtContainer.add(awtCanvas);
		awtCanvas.setFocusable(true);
		awtCanvas.requestFocus();

		awtContainer.addComponentListener(new ComponentAdapter() {

			@Override
			public void componentResized(final ComponentEvent e) {

				/*
				 * Render map otherwise a black screen is displayed until the map is moved
				 */
				final Map map = _mapApp.getMap();

				// check if initialized
				if (map == null) {
					return;
				}

				map.render();
			}
		});

		_mapApp = Map25App.createMap(this, _state, awtCanvas);
	}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:35,代码来源:Map25View.java

示例5: Java2DFrame

import java.awt.Canvas; //导入方法依赖的package包/类
public Java2DFrame(Spark game)
{
	super(GraphicsEnvironment.getLocalGraphicsEnvironment()
			.getDefaultScreenDevice().getDefaultConfiguration());

	this.game = game;

	ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
	gd = ge.getDefaultScreenDevice();
	gc = gd.getDefaultConfiguration();

	setTitle("Spark");

	setFocusable(false);
	setBackground(Color.black);
	setFocusTraversalKeysEnabled(false);
	setResizable(false);
	setIgnoreRepaint(true);

	if (game.gameOptions.displayWindowed == false)
		setUndecorated(true);

	setIconImage(new ImageIcon("spark/images/imgIcon.gif").getImage());

	// Invisible cursor
	int[] pixels = new int[16 * 16];
	Image image = Toolkit.getDefaultToolkit().createImage(
			new MemoryImageSource(16, 16, pixels, 0, 16));
	Cursor transparentCursor = Toolkit.getDefaultToolkit()
			.createCustomCursor(image, new Point(0, 0), "invisibleCursor");

	setCursor(transparentCursor);

	drawCanvas = new Canvas(gc);
	drawCanvas.setPreferredSize(new Dimension(game.ResolutionX,
			game.ResolutionY));
	drawCanvas.setBackground(Color.black);
	drawCanvas.setIgnoreRepaint(true);
	drawCanvas.setFocusTraversalKeysEnabled(false);
	drawCanvas.addKeyListener(this);
	drawCanvas.addMouseListener(this);
	drawCanvas.addMouseWheelListener(this);
	drawCanvas.setCursor(transparentCursor);
	add(drawCanvas);

	addWindowListener(this);

	pack();
	setLocationRelativeTo(null);

	if (game.gameOptions.displayWindowed == false)
	{
		setFullScreen();
	}

	setVisible(true);

	drawCanvas.requestFocus();
}
 
开发者ID:TheRemote,项目名称:Spark,代码行数:60,代码来源:Java2DFrame.java

示例6: DisplayParentTest

import java.awt.Canvas; //导入方法依赖的package包/类
public DisplayParentTest() throws LWJGLException {
    setTitle( "LWJGL Display Parent Test" );
    setSize( 640, 320 );
    setLayout( new GridLayout( 1, 2 ) );
    final Canvas display_parent = new Canvas();
    final Canvas display_parent_2 = new Canvas();
    display_parent.setFocusable( true );
    display_parent.setIgnoreRepaint( true );
    add( display_parent );
    display_parent_2.setFocusable( true );
    display_parent_2.setIgnoreRepaint( true );
    add( display_parent_2 );
    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();
        }
        if ( width < 1 || height < 1 ) {
            continue;
        }
        glViewport( 0, 0, width, height );
        glClearColor( 0.0f, 1.0f, 0.0f, 1.0f );
        glClear( GL_COLOR_BUFFER_BIT );
        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        gluOrtho2D( 0.0f, (float) width, 0.0f, (float) height );
        glMatrixMode( GL_MODELVIEW );
        glPushMatrix();
        glTranslatef( width / 2.0f, height / 2.0f, 0.0f );
        glRotatef( 2 * angle, 0f, 0f, -1.0f );
        glRectf( -50.0f, -50.0f, 50.0f, 50.0f );
        glPopMatrix();
        Display.update();
        while ( Keyboard.next() ) {
            // closing on ESCAPE
            if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() ) {
                Display.destroy();
                dispose();
                break;
            }
            if ( Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState() ) {
                Mouse.setGrabbed( !Mouse.isGrabbed() );
            }
            if ( Keyboard.getEventKey() == Keyboard.KEY_F && Keyboard.getEventKeyState() ) {
                Display.setFullscreen( !Display.isFullscreen() );
            }
            if ( Keyboard.getEventKey() == Keyboard.KEY_4 && Keyboard.getEventKeyState() ) {
                if ( Display.getParent() == display_parent ) {
                    Display.setParent( display_parent_2 );
                }
                else {
                    Display.setParent( display_parent );
                }
            }
        }
        while ( Mouse.next() ) {
            System.out.println( "Mouse.getEventX() = " + Mouse.getEventX() + " | Mouse.getEventY() = " + Mouse.getEventY() );
        }
    }
    Display.destroy();
    dispose();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:81,代码来源:DisplayParentTest.java

示例7: DisplayParentTest

import java.awt.Canvas; //导入方法依赖的package包/类
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();
			}

			if(width < 1 || height < 1) {
				continue;
			}

			glViewport(0, 0, width, height);
			glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
			glClear(GL_COLOR_BUFFER_BIT);
			glMatrixMode(GL_PROJECTION);
			glLoadIdentity();
			gluOrtho2D(0.0f, (float) width, 0.0f, (float) height);
			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();
			glTranslatef(width / 2.0f, height / 2.0f, 0.0f);
			glRotatef(2*angle, 0f, 0f, -1.0f);
			glRectf(-50.0f, -50.0f, 50.0f, 50.0f);
			glPopMatrix();
			Display.update();
			while(Keyboard.next()) {
				// closing on ESCAPE
				if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState()) {
					Display.destroy();
					dispose();
					break;
				}

				if(Keyboard.getEventKey() == Keyboard.KEY_SPACE && Keyboard.getEventKeyState()) {
					Mouse.setGrabbed(!Mouse.isGrabbed());
				}
				if(Keyboard.getEventKey() == Keyboard.KEY_F && Keyboard.getEventKeyState()) {
					Display.setFullscreen(!Display.isFullscreen());
				}
			}
/*			while (Mouse.next()) {
System.out.println("				Mouse.getEventX() = " + 				Mouse.getEventX() + " | Mouse.getEventY() = " + Mouse.getEventY());
			}*/
		}
		Display.destroy();
		dispose();
	}
 
开发者ID:mleoking,项目名称:PhET,代码行数:72,代码来源:DisplayParentTest.java

示例8: QuickFrame

import java.awt.Canvas; //导入方法依赖的package包/类
/**
	 * Builds a new frame.
	 * 
	 * @throws IllegalArgumentException
	 * 		Problem while accessing the game data.
	 * @throws SecurityException
	 * 		Problem while accessing the game data.
	 * @throws ParserConfigurationException
	 * 		Problem while accessing the game data.
	 * @throws SAXException
	 * 		Problem while accessing the game data.
	 * @throws IOException
	 * 		Problem while accessing the game data.
	 * @throws IllegalAccessException
	 * 		Problem while accessing the game data.
	 * @throws NoSuchFieldException
	 * 		Problem while accessing the game data.
	 * @throws ClassNotFoundException
	 * 		Problem while accessing the game data.
	 */
	public QuickFrame() throws IllegalArgumentException, SecurityException, ParserConfigurationException, SAXException, IOException, IllegalAccessException, NoSuchFieldException, ClassNotFoundException
	{	// init
		super("TBB v."+GameData.VERSION+" (Quicklaunch)");

		// panel size
		Dimension contentDimension = Configuration.getVideoConfiguration().getPanelDimension();
		
	    // create canvas
	    canvas = new Canvas();
	    canvas.setIgnoreRepaint(true);
//	    canvas.setSize(dim);
	    canvas.setMinimumSize(contentDimension);
	    canvas.setPreferredSize(contentDimension);
	    canvas.setMaximumSize(contentDimension);
	    add(canvas);
		
		// create progress bar
		remove(canvas);
		loadProgressBar = new JProgressBar();
//		loadProgressBar.setSize(dim);
		loadProgressBar.setMinimumSize(contentDimension);
		loadProgressBar.setPreferredSize(contentDimension);
		loadProgressBar.setMaximumSize(contentDimension);
		loadProgressBar.setStringPainted(true);
		loadProgressBar.setFont(GuiConfiguration.getMiscConfiguration().getFont().deriveFont(contentDimension.height/2f));
		getContentPane().add(loadProgressBar);
		
		// tournament
		QuickStartConfiguration quickStartConfiguration = Configuration.getGameConfiguration().getQuickStartConfiguration(); 
		tournament = quickStartConfiguration.loadQuickstart();
		List<Profile> selectedProfiles = new ArrayList<Profile>();
		ProfilesSelection profilesSelection = quickStartConfiguration.getProfilesSelection();
		selectedProfiles = ProfileLoader.loadProfiles(profilesSelection);
		tournament.setProfiles(selectedProfiles);
		tournament.init();
	    tournament.progress();
	    
	    // match
	    Match match = tournament.getCurrentMatch();
	    match.progress();
		       
	    //round
	    round = match.getCurrentRound();
	    round.setPanel(this);
		int limit = round.getProfiles().size()+3;
		loadProgressBar.setMinimum(0);
		loadProgressBar.setMaximum(limit);		
	}
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:69,代码来源:QuickFrame.java

示例9: Screen

import java.awt.Canvas; //导入方法依赖的package包/类
/**
 * Constructs a new Screen object with the given width, height and title.
 * The screen can be resized.
 * @param width The screen width
 * @param height The screen height
 * @param title The screen title
 */
public Screen(final int width, final int height, final String title) {
	frame = new JFrame(title);
	canvas = new Canvas();
	mouse = new Mouse();
	keyboard = new Keyboard();
	
	final WindowAdapter closingAdapter = new WindowAdapter() {
		@Override
		public void windowClosing(final WindowEvent w) {
			close();
			
			if (closingCallback != null) {
				closingCallback.run();
			}
		}
	};
	final ComponentAdapter resizeAdapter = new ComponentAdapter() {
		@Override
		public void componentResized(final ComponentEvent c) {
			calculateViewport();
			
			if (redrawOnResize) {
				redraw();
			}
		}
	};
	
	open = true;
	initialWidth = canvasWidth = renderWidth = width;
	initialHeight = canvasHeight = renderHeight = height;
	resizeBehavior = ResizeBehavior.STRETCH;
	
	canvas.setPreferredSize(new Dimension(width, height));
	canvas.setIgnoreRepaint(true);
	canvas.addMouseListener(mouse);
	canvas.addMouseMotionListener(mouse);
	canvas.addMouseWheelListener(mouse);
	canvas.addKeyListener(keyboard);
	
	frame.addMouseListener(mouse);
	frame.addMouseMotionListener(mouse);
	frame.addMouseWheelListener(mouse);
	frame.addKeyListener(keyboard);
	frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	frame.setIgnoreRepaint(true);
	frame.addWindowListener(closingAdapter);
	frame.addComponentListener(resizeAdapter);
	frame.add(canvas);
	frame.pack();
	frame.setLocationRelativeTo(null);
}
 
开发者ID:Sogomn,项目名称:spjgl,代码行数:59,代码来源:Screen.java


注:本文中的java.awt.Canvas.setIgnoreRepaint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。