Example #1
0
  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움직임
  }
 /*
  *  Keep the size of the component within the bounds of its parent.
  */
 private Dimension getBoundingSize(Component source) {
   if (source instanceof Window) {
     GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
     Rectangle bounds = env.getMaximumWindowBounds();
     return new Dimension(bounds.width, bounds.height);
   } else {
     return source.getParent().getSize();
   }
 }
Example #3
0
 public static void main(String[] args) {
   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsDevice[] devices = ge.getScreenDevices();
   for (int i = 0; i < devices.length; i++) {
     CapabilitiesTest tst = new CapabilitiesTest(devices[i]);
     tst.pack();
     tst.setVisible(true);
   }
 }
 private static GraphicsDevice getScreen(JFrame window) {
   for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
     if (gd.getDefaultConfiguration().getBounds().contains(window.getLocationOnScreen()))
       return gd;
   }
   System.err.println(
       window + " does not appear to be on any screen; fullscreening onto default screen");
   return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
 }
Example #5
0
    public MyPanel(Clock clock) {
      myTime = new MyTime();
      this.clock = clock;
      font = new Font(fontStyle, fontKind, fontSize);
      super.setBackground(bgColor);
      popup = new JPopupMenu();

      JMenu mn = new JMenu("menu");
      editor = new JEditorPane();
      editor.setContentType("text/html");
      editor.setEditable(true);

      editor.setText("<b>Hello</b>");
      mn.add(editor);
      JMenu mnf = new JMenu("font style");
      JMenu mnfs = new JMenu("font size");
      JMenu mnfc = new JMenu("font color");
      JMenu mnbg = new JMenu("background color");

      mn.add(mnf);
      mn.add(mnfs);
      mn.add(mnfc);
      mn.add(mnbg);

      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      fs = ge.getAvailableFontFamilyNames();
      JMenuItem[] mif = new JMenuItem[fs.length];
      for (int i = 0; i < fs.length; i++) {
        mif[i] = new JMenuItem(fs[i]);
        mnf.add(mif[i]);
        mif[i].addActionListener(new ActionAdapter(this, this.clock));
      }

      JMenuItem[] mifs = new JMenuItem[FONT_SIZE_LENGTH];
      for (int i = 0; i < FONT_SIZE_LENGTH; i++) {
        mifs[i] = new JMenuItem(Integer.valueOf(10 * 2 * (i + 1)).toString());
        mnfs.add(mifs[i]);
        mifs[i].addActionListener(new ActionAdapter(this, this.clock));
      }

      JMenuItem[] mifc = new JMenuItem[COLOR_LIST_LENGTH];
      for (int i = 0; i < COLOR_LIST_LENGTH; i++) {
        mifc[i] = new JMenuItem(colorStr[i]);
        mnfc.add(mifc[i]);
        mifc[i].addActionListener(new ActionAdapter(this, this.clock));
      }

      JMenuItem[] mibg = new JMenuItem[COLOR_LIST_LENGTH];
      for (int i = 0; i < COLOR_LIST_LENGTH; i++) {
        mibg[i] = new JMenuItem(bgColorStr[i]);
        mnbg.add(mibg[i]);
        mibg[i].addActionListener(new ActionAdapter(this, this.clock));
      }

      popup.add(mn);
      add(popup);
    }
