Exemple #1
0
  public ColorMenu(JFrame frame, int players) {
    this.frame = frame;
    numPlayers = players;

    try {
      kenVector25 =
          Font.createFont(Font.TRUETYPE_FONT, new File("fonts/kenvector_future.ttf"))
              .deriveFont(25f);
      kenVector16 =
          Font.createFont(Font.TRUETYPE_FONT, new File("fonts/kenvector_future.ttf"))
              .deriveFont(16f);
      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      // register the font
      ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("fonts/kenvector_future.ttf")));
      ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("fonts/kenvector_future.ttf")));
    } catch (IOException e) {
      e.printStackTrace();
    } catch (FontFormatException e) {
      e.printStackTrace();
    }

    initializeComponents();
    createGUI();
    addEvents();
  }
Exemple #2
0
 LayerManager(Layers layers) {
   this.layers = layers;
   GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
   for (String name : gEnv.getAvailableFontFamilyNames()) log.debug(name);
   log.info("constructed");
   executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
 }
Exemple #3
0
 /** 位置を初期化します。 */
 private void initPosition() {
   // ウィンドウのサイズ
   setSize(getWindowSize());
   // ウィンドウを中央に配置
   Point corner = new Point(0, 0);
   Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
   GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
   if (genv != null) {
     // GraphicsEnvironment はタスクバー等の占有領域も考慮する
     Rectangle screenRect = genv.getMaximumWindowBounds();
     if (screenRect != null) {
       corner = screenRect.getLocation();
       screenSize = screenRect.getSize();
     }
   }
   Dimension frameSize = this.getSize();
   if (frameSize.height > screenSize.height) {
     frameSize.height = screenSize.height;
   }
   if (frameSize.width > screenSize.width) {
     frameSize.width = screenSize.width;
   }
   this.setLocation(
       (int) (corner.getX() + (screenSize.width - frameSize.width) / 2),
       (int) (corner.getY() + (screenSize.height - frameSize.height) / 2));
 }
  public static void main(String[] args) throws IOException, DocumentException {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] fontFamily = ge.getAvailableFontFamilyNames();
    PrintStream out1 = new PrintStream(new FileOutputStream(RESULT1));
    for (int i = 0; i < fontFamily.length; i++) {
      out1.println(fontFamily[i]);
    }
    out1.flush();
    out1.close();

    DefaultFontMapper mapper = new DefaultFontMapper();
    mapper.insertDirectory("c:/windows/fonts/");
    PrintStream out2 = new PrintStream(new FileOutputStream(RESULT2));
    for (Entry<String, BaseFontParameters> entry : mapper.getMapper().entrySet()) {
      out2.println(String.format("%s: %s", entry.getKey(), entry.getValue().fontName));
    }
    out2.flush();
    out2.close();

    float width = 150;
    float height = 150;
    Document document = new Document(new Rectangle(width, height));
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT3));
    document.open();
    PdfContentByte cb = writer.getDirectContent();
    Graphics2D g2d = cb.createGraphics(width, height, mapper);
    for (int i = 0; i < FONTS.length; ) {
      g2d.setFont(FONTS[i++]);
      g2d.drawString("Hello world", 5, 24 * i);
    }
    g2d.dispose();
    document.close();
  }
  /**
   * Create a new LibraryUI object - showing an authentication dialog then bringing up the main
   * window.
   */
  public LibraryUI() {
    super("JDBC Library");
    // Uncomment the following if you'd rather not see everything in bold
    // UIManager.put("swing.boldMetal", Boolean.FALSE);

    // Initialise everything
    initActions();
    initUI();
    initFocusTraversalPolicy();
    setSize(600, 600);

    // Show Authentication dialog
    AuthDialog ad = new AuthDialog(this, "Authentication");
    ad.setVisible(true);
    String userName = ad.getUserName();
    String password = ad.getDatabasePassword();

    // Create data model
    model = new LibraryModel(this, userName, password);

    // Center window on screen
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Point center = ge.getCenterPoint();
    setLocation(center.x - getSize().width / 2, center.y - getSize().height / 2);

    // Show ourselves
    setVisible(true);
  }
