コード例 #1
0
 @SuppressWarnings("unused")
 private boolean isLegal() {
   try {
     int row = Integer.parseInt(rowField.getText());
     if (row <= 0) {
       HintFrame hint =
           new HintFrame(
               "排数必须为正!", frame.getX(), frame.getY(), frame.getWidth(), frame.getHeight());
       return false;
     }
   } catch (NumberFormatException e) {
     HintFrame hint =
         new HintFrame("排数格式错误!", frame.getX(), frame.getY(), frame.getWidth(), frame.getHeight());
     return false;
   }
   try {
     int place = Integer.parseInt(placeField.getText());
     if (place <= 0) {
       HintFrame hint =
           new HintFrame(
               "每排位数必须为正!", frame.getX(), frame.getY(), frame.getWidth(), frame.getHeight());
       return false;
     }
   } catch (NumberFormatException e) {
     HintFrame hint =
         new HintFrame(
             "每排位数格式错误!", frame.getX(), frame.getY(), frame.getWidth(), frame.getHeight());
     return false;
   }
   return true;
 }
コード例 #2
0
 private void setLocation() {
   if (this.isVisible() && ((Editor) component).centerPanel.isVisible()) {
     int xLocation = component.getX() + component.getWidth();
     int yLocation = ((Editor) component).centerPanel.getLocationOnScreen().y;
     this.setLocation(xLocation, yLocation);
   }
 }
コード例 #3
0
 /** Displays the inventory window */
 public void inventoryWindow() {
   if (inventoryWin != null) {
     inventoryWin.dispose();
   }
   inventoryWin = new JFrame("Inventory");
   inventoryWin.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   Inventory inv = player.getInventory();
   int y = inv.getSize();
   if (y == 0) {
     displayMessage("Inventory is empty");
     return;
   }
   int cols = 2;
   int rows = (y - y % cols) / cols;
   if (y % cols != 0) rows = rows + 1;
   inventoryWin.setLayout(new GridLayout(0, cols * 2));
   for (int i = 0; i < y; i++) {
     JButton b = new JButton(inv.getItem(i).getName());
     inventoryWin.add(b);
     b.addActionListener(this);
     JButton d = new JButton("drop " + inv.getItem(i).getName());
     inventoryWin.add(d);
     d.addActionListener(this);
   }
   // inventoryWin.setBounds(350, 0, 300, 80*rows);
   inventoryWin.setLocation(mainWindow.getX(), mainWindow.getY() + mainWindow.getHeight());
   inventoryWin.pack();
   inventoryWin.setVisible(true);
 }
コード例 #4
0
  /** Displays the character window */
  public void characterWindow() {
    if (characterWindow != null) {
      characterWindow.dispose();
    }
    characterWindow = new JFrame("Character");
    characterWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    JTextField health = new JTextField(player.health());
    health.setEditable(false);

    JButton weapon = new JButton(player.weapon().split(" ")[1]);
    if (player.weapon().split(" ")[1].equals("none")) {
      weapon.setEnabled(false);
    }
    weapon.addActionListener(this);

    JButton armor = new JButton(player.armor().split(" ")[1]);
    if (player.armor().split(" ")[1].equals("none")) {
      armor.setEnabled(false);
    }
    armor.addActionListener(this);

    characterWindow.setBounds(
        mainWindow.getX() + mainWindow.getWidth(), mainWindow.getY(), 200, 150);
    characterWindow.setResizable(false);
    characterWindow.setLayout(new GridLayout(3, 1));
    characterWindow.add(health);
    characterWindow.add(weapon);
    characterWindow.add(armor);

    characterWindow.setVisible(true);
  }
コード例 #5
0
ファイル: FocusUtils.java プロジェクト: xorgate/FrameSwitcher
  public static void requestFocus(Project project, final boolean useRobot) {
    JFrame frame = WindowManager.getInstance().getFrame(project);

    // the only reliable way I found to bring it to the top
    boolean aot = frame.isAlwaysOnTop();
    frame.setAlwaysOnTop(true);
    frame.setAlwaysOnTop(aot);

    int frameState = frame.getExtendedState();
    if ((frameState & Frame.ICONIFIED) == Frame.ICONIFIED) {
      // restore the frame if it is minimized
      frame.setExtendedState(frameState ^ Frame.ICONIFIED);
    }
    frame.toFront();
    frame.requestFocus();
    if (useRobot && runningOnWindows7()) {
      try {
        // remember the last location of mouse
        final Point oldMouseLocation = MouseInfo.getPointerInfo().getLocation();

        // simulate a mouse click on title bar of window
        Robot robot = new Robot();
        robot.mouseMove(frame.getX(), frame.getY());
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

        // move mouse to old location
        robot.mouseMove((int) oldMouseLocation.getX(), (int) oldMouseLocation.getY());
      } catch (Exception ex) {
        // just ignore exception, or you can handle it as you want
      } finally {
        frame.setAlwaysOnTop(false);
      }
    }
  }