Example #6
0
File: View.java Project: Jegp/BGPP
  /** Instantiates the view. */
  public View() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new BorderLayout());

    // create north, south, west and east panels
    JPanel northPanel = new JPanel(new FlowLayout());
    JPanel westPanel = new JPanel(new GridLayout(0, 1));
    JPanel eastPanel = new JPanel();
    JPanel southPanel = new JPanel();

    // create primitive start panel.
    JPanel startPanel = new JPanel(); // perhaps add picture?

    // set starting panel
    container = startPanel;

    // arrange the panels
    add(container, BorderLayout.CENTER);
    add(northPanel, BorderLayout.NORTH);
    add(westPanel, BorderLayout.WEST);
    add(eastPanel, BorderLayout.EAST);
    add(southPanel, BorderLayout.SOUTH);

    // create buttons
    reservationButton = new JButton("Reservation");
    customerButton = new JButton("Customer");
    vehicleButton = new JButton("Vehicle");

    // add components to north panel
    northPanel.add(reservationButton);
    northPanel.add(customerButton);
    northPanel.add(vehicleButton);

    // Add a loading panel to display loading before the container is shown
    loadingPanel = new JPanel(new BorderLayout());
    JLabel loading = new JLabel("Loading...");
    loadingPanel.add(loading, BorderLayout.NORTH);
    add(loadingPanel);

    // Set title
    setTitle("Bookingsystem");

    // Display
    GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
    setMaximizedBounds(e.getMaximumWindowBounds());
    setPreferredSize(e.getMaximumWindowBounds().getSize());

    // Initialize
    pack();
    setVisible(true);
  }
  @Override
  public Rectangle getScreenBounds(@NotNull Project project) {
    final GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final Point onScreen = getFrame(project).getLocationOnScreen();
    final GraphicsDevice[] devices = environment.getScreenDevices();
    for (final GraphicsDevice device : devices) {
      final Rectangle bounds = device.getDefaultConfiguration().getBounds();
      if (bounds.contains(onScreen)) {
        return bounds;
      }
    }

    return null;
  }
Example #8
0
 private static int getGraphicsConfigScreen(GraphicsConfiguration gc) {
   // TODO: this method can be implemented in a more
   // efficient way by forwarding to the delegate
   GraphicsDevice gd = gc.getDevice();
   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsDevice[] gds = ge.getScreenDevices();
   for (int i = 0; i < gds.length; i++) {
     if (gds[i] == gd) {
       return i;
     }
   }
   // Should never happen if gc is a screen device config
   return 0;
 }
Example #9
0
 public Point getPreferredLocation() {
   if (!IJ.isJava14()) return new Point(0, 0);
   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   Rectangle maxBounds = ge.getMaximumWindowBounds();
   int ijX = Prefs.getInt(IJ_X, -99);
   int ijY = Prefs.getInt(IJ_Y, -99);
   if (ijX >= 0 && ijY > 0 && ijX < (maxBounds.x + maxBounds.width - 75))
     return new Point(ijX, ijY);
   Dimension tbsize = toolbar.getPreferredSize();
   int ijWidth = tbsize.width + 10;
   double percent = maxBounds.width > 832 ? 0.8 : 0.9;
   ijX = (int) (percent * (maxBounds.width - ijWidth));
   if (ijX < 10) ijX = 10;
   return new Point(ijX, maxBounds.y);
 }
  private void doListModels() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] allFonts = ge.getAvailableFontFamilyNames();
    // Font[]allFonts = ge.getAllFonts();
    String[] styles = {"Plain", "Bold", "Italic", "Bold Italic"};
    String[] sizes = {"8", "9", "10", "11", "12", "14", "16", "18", "20"};

    DefaultComboBoxModel fontModel = new DefaultComboBoxModel(allFonts);
    DefaultComboBoxModel styleModel = new DefaultComboBoxModel(styles);
    DefaultComboBoxModel sizeModel = new DefaultComboBoxModel(sizes);

    fontList.setModel(fontModel);
    styleList.setModel(styleModel);
    sizeList.setModel(sizeModel);
  }
Example #11
0
 static {
   /* ensure that the necessary native libraries are loaded */
   Toolkit.loadLibraries();
   if (!GraphicsEnvironment.isHeadless()) {
     initIDs();
   }
 }
Example #12
0
    private void showJPopupMenu(MouseEvent e) {
      try {
        if (e.isPopupTrigger() && menu != null) {
          if (window == null) {

            if (isWindows) {
              window = new JDialog((Frame) null);
              ((JDialog) window).setUndecorated(true);
            } else {
              window = new JWindow((Frame) null);
            }
            window.setAlwaysOnTop(true);
            Dimension size = menu.getPreferredSize();

            Point centerPoint = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
            if (e.getY() > centerPoint.getY()) window.setLocation(e.getX(), e.getY() - size.height);
            else window.setLocation(e.getX(), e.getY());

            window.setVisible(true);

            menu.show(((RootPaneContainer) window).getContentPane(), 0, 0);

            // popup works only for focused windows
            window.toFront();
          }
        }
      } catch (Exception ignored) {
      }
    }