Exemple #6
0
  /**
   * Creates a transparent undecorated frame. If the transparency is not supported creates a normal
   * undecorated frame.
   *
   * @return the created frame
   */
  public static TransparentFrame createTransparentFrame() {
    isTranslucencySupported =
        AWTUtilitiesWrapper.isTranslucencySupported(AWTUtilitiesWrapper.PERPIXEL_TRANSLUCENT);

    GraphicsConfiguration translucencyCapableGC =
        GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getDefaultScreenDevice()
            .getDefaultConfiguration();

    if (!AWTUtilitiesWrapper.isTranslucencyCapable(translucencyCapableGC)) {
      translucencyCapableGC = null;

      GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
      GraphicsDevice[] devices = env.getScreenDevices();

      for (int i = 0; i < devices.length && translucencyCapableGC == null; i++) {
        GraphicsConfiguration[] configs = devices[i].getConfigurations();
        for (int j = 0; j < configs.length && translucencyCapableGC == null; j++) {
          if (AWTUtilitiesWrapper.isTranslucencyCapable(configs[j])) {
            translucencyCapableGC = configs[j];
          }
        }
      }
      if (translucencyCapableGC == null) {
        isTranslucencySupported = false;
      }
    }

    if (isTranslucencySupported) return new TransparentFrame(translucencyCapableGC);

    return new TransparentFrame();
  }
  UserInputValidationErrorBox(Frame parent, YWorkItem item, YDataStateException e) {
    super(parent, "Problem with your input data");
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    JPanel p = new JPanel(new BorderLayout());
    p.setBackground(YAdminGUI._apiColour);
    p.add(createTopPanel(item), BorderLayout.NORTH);
    p.add(createCentrePanel(e), BorderLayout.CENTER);
    c.add(p, BorderLayout.CENTER);
    c.add(createBottomPanel(), BorderLayout.SOUTH);
    c.setBackground(YAdminGUI._apiColour);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            storeData();
            this_windowClosing();
          }
        });

    Double screenWidth =
        new Double(
            GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth());
    Double screenHeight =
        new Double(
            GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight());
    setSize(new Double(screenWidth * 0.8).intValue(), new Double(screenHeight * 0.8).intValue());

    Dimension labelSize = this.getSize();
    setLocation(
        screenWidth.intValue() / 2 - (labelSize.width / 2),
        screenHeight.intValue() / 2 - (labelSize.height / 2));
    show();
  }
 /**
  * Creates a new ZPixmapDataBuffer with a specified width and height.
  *
  * @param d the X display
  * @param w the width
  * @param h the height
  */
 ZPixmapDataBuffer(int w, int h) {
   super(TYPE_BYTE, w * h * 3); // TODO: Support non-24-bit-resolutions.
   GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
   XGraphicsDevice dev = (XGraphicsDevice) env.getDefaultScreenDevice();
   Display d = dev.getDisplay();
   zpixmap = new ZPixmap(d, w, h, d.default_pixmap_format);
 }
Exemple #9
0
  private boolean enterFullScreenMode() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] devices = ge.getScreenDevices();
    for (int i = 0; i < devices.length; i++) {
      GraphicsDevice device = devices[i];
      if (device.isFullScreenSupported() && device.getFullScreenWindow() == null) {
        log.info("Switching to full screen mode.");

        frame.setVisible(false);

        try {
          device.setFullScreenWindow(frame);
        } catch (InternalError e) {
          log.error("Failed to switch to full screen exclusive mode.");
          e.printStackTrace();

          frame.setVisible(true);
          return false;
        }

        frame.dispose();
        frame.setUndecorated(true);
        frame.setVisible(true);
        frame.requestFocusInWindow();

        return true;
      }
    }

    log.warn("No screens available or full screen exclusive mode is unsupported on your platform.");

    postError("Full screen mode is not supported on your platform.");

    return false;
  }
  public FrameGeneric(JPanel panelP, int w, int h) {
    super();

    panelContenido = panelP;

    frameWidth = w;
    frameHeight = h;
    frameTitle = "Gestion de eventos [0.1] ";

    super.setTitle(frameTitle);

    Toolkit kit = getToolkit();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    Insets in = kit.getScreenInsets(gs[0].getDefaultConfiguration());
    Dimension d = kit.getScreenSize();
    int max_width = (d.width - in.left - in.right);
    int max_height = (d.height - in.top - in.bottom);
    setSize(
        Math.min(max_width, frameWidth),
        Math.min(max_height, frameHeight)); // whatever size you want but smaller the insets
    setLocation((max_width - getWidth()) / 2, (max_height - getHeight()) / 2);

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container contentPane = getContentPane();
    contentPane.add(panelP);
  }
