コード例 #1
0
 public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
   super.init(gc, sbg);
   multiLb = new MKLabelNode("Multiplayer");
   multiLb.setPostion(new MKPoint(50, 50));
   multiLb.setFont(new Font("Verdana", Font.BOLD, 50));
   // gc font x y w h
   textField =
       new TextField(
           gc, new TrueTypeFont(new Font("Verdana", Font.BOLD, 30), false), 50, 10, 500, 50);
   textField.setText("username...");
   textField.setCursorPos("username...".length());
 }
コード例 #2
0
ファイル: GUI.java プロジェクト: FruitOfLight/vida
    @Override
    public void run() {
      // TODO spravit krajsie

      final JFrame frame = new JFrame("ViDA");
      GUI.frame = frame;
      frame.setLayout(null);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      graphLoader = new JFileChooser("./");
      graphSaver = new JFileChooser("./");

      menu = new JMenuBar();
      Menu.init();

      for (int i = 0; i < Menu.menuItems.length; i++) {
        final JMenu item = new JMenu(Menu.menuItems[i]);
        menu.add(item);
        for (int j = 0; j < Menu.allMenuItems[i].length; ++j) {
          if (Menu.allMenuItems[i][j].equals("--")) {
            item.addSeparator();
          } else {
            final JMenuItem meno = new JMenuItem(Menu.allMenuItems[i][j]);
            item.add(meno);
            final int fi = i;
            final int fj = j;
            meno.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    Menu.performAction(fi, fj);
                  }
                });
          }
        }
      }

      popupInformation = new PopupPanel(informationPanel.scrollPanel);
      gkl.addMouseListener(KeyEvent.VK_I, popupInformation);
      popupZoomWindow = new PopupPanel(zoomWindow.canvas);

      layeredPane = new JLayeredPane();
      frame.add(layeredPane);
      // layeredPane.setLayout(null);
      layeredPane.add(menu);
      layeredPane.add(player.graph.canvas);
      layeredPane.add(informationPanel.scrollPanel);
      layeredPane.add(zoomWindow.canvas);
      layeredPane.add(popupInformation);
      layeredPane.add(popupZoomWindow);
      frame.add(controls.panel);

      layeredPane.setComponentZOrder(menu, 0);
      layeredPane.setComponentZOrder(player.graph.canvas, 1);
      layeredPane.setComponentZOrder(informationPanel.scrollPanel, 0);
      layeredPane.setComponentZOrder(zoomWindow.canvas, 0);
      layeredPane.setComponentZOrder(popupInformation, 0);
      layeredPane.setComponentZOrder(popupZoomWindow, 0);

      informationPanel.scrollPanel.setVisible(false);
      zoomWindow.canvas.setVisible(false);

      KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      manager.addKeyEventDispatcher(gkl);

      frame.addWindowListener(
          new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
              saveApp();
            }
          });
      frame.addComponentListener(
          new ComponentAdapter() {
            public void componentResized(ComponentEvent e) {
              refreshLayout();
            }
          });

      frame.setSize(CONST.windowWidth, CONST.windowHeight);
      frame.setVisible(true);
      int dw = frame.getWidth() - frame.getContentPane().getWidth();
      int dh = frame.getHeight() - frame.getContentPane().getHeight();
      System.out.println("frame " + dw + " " + dh);
      frame.setMinimumSize(new Dimension(CONST.minWindowWidth + dw, CONST.minWindowHeight + dh));
      gRepaint();
    }