资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 编程开发 >
Advertisement
文章正文

java 程序一出来就满屏 _编程

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   
  • J2ME Wireless Toolkit 2.2 新改进  
  • 一个MIDP俄罗斯方块游戏的设计和实现  
  • PicoContainer-One minute description  
  • java.util.Collections.sort(List list)与Comparable,Comparator 接口  
  • 配置Tomcat5.5和IIS5之解疑  
  • JBuilder2005 下 jsp2.0 初体验  
  • Java中的异步网络编程  
  • Java异常学习心得,欢迎拍砖  
  • J2ME伪高手先锋开讲—扫雷游戏的设计  
  • Eclipse与插件(tomcatPlugin Lomboz easyStruts)安装  
  • 页面导航:

    正文内容:
    package display;

    /**
    * @author administrator
    *
    * todo to change the template for this generated type comment go to
    * window - preferences - java - code style - code templates
    */
    import java.awt.*;
    import java.awt.image.bufferstrategy;
    import java.awt.image.bufferedimage;
    import java.lang.reflect.invocationtargetexception;
    import javax.swing.jframe;

    /**
    the screenmanager class manages initializing and displaying
    full screen graphics modes.
    */
    public class screenmanager {

    private graphicsdevice device;

    /**
    creates a new screenmanager object.
    */
    public screenmanager() {
    graphicsenvironment environment =
    graphicsenvironment.getlocalgraphicsenvironment();
    device = environment.getdefaultscreendevice();
    }

    /**
    returns a list of compatible display modes for the
    default device on the system.
    */
    public displaymode[] getcompatibledisplaymodes() {
    return device.getdisplaymodes();
    }

    /**
    returns the first compatible mode in a list of modes.
    returns null if no modes are compatible.
    */
    public displaymode findfirstcompatiblemode(
    displaymode modes[])
    {
    displaymode goodmodes[] = device.getdisplaymodes();
    for (int i = 0; i < modes.length; i++) {
    for (int j = 0; j < goodmodes.length; j++) {
    if (displaymodesmatch(modes[i], goodmodes[j])) {
    return modes[i];
    }
    }

    }

    return null;
    }

    /**
    returns the current display mode.
    */
    public displaymode getcurrentdisplaymode() {
    return device.getdisplaymode();
    }

    /**
    determines if two display modes "match". two display
    modes match if they have the same resolution, bit depth,
    and refresh rate. the bit depth is ignored if one of the
    modes has a bit depth of displaymode.bit_depth_multi.
    likewise, the refresh rate is ignored if one of the
    modes has a refresh rate of
    displaymode.refresh_rate_unknown.
    */
    public boolean displaymodesmatch(displaymode mode1,
    displaymode mode2)

    {
    if (mode1.getwidth() != mode2.getwidth() ||
    mode1.getheight() != mode2.getheight())
    {
    return false;
    }

    if (mode1.getbitdepth() != displaymode.bit_depth_multi &&
    mode2.getbitdepth() != displaymode.bit_depth_multi &&
    mode1.getbitdepth() != mode2.getbitdepth())
    {
    return false;
    }

    if (mode1.getrefreshrate() !=
    displaymode.refresh_rate_unknown &&
    mode2.getrefreshrate() !=
    displaymode.refresh_rate_unknown &&
    mode1.getrefreshrate() != mode2.getrefreshrate())
    {
    return false;
    }

    return true;
    }

    /**
    enters full screen mode and changes the display mode.
    if the specified display mode is null or not compatible
    with this device, or if the display mode cannot be
    changed on this system, the current display mode is used.
    <p>
    the display uses a bufferstrategy with 2 buffers.
    */
    public void setfullscreen(displaymode displaymode) {
    final jframe frame = new jframe();
    frame.setdefaultcloseoperation(jframe.exit_on_close);
    frame.setundecorated(true);
    frame.setignorerepaint(true);
    frame.setresizable(false);

    device.setfullscreenwindow(frame);

    if (displaymode != null &&
    device.isdisplaychangesupported())
    {
    try {
    device.setdisplaymode(displaymode);
    }
    catch (illegalargumentexception ex) { }
    // fix for mac os x
    frame.setsize(displaymode.getwidth(),
    displaymode.getheight());
    }
    // avoid potential deadlock in 1.4.1_02
    try {
    eventqueue.invokeandwait(new runnable() {
    public void run() {
    frame.createbufferstrategy(2);
    }
    });
    }
    catch (interruptedexception ex) {
    // ignore
    }
    catch (invocationtargetexception ex) {
    // ignore
    }
    }

    /**
    gets the graphics context for the display. the
    screenmanager uses double buffering, so applications must
    call update() to show any graphics drawn.
    <p>
    the application must dispose of the graphics object.
    */
    public graphics2d getgraphics() {
    window window = device.getfullscreenwindow();
    if (window != null) {
    bufferstrategy strategy = window.getbufferstrategy();
    return (graphics2d)strategy.getdrawgraphics();
    }
    else {
    return null;
    }
    }

    /**
    updates the display.
    */
    public void update() {
    window window = device.getfullscreenwindow();
    if (window != null) {
    bufferstrategy strategy = window.getbufferstrategy();
    if (!strategy.contentslost()) {
    strategy.show();
    }
    }
    // sync the display on some systems.
    // (on linux, this fixes event queue problems)
    toolkit.getdefaulttoolkit().sync();
    }

    /**
    returns the window currently used in full screen mode.
    returns null if the device is not in full screen mode.
    */
    public jframe getfullscreenwindow() {
    return (jframe)device.getfullscreenwindow();
    }

    /**
    returns the width of the window currently used in full
    screen mode. returns 0 if the device is not in full
    screen mode.
    */
    public int getwidth() {
    window window = device.getfullscreenwindow();
    if (window != null) {
    return window.getwidth();
    }
    else {
    return 0;
    }
    }

    /**
    returns the height of the window currently used in full
    screen mode. returns 0 if the device is not in full
    screen mode.
    */
    public int getheight() {
    window window = device.getfullscreenwindow();
    if (window != null) {
    return window.getheight();
    }
    else {
    return 0;
    }
    }

    /**
    restores the screens display mode.
    */
    public void restorescreen() {
    window window = device.getfullscreenwindow();
    if (window != null) {
    window.dispose();
    }
    device.setfullscreenwindow(null);
    }

    /**
    creates an image compatible with the current display.
    */
    public bufferedimage createcompatibleimage(int w, int h,
    int transparancy)
    {
    window window = device.getfullscreenwindow();
    if (window != null) {
    graphicsconfiguration gc =
    window.getgraphicsconfiguration();
    return gc.createcompatibleimage(w, h, transparancy);
    }
    return null;
    }
     /**
      * @return returns the device.
      */
     public graphicsdevice getdevice() {
     return device;
     }
    }


     

     
    热门推荐笔记本: IBM笔记本
    相关文章:
    webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
    ©2007 popbb.net All Rights Reserved