Exemple #11
0
  /**
   * Applies this geometry to a window. Makes sure that the window is not placed outside of the
   * coordinate range of all available screens.
   *
   * @param window the window
   */
  public void applySafe(Window window) {
    Point p = new Point(topLeft);

    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    for (GraphicsDevice gd : gs) {
      if (gd.getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
        virtualBounds = virtualBounds.union(gd.getDefaultConfiguration().getBounds());
      }
    }

    if (p.x < virtualBounds.x) {
      p.x = virtualBounds.x;
    } else if (p.x > virtualBounds.x + virtualBounds.width - extent.width) {
      p.x = virtualBounds.x + virtualBounds.width - extent.width;
    }

    if (p.y < virtualBounds.y) {
      p.y = virtualBounds.y;
    } else if (p.y > virtualBounds.y + virtualBounds.height - extent.height) {
      p.y = virtualBounds.y + virtualBounds.height - extent.height;
    }

    window.setLocation(p);
    window.setSize(extent);
  }
  private void initFontMenu() {
    Menu fontMenu = new Menu("font");
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fontSet = ge.getAllFonts();
    List<String> list = new ArrayList<>();
    for (Font f : fontSet) {
      list.add(f.getName());
    }
    int num = DigitalClockWindow.EXCLUDED_FONTS.length;
    for (int i = 0; i < num; i++) {
      list.remove(DigitalClockWindow.EXCLUDED_FONTS[i]);
    }
    for (final String fontName : list) {
      MenuItem mi = new MenuItem(fontName);
      mi.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              DigitalClockProperty.PROPERTY.setFontName(fontName);
              digitalClockPropertyObserver.notifyPropertyChanged(DigitalClockProperty.PROPERTY);
              DigitalClockPopupMenu.this.setFont(POPUP_MENU_FONT);
            }
          });
      fontMenu.add(mi);
    }
    add(fontMenu);
  }
  /**
   * Loads the location/size of a frame from the properties file and positions the frame as
   * appropriate.
   *
   * @param frame the frame to position.
   * @param name the name of the property to load from
   */
  public WindowPosition loadFrame(int windowID) {
    if (windowCoords == null) loadConfiguration();

    WindowPosition result = windowCoords.get(windowID);

    if (result
        == null) { // invent default coordinates, using
                   // http://java.sun.com/j2se/1.5.0/docs/api/java/awt/GraphicsDevice.html#getDefaultConfiguration()

      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      GraphicsDevice[] gs = ge.getScreenDevices();
      int deviceToUse = Integer.valueOf(getProperty(G_PROPERTIES.GRAPHICS_MONITOR));
      if (deviceToUse >= gs.length)
        deviceToUse =
            statechum.GlobalConfiguration
                .DEFAULT_SCREEN; // use the first one if cannot use the requested one.
      GraphicsConfiguration gc = gs[deviceToUse].getDefaultConfiguration();

      // from http://java.sun.com/j2se/1.4.2/docs/api/index.html
      Rectangle shape = gc.getBounds();
      Rectangle rect = new Rectangle(new Rectangle(shape.x, shape.y, 400, 300));
      if (rect.height > shape.height) rect.height = shape.height;
      if (rect.width > shape.width) rect.width = shape.width;
      rect.y += windowID * (rect.getHeight() + 30);
      int yLimit = shape.height - rect.height;
      if (rect.y > yLimit) rect.y = yLimit;
      int xLimit = shape.width - rect.width;
      if (rect.x > xLimit) rect.x = xLimit;
      result = new WindowPosition(rect, deviceToUse);
      windowCoords.put(windowID, result);
    }

    return result;
  }