Example #13
0
 private void initFontPrefs() {
   UserPreferences pref = UserPreferences.getInstance();
   String[] fontList =
       GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
   for (String font : fontList) _cmbFontName.addItem(font);
   _cmbFontName.setSelectedItem(pref.getFontName());
   _spnFontSize.setValue(pref.getFontSize());
 }
  static {
    //  Do not initialize keyboard settings
    //  if we are running headless.

    try {
      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

      if (!ge.isHeadless()) {
        MENU_SHORTCUT_KEY_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();

        MENU_SHORTCUT_SHIFT_KEY_MASK = MENU_SHORTCUT_KEY_MASK + InputEvent.SHIFT_MASK;
      } else {
        MENU_SHORTCUT_KEY_MASK = 0;
        MENU_SHORTCUT_SHIFT_KEY_MASK = 0;
      }
    } catch (Exception e) {
    }
  }
Example #15
0
 /** Constructor. */
 protected HIDServiceImpl() {
   try {
     robot = new Robot();
     nativeKeyboard = new NativeKeyboard();
   } catch (Throwable e) {
     if (!GraphicsEnvironment.isHeadless())
       logger.error("Error when creating Robot/NativeKeyboard instance", e);
   }
 }
Example #16
0
  public static DisplayDeviceArea[] getPresentationAndImageDeviceAreas() {
    DisplayDeviceArea[] displayDeviceAreas = null;
    GraphicsDevice[] gs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
    if (gs.length == 1) {
      DisplayMode dm = gs[0].getDisplayMode();
      int width = dm.getWidth();
      int height = dm.getHeight();
      float presentationAspectRatio = 5f / 4; // usual screen for presentations
      float imageAspectRatio = 3f / 4 * 2; // pair of portrait monitors

      float presentationHorizontalProportion = 0.33f;

      int presentationWidth = (int) (width * presentationHorizontalProportion);

      int presentationHeight = (int) (presentationWidth / presentationAspectRatio);
      if (presentationHeight > height) {
        presentationHeight = height;
      }
      int presentationX = 0;
      int presentationY = height - presentationHeight;

      int imageWidth = width - presentationWidth;
      int imageHeight = (int) (imageWidth / imageAspectRatio);
      if (imageHeight > height) {
        imageHeight = height;
      }
      int imageX = presentationWidth;
      int imageY = height - imageHeight;

      displayDeviceAreas = new DisplayDeviceArea[2];
      displayDeviceAreas[0] =
          new DisplayDeviceArea(
              gs[0], presentationX, presentationY, presentationWidth, presentationHeight);
      displayDeviceAreas[1] = new DisplayDeviceArea(gs[0], imageX, imageY, imageWidth, imageHeight);
    } else if (gs.length == 2) {
      DisplayMode dm1 = gs[0].getDisplayMode();
      DisplayMode dm2 = gs[1].getDisplayMode();
      int width1 = dm1.getWidth();
      int width2 = dm2.getWidth();
      int height1 = dm1.getHeight();
      int height2 = dm2.getHeight();
      GraphicsDevice presentationDevice;
      GraphicsDevice imageDevice;
      if (width1 * height1 > width2 * height2) {
        presentationDevice = gs[1];
        imageDevice = gs[0];
      } else {
        presentationDevice = gs[0];
        imageDevice = gs[1];
      }
      displayDeviceAreas = new DisplayDeviceArea[2];
      displayDeviceAreas[0] = new DisplayDeviceArea(presentationDevice);
      displayDeviceAreas[1] = new DisplayDeviceArea(imageDevice);
    }
    return displayDeviceAreas;
  }