コード例 #6
0
 /**
  * @param vViewer
  * @param owner
  */
 private void showDialog(final VisualizationViewer<IVertex, IEdge> vViewer, final JFrame owner) {
   if (this.point != null && this.vertex != null) {
     VertexPropertyDialog dialog = new VertexPropertyDialog(this.vertex, owner, vViewer);
     dialog.setLocation(
         (int) this.point.getX() + owner.getX(), (int) this.point.getY() + owner.getY());
     dialog.setVisible(true);
   }
 }
コード例 #7
0
ファイル: Mouse.java プロジェクト: LukaJCB/pg3b
 public void grab(JFrame grabbedFrame) {
   this.grabbedFrame = grabbedFrame;
   if (grabbedFrame != null && robot != null) {
     x = grabbedFrame.getX() + grabbedFrame.getWidth() / 2;
     y = grabbedFrame.getY() + grabbedFrame.getHeight() / 2;
     robot.mouseMove(x, y);
   }
 }
コード例 #8
0
 /** Creates new form ViewPrompt */
 public ViewPrompt(JFrame f) {
   this.f = f;
   setAlwaysOnTop(true);
   setUndecorated(true);
   initComponents();
   setLocation(
       f.getX() + (f.getWidth() - getWidth()) / 2, f.getY() + (f.getHeight() - getHeight()) / 2);
   setVisible(true);
 }
コード例 #9
0
ファイル: Creator.java プロジェクト: hunter7654/aephyr
 private void updateUI() {
   if (preview.isSelected()) {
     openRemoteUIDefaults(
         "java",
         RemoteUIDefaultsImpl.class.getName(),
         CodeTransfer.THEME_FILE.getPath(),
         Integer.toString(frame.getX() + frame.getWidth()),
         Integer.toString(frame.getY()),
         Integer.toString(previewIndex));
   } else {
     openRemoteUIDefaults(CodeTransfer.THEME_FILE);
   }
 }
コード例 #10
0
 @SuppressWarnings("unchecked")
 private void getAll() {
   ResultMessage message = logicSer.searchShelf(orgId, null);
   if (message.getReInfo().equals(Result.SUCCESS)) {
     shelfList = (ArrayList<ShelfVO>) message.getMessage();
     tableDisplay();
   } else {
     @SuppressWarnings("unused")
     HintFrame hint =
         new HintFrame(
             message.getReInfo(), frame.getX(), frame.getY(), frame.getWidth(), frame.getHeight());
   }
 }
コード例 #11
0
 private void fresh(Result result) {
   if (result.equals(Result.SUCCESS)) {
     if (searchField.getText().equals("")) {
       getAll();
     } else {
       search();
     }
     DoHint.hint(result, frame);
   } else {
     @SuppressWarnings("unused")
     HintFrame hint =
         new HintFrame(result, frame.getX(), frame.getY(), frame.getWidth(), frame.getHeight());
   }
 }
コード例 #12
0
  private void createFrame() {
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    setUndecorated(true);
    getContentPane().setBackground(Color.RED);

    int centerX = parentFrame.getX() + parentFrame.getWidth() / 2;
    int centerY = parentFrame.getY() + parentFrame.getHeight() / 2;
    setBounds(centerX - WIDTH / 2, centerY - HEIGHT / 2, WIDTH, HEIGHT);

    JLabel mainLabel = new JLabel("Please wait while your final changes are being saved.");
    mainLabel.setHorizontalAlignment(SwingConstants.CENTER);
    getContentPane().add(mainLabel, BorderLayout.CENTER);

    setVisible(true);
  }
コード例 #13
0
 @Override
 protected void paintComponent(Graphics g) {
   Graphics2D g_ = (Graphics2D) g;
   // g_.setXORMode(frame.getBackground());
   g_.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   g_.setColor(Color.blue);
   g_.fillRect(frame.getX(), frame.getY(), frame.getWidth(), frame.getHeight());
   g_.setColor(Color.red);
   g_.fill(rect);
   g_.setColor(Color.blue);
   for (Shape shape : toDraw) {
     // System.out.println(shape);
     g_.setColor(Color.black);
     g_.draw(shape);
   }
   doMove();
 }
コード例 #14
0
  /**
   * 构造函数
   *
   * @param panel 主面板
   * @param frame 主窗口
   */
  public AddExceptionLineItemDialog(AddExceptionLineItem panel, JFrame frame) {
    super(frame, true);
    this.frame = frame;
    ((JComponent) this.getContentPane()).setOpaque(true);
    this.panel = panel;
    this.commodityController = ControllerFactoryImpl.getInstance().getCommodityController();
    this.vomap = new HashMap<String, CommodityVO>();
    this.cfg = ERPConfig.getADDEXCEPTIONLINEITEM_DIALOG_CONFIG();

    // 设置大小、坐标、布局
    this.setTitle(cfg.getTitle());
    this.setBounds(cfg.getX(), cfg.getY(), cfg.getW(), cfg.getH());
    this.setLayout(null);
    this.setResizable(false);
    this.setLocation(frame.getX() + this.cfg.getX(), frame.getY() + this.cfg.getY());

    //  初始化组件
    this.initComponent();
    this.setVisible(true);
  }