Exemple #14
0
 private void buttonSecondGenerateActionPerformedDoubleSlit(
     java.awt.event.ActionEvent
         evt) { // GEN-FIRST:event_buttonSecondGenerateActionPerformedDoubleSlit
   actionTag = "DoubleSlit";
   if (parseArguments()) {
     GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
     GraphicsDevice[] devices = env.getScreenDevices();
     if (devices.length == 1) {
       countSecondDisplayDoubleSlit--;
       JOptionPane.showMessageDialog(
           null, "No second display is found", "Error", JOptionPane.ERROR_MESSAGE);
     } else {
       PatternImage image = ((EduPatternJPanel) panelPattern).pimage;
       image.updateLensParameterDrawSlit(
           2,
           d_widthX_double,
           d_heightX_double,
           d_postionX_double,
           d_rotation_double,
           d_grayLevel_double,
           d_spacing_double);
       image.slit(2);
       EduPatternShowOn.updatePatternSecondDisplay(image, genLogDoubleSlit());
       setLog(genLogDoubleSlit());
       // EduPatternTest.updateLensPatternPattern(image, genLog());
       imageGenerated = true;
       if (countSecondDisplayDoubleSlit % 2 == 0) {
         patternFrameDoubleClick.dispose();
         patternFrame.dispose();
       }
     }
   }
 } // GEN-LAST:event_buttonSecondGenerateActionPerformedDoubleSlit
Exemple #15
0
  /**
   * <code>main</code> - pass in JFrame name
   *
   * @param args - <code>String[]</code> -
   */
  public static void main(String[] args) {
    name = "";
    String maxScreenValue = "false";
    for (int argc = 0; argc < args.length; argc++) {
      // System.err.println( "argc " + argc + " " + args[argc]);
      if (argc == 0) {
        name = args[argc];
      } else if (argc == 1) {
        maxScreenValue = args[argc];
      } else {
        System.err.println("argument '" + args[argc] + "' not handled");
        System.exit(-1);
      }
    }
    osType = System.getProperty("os.type");
    // System.err.println( "osType " + osType);
    planWorksRoot = System.getProperty("planworks.root");
    isMaxScreen = false;
    if (maxScreenValue.equals("true")) {
      isMaxScreen = true;
    }

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    for (int i = 0; i < gs.length; i++) {
      DisplayMode dm = gs[i].getDisplayMode();
      System.err.println(dm.getWidth() + " " + dm.getHeight());
    }

    planWorks = new PlanWorks(buildConstantMenus());
  } // end main
  {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    fontSet = ge.getAllFonts();
    for (int i = 0; i < fontSet.length; i++) {
      fontCombo.addItem(fontSet[i].getFontName());
    }
    final int FONT_SIZE_NUM = 31;
    fontSizeSet = new int[FONT_SIZE_NUM];
    for (int i = 0; i < FONT_SIZE_NUM; i++) {
      fontSizeSet[i] = 100 + (i * 10);
    }
    for (int n : fontSizeSet) {
      fontSizeCombo.addItem(n);
    }
    for (Color color : ColorNameConverter.getColorSet()) {
      fontColorCombo.addItem(color);
    }
    for (Color color : ColorNameConverter.getColorSet()) {
      backgroundColorCombo.addItem(color);
    }

    fontColorCombo.setEditable(false);
    backgroundColorCombo.setEditable(false);
    ItemWithColorTip item = new ItemWithColorTip();
    fontColorCombo.setRenderer(item);
    backgroundColorCombo.setRenderer(item);
  }