Example #17
0
 /**
  * Tries to find GraphicsConfiguration that contains the mouse cursor position. Can return null.
  */
 private GraphicsConfiguration getCurrentGraphicsConfiguration(Point popupLocation) {
   GraphicsConfiguration gc = null;
   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsDevice[] gd = ge.getScreenDevices();
   for (int i = 0; i < gd.length; i++) {
     if (gd[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
       GraphicsConfiguration dgc = gd[i].getDefaultConfiguration();
       if (dgc.getBounds().contains(popupLocation)) {
         gc = dgc;
         break;
       }
     }
   }
   // If not found and we have invoker, ask invoker about his gc
   if (gc == null && getInvoker() != null) {
     gc = getInvoker().getGraphicsConfiguration();
   }
   return gc;
 }
Example #18
0
 protected JComboBox createFontChoice() {
   CommandChoice choice = new CommandChoice();
   String fonts[] =
       GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
   for (int i = 0; i < fonts.length; i++) {
     choice.addItem(
         new ChangeAttributeCommand(fonts[i], FigureAttributeConstant.FONT_NAME, fonts[i], this));
   }
   return choice;
 }
Example #19
0
 public static void main(String[] args) {
   System.out.println("It is program My");
   // получение списка шрифтов
   String[] fontNames =
       GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
   for (int i = 0; i < fontNames.length; i++) System.out.println(fontNames[i]);
   MyFrame frame = new MyFrame();
   // условие закрытия окна
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.show();
 }
Example #20
0
  JFrame openMonitorGUI(String title) {
    try {
      MonitorGUI gui = new MonitorGUI(this, title);

      JFrame frame = new JFrame(title);
      frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      frame.addWindowListener(this);
      frame.getContentPane().add(gui);

      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      Rectangle r = ge.getMaximumWindowBounds();
      frame.setSize(400, 200);
      frame.setLocationRelativeTo(null);
      frame.pack();
      frame.setVisible(true);
      return frame;
    } catch (Exception e) {
      System.out.println("9\b" + getClass().getName() + "\n\t" + e);
      return null;
    }
  }
Example #21
0
 public static BufferedImage tileImage(BufferedImage im, int width, int height) {
   GraphicsConfiguration gc =
       GraphicsEnvironment.getLocalGraphicsEnvironment()
           .getDefaultScreenDevice()
           .getDefaultConfiguration();
   int transparency = Transparency.OPAQUE; // Transparency.BITMASK;
   BufferedImage compatible = gc.createCompatibleImage(width, height, transparency);
   Graphics2D g = (Graphics2D) compatible.getGraphics();
   g.setPaint(new TexturePaint(im, new Rectangle(0, 0, im.getWidth(), im.getHeight())));
   g.fillRect(0, 0, width, height);
   return compatible;
 }
Example #22
0
  /** @see pong.ApplicationState#init() */
  @Override
  public void init() {
    JFrame.setDefaultLookAndFeelDecorated(false);

    // Set background scene.

    backgroundScene =
        new PhysicsScene(CollidableMap.getMainMenuMap(), null, null, .0f, new RandomBallStrategy());

    // Create GUI.
    mainFrame = new PongFrame("Pong Adventures -Main menu-", backgroundScene, false, null, false);
    mainFrame.addWindowListener(this);
    mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    mainFrame.setResizable(false);

    // Setting frame to center of screen.
    Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
    mainFrame.setBounds(
        center.x - Global.windowSize.width / 2,
        center.y - Global.windowSize.height / 2,
        Global.windowSize.width,
        Global.windowSize.height);

    newGameButton = new JButton("New Game");
    newGameButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    newGameButton.addActionListener(this);

    settingsButton = new JButton("Settings");
    settingsButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    settingsButton.addActionListener(this);

    exitButton = new JButton("Exit");
    exitButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    exitButton.addActionListener(this);

    Container content = mainFrame.getContentPane();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));

    content.add(Box.createGlue());
    content.add(Box.createGlue());
    content.add(newGameButton);
    content.add(Box.createGlue());
    content.add(settingsButton);
    content.add(Box.createGlue());
    content.add(exitButton);
    content.add(Box.createGlue());
    content.add(Box.createGlue());

    mainFrame.setVisible(true);

    Debugger.debugWriteln("Initializing main menu.", this.getClass());
  }
