public FenetrePrincipale(PlanSalle modele) {
    super();
    this.modele = modele;
    this.setTitle(modele.getNom() + " - OSE");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.creerBarreMenus();
    this.creerMenuContextuel();
    JLayeredPane lp = new JLayeredPane();
    lp.setPreferredSize(
        new Dimension(
            Parametres.NB_TRAVEES * Parametres.LARGEUR_TRAVEE,
            Parametres.NB_RANGEES * Parametres.HAUTEUR_RANGEE));
    lePlan = new Plan(modele);
    lePlan.setBounds(
        0,
        0,
        Parametres.NB_TRAVEES * Parametres.LARGEUR_TRAVEE,
        Parametres.NB_RANGEES * Parametres.HAUTEUR_RANGEE);
    lp.add(lePlan, new Integer(0));
    Container conteneur = this.getContentPane();
    conteneur.setLayout(new FlowLayout());

    conteneur.add(lp);
    this.pack();
    this.setLocationRelativeTo(null);
    this.setVisible(true);
  }
Esempio n. 2
0
  /**
   * The constructor for the class It's going to set the dimension of the program to 600x600, the
   * background is going to be white (in order to blend in with the vor image), and it is going to
   * add in the VOR radar and a radial indicator that will let the user know which radial he/she is
   * on
   */
  public finalVORGUI(int r) {
    deg = r;
    this.vor = new VorReceiver(deg, ".- -... -.-.");
    this.vor.setOBS(90); // set the OBS to 30
    JLayeredPane lp = new JLayeredPane();
    lp.setPreferredSize(new Dimension(WIDTH, HEIGHT));
    setBackground(Color.white);
    lp.setLayout(null);
    lp.setFocusable(true);
    degrees = deg; // r is intended radial
    CurrentRadial =
        new JLabel(
            "Intended Radial: "
                + deg); // A string that is always going to be above the radar. it's going to let
    // the user know the current radial
    CurrentRadial.setBounds(220, 18, 200, 200);
    MorseCode = new JLabel("Station: TO ENTER HERE");
    MorseCode.setBounds(200, 500, 200, 50);
    MorseCode.setText("Station: " + this.vor.getMorse());

    // vor.printVorStatus_v1();
    rotationPanel = new JPanel();
    rotationPanel = new TurningCanvas();
    rotationPanel.setBounds(
        157, 125, rotationPanel.getPreferredSize().width, rotationPanel.getPreferredSize().height);
    needle = new JPanel();
    needle = new DrawAttributes();
    needle.setBounds(100, 0, needle.getPreferredSize().width, needle.getPreferredSize().height);
    OBS = new JPanel();
    OBS = new AddButtons();
    OBS.setBounds(110, 350, 200, 100);
    lp.add(rotationPanel, Integer.valueOf(1));
    lp.add(needle, Integer.valueOf(2));
    lp.add(OBS, Integer.valueOf(3));
    lp.add(CurrentRadial, Integer.valueOf(4));
    lp.add(MorseCode, Integer.valueOf(5));
    add(lp);

    x = 172; // x is the location of the needle
    y1 = 155;
    y2 = 330;
  }
 /**
  * This method adds the panels to the window and organises them using a GridBagLayout and a
  * JLayeredPane.
  */
 private void populateFrame(Container frame) {
   frame.setLayout(new GridBagLayout());
   GridBagConstraints layoutConstraints = new GridBagConstraints();
   JLayeredPane dungeonArea = new JLayeredPane();
   dungeonArea.setPreferredSize(new Dimension(448, 448));
   dungeonArea.add(dungeonPanel, JLayeredPane.DEFAULT_LAYER);
   // the DungeonPanel is added underneath
   dungeonArea.add(dungeonPanelOverlay, JLayeredPane.PALETTE_LAYER);
   // the mostly transparent DungeonPanelOverlay is added on top in the same position
   layoutConstraints.gridx = 0;
   layoutConstraints.gridy = 0;
   layoutConstraints.gridwidth = 7;
   layoutConstraints.gridheight = 7;
   frame.add(dungeonArea, layoutConstraints);
   layoutConstraints.gridx = 7;
   layoutConstraints.gridwidth = 1;
   frame.add(serverSettings, layoutConstraints);
   layoutConstraints.gridx = 0;
   layoutConstraints.gridy = 7;
   layoutConstraints.gridwidth = 8;
   layoutConstraints.gridheight = 1;
   frame.add(chatPanel, layoutConstraints);
 }
Esempio n. 4
0
  public TestPanel(Player p) {
    super();
    player = p;
    layeredPane.setPreferredSize(new Dimension(300, 300));

    money = new JLabel("Money: $" + player.getMoney());
    product = new JLabel("Product: " + player.getProduct());
    risk = new JLabel("Risk: " + getRisk() + "%");

    JButton buy = new JButton("Buy RV");
    buy.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            buy();
          }
        });

    JButton sell = new JButton("Sell RV");
    sell.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            sell();
          }
        });

    JButton collect = new JButton("Collect");
    collect.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            collect();
          }
        });

    JButton cook = new JButton("cook");
    cook.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cook();
          }
        });

    layeredPane.add(money, new Integer(0));
    money.setBounds(0, 0, 100, 20);

    layeredPane.add(product, new Integer(0));
    product.setBounds(0, 20, 100, 20);

    layeredPane.add(risk, new Integer(0));
    risk.setBounds(0, 40, 100, 20);

    layeredPane.add(buy, new Integer(0));
    buy.setBounds(100, 0, 101, 30);

    layeredPane.add(sell, new Integer(0));
    sell.setBounds(100, 30, 101, 30);

    layeredPane.add(collect, new Integer(0));
    collect.setBounds(100, 60, 101, 30);

    layeredPane.add(cook, new Integer(0));
    cook.setBounds(100, 90, 101, 30);

    add(layeredPane);
    (new Thread(new StartGame())).start();
  }