Exemple #17
0
  public static BufferedImage convertIconToBufferedImage(final Icon icon) {

    if (icon == null) {
      return null;
    }
    if (icon instanceof ImageIcon) {
      final Image ret = ((ImageIcon) icon).getImage();
      if (ret instanceof BufferedImage) {
        return (BufferedImage) ret;
      }
    }
    final int w = icon.getIconWidth();
    final int h = icon.getIconHeight();
    final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice gd = ge.getDefaultScreenDevice();
    final GraphicsConfiguration gc = gd.getDefaultConfiguration();
    final BufferedImage image = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);

    final Graphics2D g = image.createGraphics();
    g.setRenderingHint(
        RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    // g.setColor(Color.RED);
    // g.fillRect(0, 0, w, h);
    icon.paintIcon(null, g, 0, 0);
    g.dispose();
    return image;
  }
Exemple #18
0
  public static DisplayMode[] getDisplayModes() {
    GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = genv.getDefaultScreenDevice();
    java.awt.DisplayMode desktopMode = device.getDisplayMode();
    java.awt.DisplayMode[] displayModes = device.getDisplayModes();
    ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>();
    int idx = 0;
    for (java.awt.DisplayMode mode : displayModes) {
      boolean duplicate = false;
      for (int i = 0; i < modes.size(); i++) {
        if (modes.get(i).width == mode.getWidth()
            && modes.get(i).height == mode.getHeight()
            && modes.get(i).bitsPerPixel == mode.getBitDepth()) {
          duplicate = true;
          break;
        }
      }
      if (duplicate) continue;
      if (mode.getBitDepth() != desktopMode.getBitDepth()) continue;
      modes.add(
          new LwjglApplicationConfigurationDisplayMode(
              mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth()));
    }

    return modes.toArray(new DisplayMode[modes.size()]);
  }
 private static void quitFullscreen() {
   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsDevice[] gd = ge.getScreenDevices();
   if (gd.length > 1) {
     gd[1].getFullScreenWindow().dispose();
   }
 }
Exemple #20
0
 public static DisplayMode getDesktopDisplayMode() {
   GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsDevice device = genv.getDefaultScreenDevice();
   java.awt.DisplayMode mode = device.getDisplayMode();
   return new LwjglApplicationConfigurationDisplayMode(
       mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth());
 }
  /**
   * Standard constructor - builds a FontChooserPanel initialised with the specified font.
   *
   * @param font the initial font to display.
   */
  public FontChooserPanel(final Font font) {

    final GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final String[] fonts = g.getAvailableFontFamilyNames();

    setLayout(new BorderLayout());

    final JPanel leftPanel = new JPanel(new GridLayout(2, 1));
    fontlist = new JComboBox(fonts);
    adjustComponent(fontlist);
    sizelist = new JComboBox(SIZES);
    adjustComponent(sizelist);
    leftPanel.add(fontlist);
    final JPanel sizePanel = new JPanel(new BorderLayout(3, 0));
    final JLabel label = new JLabel("Size:");
    adjustComponent(label);
    label.setHorizontalAlignment(JLabel.RIGHT);
    sizePanel.add(label, BorderLayout.CENTER);
    sizePanel.add(sizelist, BorderLayout.EAST);
    leftPanel.add(sizePanel);

    final JPanel rightPanel = new JPanel(new GridLayout(2, 1));
    boldCheck = new JCheckBox("Bold");
    adjustComponent(boldCheck);
    italicCheck = new JCheckBox("Italic");
    adjustComponent(italicCheck);
    rightPanel.add(boldCheck);
    rightPanel.add(italicCheck);

    add(leftPanel, BorderLayout.CENTER);
    add(rightPanel, BorderLayout.EAST);

    setSelectedFont(font);
  }
  private static void showOnScreen(int screen, JFrame frame, boolean fullscreen) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gd = ge.getScreenDevices();
    if (!Main.protection || (screen > -1 && screen < gd.length)) {
      if (!Main.protection || (fullscreen && screen == Main.secondScreen)) {
        // frame.setSize(gd[screen].getDefaultConfiguration().getBounds().x,gd[screen].getDefaultConfiguration().getBounds().y);
        gd[screen].setFullScreenWindow(frame);
      } else {
        frame.setSize(600, 300);
        Rectangle bound = gd[screen].getDefaultConfiguration().getBounds();
        System.out.println(
            "x: "
                + bound.x
                + " y: "
                + bound.y
                + " width: "
                + bound.width
                + " height : "
                + bound.height);
        frame.setLocation((int) (bound.x + bound.getWidth() / 2 - 300), frame.getY());
      }

      return;
    }
    System.out.println("Erreur : l'ecran " + screen + " n'a pas ete trouve");
  }