Example #23
0
  /**
   * Returns an point which has been adjusted to take into account of the desktop bounds, taskbar
   * and multi-monitor configuration.
   *
   * <p>This adustment may be cancelled by invoking the application with
   * -Djavax.swing.adjustPopupLocationToFit=false
   */
  Point adjustPopupLocationToFitScreen(int xPosition, int yPosition) {
    Point popupLocation = new Point(xPosition, yPosition);

    if (popupPostionFixDisabled == true || GraphicsEnvironment.isHeadless()) {
      return popupLocation;
    }

    // Get screen bounds
    Rectangle scrBounds;
    GraphicsConfiguration gc = getCurrentGraphicsConfiguration(popupLocation);
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (gc != null) {
      // If we have GraphicsConfiguration use it to get screen bounds
      scrBounds = gc.getBounds();
    } else {
      // If we don't have GraphicsConfiguration use primary screen
      scrBounds = new Rectangle(toolkit.getScreenSize());
    }

    // Calculate the screen size that popup should fit
    Dimension popupSize = JPopupMenu.this.getPreferredSize();
    long popupRightX = (long) popupLocation.x + (long) popupSize.width;
    long popupBottomY = (long) popupLocation.y + (long) popupSize.height;
    int scrWidth = scrBounds.width;
    int scrHeight = scrBounds.height;
    if (!canPopupOverlapTaskBar()) {
      // Insets include the task bar. Take them into account.
      Insets scrInsets = toolkit.getScreenInsets(gc);
      scrBounds.x += scrInsets.left;
      scrBounds.y += scrInsets.top;
      scrWidth -= scrInsets.left + scrInsets.right;
      scrHeight -= scrInsets.top + scrInsets.bottom;
    }
    int scrRightX = scrBounds.x + scrWidth;
    int scrBottomY = scrBounds.y + scrHeight;

    // Ensure that popup menu fits the screen
    if (popupRightX > (long) scrRightX) {
      popupLocation.x = scrRightX - popupSize.width;
      if (popupLocation.x < scrBounds.x) {
        popupLocation.x = scrBounds.x;
      }
    }
    if (popupBottomY > (long) scrBottomY) {
      popupLocation.y = scrBottomY - popupSize.height;
      if (popupLocation.y < scrBounds.y) {
        popupLocation.y = scrBounds.y;
      }
    }

    return popupLocation;
  }
Example #24
0
  public GamePanel() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gs.getDefaultConfiguration();

    // Create an image that does not support transparency
    backBufferImage =
        gc.createCompatibleImage(
            TopDownShooter_Main.screenWidth, TopDownShooter_Main.screenHeight, Transparency.OPAQUE);
    backBuffer = backBufferImage.getGraphics();

    player = new Player(new Point(750, 750));

    map = Map.getInstance();
    map.loadWorld("World 1");
    viewScreen = ViewScreen.getInstance();
    collisionManager = CollisionManager.getInstance();

    SwingUtilities.invokeLater(
        new Runnable() { // The GUI needs to be added to the JPanel at a later time, since there is
                         // no way to know the size of this panel yet.
          public void run() {
            viewScreen.setSize(
                new Rectangle(
                    new Point(0, 0),
                    new Dimension(
                        GamePanel.this.getWidth(),
                        GamePanel.this
                            .getHeight()))); // Size the ViewScreen to the actual dimensions of the
                                             // viewable area now that we know them
            viewScreen.CenterOnObject(player.getBoundingBox());
          }
        });

    this.setFocusable(true);
    this.addKeyListener(player);

    new Timer(16, this).start(); // Master game timer
  }
  public void updateGC() {
    int scrn = getScreenImOn();
    if (screenLog.isLoggable(PlatformLogger.Level.FINER)) {
      log.finer("Screen number: " + scrn);
    }

    // get current GD
    Win32GraphicsDevice oldDev = (Win32GraphicsDevice) winGraphicsConfig.getDevice();

    Win32GraphicsDevice newDev;
    GraphicsDevice devs[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
    // Occasionally during device addition/removal getScreenImOn can return
    // a non-existing screen number. Use the default device in this case.
    if (scrn >= devs.length) {
      newDev =
          (Win32GraphicsDevice)
              GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    } else {
      newDev = (Win32GraphicsDevice) devs[scrn];
    }

    // Set winGraphicsConfig to the default GC for the monitor this Window
    // is now mostly on.
    winGraphicsConfig = (Win32GraphicsConfig) newDev.getDefaultConfiguration();
    if (screenLog.isLoggable(PlatformLogger.Level.FINE)) {
      if (winGraphicsConfig == null) {
        screenLog.fine("Assertion (winGraphicsConfig != null) failed");
      }
    }

    // if on a different display, take off old GD and put on new GD
    if (oldDev != newDev) {
      oldDev.removeDisplayChangedListener(this);
      newDev.addDisplayChangedListener(this);
    }

    AWTAccessor.getComponentAccessor()
        .setGraphicsConfiguration((Component) target, winGraphicsConfig);
  }
Example #26
0
  public shit() {
    this.addWindowListener(this);
    setSize(1280, 720);
    setVisible(true);

    r = new Random();
    //		ap = new AudioPlayer();//THIS SHIT DOESN'T WORK WHAT THE F**K DEHOWE
    timer = System.currentTimeMillis();
    options.add("");
    options.add("");
    options.add(""); // These 3 lines are to populate options.
    state = 1; // The first line will always be a story panel so the state is 1.
    try {
      URL url = getClass().getResource("options.png");
      obox = ImageIO.read((url));
      url = getClass().getResource("Text Boxes.png");
      textBox = ImageIO.read(url); // reads in the text boxes file.
      p = new parser("Introduction.txt"); // reads in the story file.
      progress(); // the function that calls going through to the next line
    } catch (IOException e) {
      e.printStackTrace();
    }

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    try {
      URL url = getClass().getResource("sspr.ttf");
      ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, url.openStream()));
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    resize(SCREENWIDTH, SCREENHEIGHT); // Makes the applet the size we want it
    addMouseListener(this); // Lets us use mouse
    addKeyListener(this); // Lets us use keyboard

    Thread t = new Thread(this);
    t.start();
  }