コード例 #15
0
ファイル: FrameJuego.java プロジェクト: pachecokun/draw-PUM
 public Point getMousePosition() {
   PointerInfo a = MouseInfo.getPointerInfo();
   Point b = a.getLocation();
   b.setLocation(b.getX() - frmDrawPum.getX() - 8, b.getY() - frmDrawPum.getY() - 42);
   return b;
 }
コード例 #16
0
 public boolean isCompletelyOnScreen() {
   Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
   return jFrame.getX() + jFrame.getWidth() < dim.getWidth()
       && jFrame.getY() + jFrame.getHeight() < dim.getHeight();
 }
コード例 #17
0
  public CharSelection(JFrame parent) {
    this.parent = parent;
    JPanel holder = new JPanel();
    GridLayout my_layout = new GridLayout();
    my_layout.setColumns(2);
    my_layout.setRows(5);
    holder.setLayout(my_layout);
    JButton selectArcher = new JButton("Archer");
    JButton selectFighter = new JButton("Fighter");
    JButton selectBlue = new JButton("Blue Caster");
    JButton selectRed = new JButton("Red Caster");
    JButton selectGreen = new JButton("Green Caster");
    JButton selectProphet = new JButton("Prophet");
    JButton upgrade = new JButton("Upgrade Units");
    JButton sell = new JButton("Sell Units");
    holder.add(selectArcher);
    holder.add(selectFighter);
    holder.add(selectBlue);
    holder.add(selectRed);
    holder.add(selectGreen);
    holder.add(selectProphet);
    holder.add(upgrade);
    holder.add(sell);
    sell.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            // TODO Auto-generated method stub
            if (sellpanel.mouse.canSell) sellpanel.setVisible(true);
            else
              JOptionPane.showMessageDialog(
                  charHolder, "you do not have any units to sell at this time.");
          }
        });
    upgrade.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (cu.mouse.canUpgrade) cu.setVisible(true);
            else
              JOptionPane.showMessageDialog(
                  charHolder, "you do not have any units to upgrade at this time.");
          }
        });
    selectArcher.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            FIGHTER = false;
            BLUE = false;
            RED = false;
            GREEN = false;
            PROPHET = false;
            if (!ARCHER) {
              ARCHER = true;
              JOptionPane.showMessageDialog(
                  charHolder,
                  "click on the map to deploy an archer there. deploying an archer costs 1000G");
            } else
              JOptionPane.showMessageDialog(
                  charHolder, "you're currently deploying an archer. do so already.");
          }
        });
    selectFighter.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            ARCHER = false;
            BLUE = false;
            RED = false;
            GREEN = false;
            PROPHET = false;
            if (!FIGHTER) {
              FIGHTER = true;
              JOptionPane.showMessageDialog(
                  charHolder,
                  "click on the map to deploy a fighter there. deploying a fighter costs 1500G");
            } else
              JOptionPane.showMessageDialog(
                  charHolder, "you're currently deploying a fighter. do so already.");
          }
        });
    selectBlue.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            ARCHER = false;
            FIGHTER = false;
            RED = false;
            GREEN = false;
            PROPHET = false;
            if (!BLUE) {
              BLUE = true;
              JOptionPane.showMessageDialog(
                  charHolder,
                  "click on the map to deploy a blue mage there. deploying a blue mage costs 2000G");
            } else
              JOptionPane.showMessageDialog(
                  charHolder, "you're currently deploying a blue mage. do so already.");
          }
        });
    selectRed.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            ARCHER = false;
            FIGHTER = false;
            BLUE = false;
            GREEN = false;
            PROPHET = false;
            if (!RED) {
              RED = true;
              JOptionPane.showMessageDialog(
                  charHolder,
                  "click on the map to deploy a red mage there. deploying a red mage costs 2000G");
            } else
              JOptionPane.showMessageDialog(
                  charHolder, "you're currently deploying a red mage. do so already.");
          }
        });
    selectGreen.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            ARCHER = false;
            FIGHTER = false;
            BLUE = false;
            RED = false;
            PROPHET = false;
            if (!GREEN) {
              GREEN = true;
              JOptionPane.showMessageDialog(
                  charHolder,
                  "click on the map to deploy a green mage there. deploying a green mage costs 2000G");
            } else
              JOptionPane.showMessageDialog(
                  charHolder, "you're currently deploying a green mage. do so already.");
          }
        });
    selectProphet.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            ARCHER = false;
            FIGHTER = false;
            BLUE = false;
            RED = false;
            GREEN = false;
            if (!PROPHET) {
              PROPHET = true;
              JOptionPane.showMessageDialog(
                  charHolder,
                  "click on the map to deploy a prophet there. deploying a prophet costs 5000G");
            } else
              JOptionPane.showMessageDialog(
                  charHolder, "you're currently deploying a prophet. do so already.");
          }
        });
    charHolder.add(holder);
    charHolder.pack();
    charHolder.setLocation(parent.getX() + 27, parent.getY() + 220);
  }
コード例 #18
0
 public void reposition() {
   setLocation(
       f.getX() + (f.getWidth() - getWidth()) / 2, f.getY() + (f.getHeight() - getHeight()) / 2);
 }