Exemple #23
0
 public static void main(String[] args) throws Exception {
   String os = System.getProperty("os.name");
   if (!os.startsWith("Mac")) {
     return;
   }
   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   Font[] fonts = ge.getAllFonts();
   for (int i = 0; i < fonts.length; i++) {
     if (fonts[i].getPSName().equals("Helvetica-LightOblique")) {
       helvFont = fonts[i];
       break;
     }
   }
   if (helvFont == null) {
     return;
   }
   final HelvLtOblTest test = new HelvLtOblTest();
   SwingUtilities.invokeLater(
       () -> {
         JFrame f = new JFrame();
         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         f.add("Center", test);
         f.pack();
         f.setVisible(true);
       });
   test.compareImages();
 }
  public void beginExecution() {
    if (cam == null) {

      int numBuffers = 2;

      env = GraphicsEnvironment.getLocalGraphicsEnvironment();
      device = env.getDefaultScreenDevice();
      // MultiBufferTest test = new MultiBufferTest(numBuffers, device);

      try {

        GraphicsConfiguration gc = device.getDefaultConfiguration();
        mainFrame = new Frame(gc);
        mainFrame.setUndecorated(true);
        mainFrame.setIgnoreRepaint(true);
        device.setFullScreenWindow(mainFrame);
        if (device.isDisplayChangeSupported()) {
          chooseBestDisplayMode(device);
        }
        mainFrame.createBufferStrategy(numBuffers);
        bufferStrategy = mainFrame.getBufferStrategy();

      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
  public MafiaMainClass() {
    setLayout(card); // BorderLayout

    // add("WR",wr);
    add("LOG", login); // window창 위에 penal을 올린다
    setTitle("MAFIA GAME - LOGIN");
    setSize(1280, 985); // window 크기

    /*			// 창을 중앙에 띄운다.
    			Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
    			Dimension ex_size = this.getSize();

    			int xpos=(int)(screen.getWidth()/2 - this.getWidth()/2);
    			int ypos=(int)(screen.getHeight()/2 - this.getHeight()/2);

    			this.setLocation(xpos,ypos);
    */
    // 전체화면
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    setUndecorated(true);
    gd.setFullScreenWindow(this);

    setVisible(true); // window 보이기
    setResizable(false); // 화면크기 고정

    addMouseListener(this); // mouse움직임
  }
  /** Initializes the GUI. */
  public void initGUI() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    DisplayMode dm = gs[0].getDisplayMode();
    windowHeight = dm.getHeight() - 50;
    windowWidth = ((windowHeight * Board.WIDTH) / Board.HEIGHT) + MENU_WIDTH;
    this.setTitle("Kriegspiel Board Display");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setMinimumSize(new Dimension(windowWidth, windowHeight));
    this.setResizable(false);

    Container content = this.getContentPane();

    boardPanel = new JPanel();
    boardPanel.setLayout(
        new GridLayout(Board.HEIGHT, Board.WIDTH, windowHeight / 500, windowHeight / 500));
    JPanel menuPanel = new MenuDisplayer(this, controller);
    content.setLayout(new BorderLayout());

    this.add(boardPanel, BorderLayout.CENTER);
    this.add(menuPanel, BorderLayout.EAST);

    boardPanel.setBackground(new Color(0, 0, 0));

    squares = new JPanel[Board.WIDTH][Board.HEIGHT];
  }
Exemple #27
0
 /**
  * Create possibly volatile scratch image for fast painting. A scratch image can become
  * invalidated, when this happens any actions involving it are ignored, and it needs to be
  * recreated. Use isScratchImageValid() to check this.
  */
 public static Image createScratchImage(int width, int height) {
   try {
     Image img =
         (Image)
             tryMethod(
                 output_comp,
                 "createVolatileImage",
                 new Object[] {new Integer(width), new Integer(height)});
     if (img == null) {
       // no such method -> create regular image
       return output_comp.createImage(width, height);
     }
     // if (img.validate(output_comp.getGraphicsConfiguration())
     // == VolatileImage.IMAGE_INCOMPATIBLE) {
     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
     GraphicsDevice gs = ge.getDefaultScreenDevice();
     GraphicsConfiguration gc = gs.getDefaultConfiguration();
     Integer valid = (Integer) tryMethod(img, "validate", new Object[] {gc});
     // output_comp.getGraphicsConfiguration() });
     if (valid.intValue() == 2) { // I checked, IMAGE_INCOMPATIBLE=2
       // Hmm, somehow it didn't work. Create regular image.
       return output_comp.createImage(width, height);
     }
     return img;
   } catch (java.security.AccessControlException e) {
     // we're not allowed to do this (we're probably an applet)
     return output_comp.createImage(width, height);
   }
 }
Exemple #28
0
  /**
   * ZombieFrame's constructor.
   *
   * @param contents Optional JPanel(s) to add to content pane. Arguments > 0 are ignored.
   */
  public ZombieFrame(JPanel... contents) {
    super("ZombieHouse");

    // Request keyboard focus for the frame.
    setFocusable(true);
    requestFocusInWindow();
    requestFocus();

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setUndecorated(true);
    setResizable(false);
    setBackground(Color.BLACK);

    // The content pane. An optional JPanel may be passed into the
    // constructor. It creates an empty pane with a black background if
    // one isn't provided.
    pane = getContentPane();
    pane.setBackground(Color.BLACK);
    pane.setFocusable(false);
    pane.setVisible(true);
    if (contents.length > 0) {
      pane.add(contents[0]);
    }

    keys = new ZombieKeyBinds((JComponent) pane);

    // Get the graphics device information.
    GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice graphics = environment.getDefaultScreenDevice();

    pack();

    // Go full screen, if supported.
    if (graphics.isFullScreenSupported()) {
      try {
        graphics.setFullScreenWindow(this);
        // Having gone full screen, retrieve the display size.
        // size = Toolkit.getDefaultToolkit().getScreenSize();

        // This double-switching of setVisible is to fix a bug with
        // full-screen-exclusive mode on OS X. Versions 10.8 and later
        // don't send keyboard events properly without it.
        if (System.getProperty("os.name").contains("OS X")) {
          setVisible(false);
        }
      } catch (HeadlessException ex) {
        System.err.println(
            "Error: primary display not set or found. "
                + "Your experience of life may be suboptimal.");
        ex.printStackTrace();
      }
    } else {
      // If full-screen-exclusive mode isn't supported, switch to
      // maximized window mode.
      System.err.println("Full-screen-exclusive mode not supported.");
      setExtendedState(Frame.MAXIMIZED_BOTH);
    }
    setVisible(true);
  }
  /*Cuando el estado de la ventana cambia*/
  private void formWindowStateChanged(
      java.awt.event.WindowEvent evt) { // GEN-FIRST:event_formWindowStateChanged

    /*Que este máximizado siempre*/
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    this.setMaximizedBounds(env.getMaximumWindowBounds());
    this.setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH);
  } // GEN-LAST:event_formWindowStateChanged
Exemple #30
0
  public static BufferedImage createEmptyImage(final int w, final int h) {

    final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice gd = ge.getDefaultScreenDevice();
    final GraphicsConfiguration gc = gd.getDefaultConfiguration();
    final BufferedImage image = gc.createCompatibleImage(w, h, Transparency.BITMASK);
    return image;
  }