Example #27
0
  /**
   * Reads the <code>ObjectInputStream</code> and if it isn't <code>null</code> adds a listener to
   * receive action events fired by the button. Unrecognized keys or values will be ignored.
   *
   * @param s the <code>ObjectInputStream</code> to read
   * @exception HeadlessException if <code>GraphicsEnvironment.isHeadless</code> returns <code>true
   *     </code>
   * @serial
   * @see #removeActionListener(ActionListener)
   * @see #addActionListener(ActionListener)
   * @see java.awt.GraphicsEnvironment#isHeadless
   * @see #writeObject(ObjectOutputStream)
   */
  private void readObject(ObjectInputStream s)
      throws ClassNotFoundException, IOException, HeadlessException {
    GraphicsEnvironment.checkHeadless();
    s.defaultReadObject();

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
      String key = ((String) keyOrNull).intern();

      if (actionListenerK == key) addActionListener((ActionListener) (s.readObject()));
      else // skip value for unrecognized key
      s.readObject();
    }
  }
Example #28
0
  private String[] chooseFonts() {
    Random random = new Random();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fonts = ge.getAllFonts();

    HashSet<Integer> set = new HashSet<Integer>(); // Thanks to google

    int i = 0;
    String[] fontList = new String[4];

    while (i < 4) {
      int rand = random.nextInt(fonts.length);

      if (!(set.contains(rand))) {
        set.add(rand);
        fontList[i] = fonts[rand].getFontName();
      }

      i++; // Never fails I always forget this on first run
    }

    return fontList;
  }
  public void generarFondo(Component componente) {
    Rectangle areaDibujo = this.getBounds();
    BufferedImage tmp;
    GraphicsConfiguration gc =
        GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getDefaultScreenDevice()
            .getDefaultConfiguration();

    tmp = gc.createCompatibleImage(areaDibujo.width, areaDibujo.height, BufferedImage.TRANSLUCENT);
    Graphics2D g2d = (Graphics2D) tmp.getGraphics();
    g2d.setColor(new Color(55, 55, 255, 165));
    g2d.fillRect(0, 0, areaDibujo.width, areaDibujo.height);
    fondo = tmp;
  }
Example #30
0
  private static String[] getFontList() {
    String[] nameArray =
        GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
    List<String> nameVector = new ArrayList<String>(nameArray.length);

    for (int i = 0, j; i < nameArray.length; i++) {
      for (j = 0; j < HIDEFONTS.length; j++) {
        if (nameArray[i].contains(HIDEFONTS[j])) break;
      }

      if (j == HIDEFONTS.length) nameVector.add(nameArray[i]);
    }

    String[] _array = new String[nameVector.size()];
    return nameVector.toArray(_array);
  }