Total members 11895 |It is currently Sun Dec 22, 2024 3:43 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





full Screen Graphics in java
Code:
import java.awt.*;
import java.awt.image.BufferStrategy;

public class 
ShowFullScreen {
  private static 
int counter 0;
    private static final 
int size 40;

   private static 
DisplayMode displayMode[] = new DisplayMode[] {
      new 
DisplayMode(640480320), new DisplayMode(640480160),
      new 
DisplayMode(64048080) };

  private static 
DisplayMode getBestDisplayMode(GraphicsDevice device) {
    for (
int z 0displayMode.lengthnz++) {
      
DisplayMode[] displayMode device.getDisplayModes();
      for (
int j 0displayMode.lengthkj++) {
        if (
displayMode[j].getWidth() == displayMode[z].getWidth()
          && 
displayMode[j].getHeight() ==displayMode[z].getHeight()
          && 
displayMode[j].getBitDepth(==displayMode[z].getBitDepth()){
          return 
displayMode[z];
        }
      }
    }
    return 
null;
  }
 public static 
void main(String args[]) {
    
GraphicsEnvironment ge GraphicsEnvironment.
          
getLocalGraphicsEnvironment();
    
GraphicsDevice gd ge.getDefaultScreenDevice();
    
DisplayMode dm gd.getDisplayMode();
    try {
      
Frame f = new Frame("Show full screen");
       
gd.setFullScreenWindow(f);
      if (
gd.isDisplayChangeSupported()) {
        
gd.setDisplayMode(getBestDisplayMode(gd));
      }
      
f.createBufferStrategy(5); 
      
Rectangle rect f.getBounds();
      
BufferStrategy bs f.getBufferStrategy();
      while (!
done()) {
        
Graphics g null;
        try {
          
bs.getDrawGraphics();
          if ((
counter <= 5)) { 
            
g.setColor(Color.white);
            
g.fillRect(00650,550);
          }
          
g.setColor(Color.red);
          
g.drawLine(countercounter 5rect.width,
            
rect.height);
    
bs.show();
        } 
finally {
          if (
!= null) {
            
g.dispose();
          }
        }
        try {
          
Thread.sleep(150);
        } catch (
Exception e) {
        }
      }
    } 
finally {}
    
System.exit(0);
  }
 private static 
boolean done() {
    return (
counter++ == size);
  }





Attachments:
File comment: the output
fullScreen.gif
fullScreen.gif [ 2.83 KiB | Viewed 5933 times ]

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada
Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : full Screen Graphics
 Full Screen graphics (Lesson 2).     -  
 Splash Screen     -  
 Screen Capture and multicast     -  
 My Header is Not Fitting to the Screen!     -  
 Graphics commands list in C++     -  
 Flashing Graphics animations with threads     -  
 MacBook Pro Turned Into a Blue Screen     -  
 double buffering-applet animates graphics     -  
 how to screen scrape or grab some parts of a website?     -  
 getting a full line input     -  



Topic Tags

Java Graphics
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com