private void initPanel() {
    JLabel sizeLabel = new JLabel("capacity");
    sizeLabel.setBounds(5, 5, 900, 25);
    add(sizeLabel);
    roomSize = new RestrictedTextField(RestrictedTextField.RESTRICTION_INT, -1);
    roomSize.setBounds(sizeLabel.getX(), sizeLabel.getY() + sizeLabel.getHeight() + 5, 150, 25);
    roomSize.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent arg0) {
            room.setcapacity(Integer.parseInt(roomSize.getText()));
            editVector.add(new Wrapper<Room>(room, Edit.edited));
          }

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}
        });
    add(roomSize);

    JLabel hardwareLabel = new JLabel("Harware");
    hardwareLabel.setBounds(roomSize.getX(), roomSize.getY() + 20, 900, 25);
    add(hardwareLabel);
    hardwarePanel = new HardwarePanel(hardwares, editVector);
    JScrollPane scroll = new JScrollPane(hardwarePanel);
    scroll.setBounds(
        hardwareLabel.getX(), hardwareLabel.getY() + hardwareLabel.getHeight() + 5, 320, 150);
    add(scroll);
  }
  public void getNextHero() {
    anyHero = this.heroManager.getHero();

    ImageIcon icon1 = anyHero.getIcon(0);
    Image image1 = icon1.getImage();
    Image resizedImage1 = image1.getScaledInstance(photo1.getWidth(), photo1.getHeight(), 0);
    photo1.setIcon(new ImageIcon(resizedImage1));

    ImageIcon icon2 = anyHero.getIcon(1);
    Image image2 = icon2.getImage();
    Image resizedImage2 = image2.getScaledInstance(photo2.getWidth(), photo2.getHeight(), 0);
    photo2.setIcon(new ImageIcon(resizedImage2));

    ImageIcon icon3 = anyHero.getIcon(2);
    Image image3 = icon3.getImage();
    Image resizedImage3 = image3.getScaledInstance(photo3.getWidth(), photo3.getHeight(), 0);
    photo3.setIcon(new ImageIcon(resizedImage3));
    // prosarmogh eikonwn sta label

    System.out.println(anyHero.getName());
    // yparxei boithitika gia na fainetai to onoma

    nameArea.setText("");
    // katharizei to textArea

  }
  /** Create the frame. */
  public VentanaSugerencias() {
    getContentPane().setBackground(Color.DARK_GRAY);
    setBounds(100, 100, 587, 576);
    getContentPane().setLayout(null);
    txtCAS = new JTextArea();
    textPane = new JScrollPane();
    textPane.setBounds(55, 150, 464, 353);
    textPane.setViewportView(txtCAS);
    getContentPane().add(textPane);

    lblLabelenviar = new JLabel("");
    lblLabelenviar.setBounds(416, 29, 103, 91);
    iconoEnviar =
        new ImageIcon(
            new ImageIcon(VentanaSugerencias.class.getResource("/Imagenes/enviar.png"))
                .getImage()
                .getScaledInstance(
                    lblLabelenviar.getWidth(), lblLabelenviar.getHeight(), Image.SCALE_DEFAULT));
    lblLabelenviar.setIcon(iconoEnviar);
    getContentPane().add(lblLabelenviar);

    JLabel lblQuejasYSugerencias = new JLabel("Quejas y sugerencias");
    lblQuejasYSugerencias.setFont(new Font("Tahoma", Font.PLAIN, 25));
    lblQuejasYSugerencias.setForeground(Color.WHITE);
    lblQuejasYSugerencias.setBounds(71, 61, 264, 46);
    getContentPane().add(lblQuejasYSugerencias);
  }
Beispiel #4
0
 private void drawCircle(int tokenID, int tokenTile) {
   int circleXPos =
       tileCoordinates[tokenTile][0] - (circle.getWidth() - tokens.get(tokenID).getWidth()) / 2;
   int circleYPos =
       tileCoordinates[tokenTile][1] - (circle.getHeight() - tokens.get(tokenID).getHeight()) / 2;
   circle.setLocation(circleXPos, circleYPos);
 }
Beispiel #5
0
  /**
   * Spusti se pri zmacknuti tlacitka. Pokud je pod mysi obraz figury, zjisti, zda se muze pohnout
   * (pokud ano, upravi ho pro tahnuti, nastavi ho do figLabel) a zobrazi kontextovou napovedu.
   */
  private void eCatcherMousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_eCatcherMousePressed
    if (figLabel != null || finished) {
      return;
    }
    BoardSquare bsquare = (BoardSquare) eCatcher.getComponentAt(evt.getPoint());

    JPanel fsquare = (JPanel) figurePan.getComponent(bsquare.getIndex());
    sourceBSquare = bsquare;
    Point defLocation = fsquare.getLocation();
    xAdjustment = (int) defLocation.getX() - evt.getX();
    yAdjustment = (int) defLocation.getY() - evt.getY();
    if (fsquare.getComponentCount() == 0) {
      return;
    }
    figLabel = (JLabel) fsquare.getComponent(0);

    setFocus(gui.getFocus(bsquare.getColumn(), bsquare.getRow()));
    if (!gui.canMove(bsquare.getColumn(), bsquare.getRow())) {
      figLabel = null;
      return;
    }
    fsquare.remove(figLabel);
    boardPane.add(figLabel, 0);
    figLabel.setLocation(evt.getX() + xAdjustment, evt.getY() + yAdjustment);
    figLabel.setSize(figLabel.getWidth(), figLabel.getHeight());
  } // GEN-LAST:event_eCatcherMousePressed
Beispiel #6
0
 private static void updateWindow(JLabel imagePane, Mat mat) {
   int w = (int) (mat.size().width);
   int h = (int) (mat.size().height);
   if (imagePane.getWidth() != w || imagePane.getHeight() != h) {
     imagePane.setSize(w, h);
   }
   BufferedImage bufferedImage = Mat2Image.getImage(mat);
   imagePane.setIcon(new ImageIcon(bufferedImage));
 }
  /**
   * Returns the drag icon used to represent a cell in all drag operations.
   *
   * @param tree the parent tree object
   * @param dragObject the dragged object
   * @param index the index of the dragged object in the tree
   * @return the drag icon
   */
  public Icon getDragIcon(JTree tree, Object dragObject, int index) {
    ContactListTreeCellRenderer dragC =
        (ContactListTreeCellRenderer)
            getTreeCellRendererComponent(
                tree,
                dragObject,
                false, // is selected
                false, // is expanded
                true, // is leaf
                index,
                true // has focus
                );

    // We should explicitly set the bounds of all components in order that
    // they're correctly painted by paintIcon afterwards. This fixes empty
    // drag component in contact list!
    dragC.setBounds(0, 0, dragC.getIconWidth(), dragC.getIconHeight());

    Icon rightLabelIcon = rightLabel.getIcon();
    int imageHeight = 0;
    int imageWidth = 0;
    if (rightLabelIcon != null) {
      imageWidth = rightLabelIcon.getIconWidth();
      imageHeight = rightLabelIcon.getIconHeight();
      dragC.rightLabel.setBounds(tree.getWidth() - imageWidth, 0, imageWidth, imageHeight);
    }

    dragC.statusLabel.setBounds(0, 0, statusLabel.getWidth(), statusLabel.getHeight());

    dragC.nameLabel.setBounds(
        statusLabel.getWidth(), 0, tree.getWidth() - imageWidth - 5, nameLabel.getHeight());

    dragC.displayDetailsLabel.setBounds(
        displayDetailsLabel.getX(),
        nameLabel.getHeight(),
        displayDetailsLabel.getWidth(),
        displayDetailsLabel.getHeight());

    return dragC;
  }
Beispiel #8
0
  @Override
  public void paintComponent(Graphics g) {
    final JLabel lbl = CHomeUI.SINGLETON_INSTANCE.getLblSelected();
    int yTop = (lbl.getY() + lbl.getParent().getY());

    // super.paintComponent(g);
    final Graphics2D g2d = (Graphics2D) g.create();
    final int w = getWidth();
    final int h = getHeight();

    FSkin.setGraphicsColor(g2d, d20);

    // Selected in this group, don't draw background under selected label.
    if (getY() < yTop && yTop < getY() + h) {
      g2d.fillRect(0, 0, w, lbl.getY());
      g2d.fillRect(0, lbl.getY() + lbl.getHeight(), w, h);

      FSkin.setGraphicsGradientPaint(g2d, w - 8, 0, l00, w, 0, d80);
      g2d.fillRect(w - 6, 0, w, lbl.getY());
      g2d.fillRect(w - 6, lbl.getY() + lbl.getHeight(), w, h);
    }
    // Selected not in this group; draw full background.
    else {
      g2d.fillRect(0, 0, w, h);

      FSkin.setGraphicsGradientPaint(g2d, w - 8, 0, l00, w, 0, d80);
      g2d.fillRect(w - 6, 0, w, h);
    }

    FSkin.setGraphicsColor(g2d, l10);
    g2d.drawLine(0, h - 1, w - 1, h - 1);

    FSkin.setGraphicsColor(g2d, d60);
    g2d.drawLine(0, 0, w - 1, 0);

    g2d.dispose();
  }
    public static Image createImage(final JTree tree) {
      final TreeSelectionModel model = tree.getSelectionModel();
      final TreePath[] paths = model.getSelectionPaths();

      int count = 0;
      final List<ChangesBrowserNode> nodes = new ArrayList<ChangesBrowserNode>();
      for (final TreePath path : paths) {
        final ChangesBrowserNode node = (ChangesBrowserNode) path.getLastPathComponent();
        if (!node.isLeaf()) {
          nodes.add(node);
          count += node.getCount();
        }
      }

      for (TreePath path : paths) {
        final ChangesBrowserNode element = (ChangesBrowserNode) path.getLastPathComponent();
        boolean child = false;
        for (final ChangesBrowserNode node : nodes) {
          if (node.isNodeChild(element)) {
            child = true;
            break;
          }
        }

        if (!child) {
          if (element.isLeaf()) count++;
        } else if (!element.isLeaf()) {
          count -= element.getCount();
        }
      }

      final JLabel label = new JLabel(VcsBundle.message("changes.view.dnd.label", count));
      label.setOpaque(true);
      label.setForeground(tree.getForeground());
      label.setBackground(tree.getBackground());
      label.setFont(tree.getFont());
      label.setSize(label.getPreferredSize());
      final BufferedImage image =
          new BufferedImage(label.getWidth(), label.getHeight(), BufferedImage.TYPE_INT_ARGB);

      Graphics2D g2 = (Graphics2D) image.getGraphics();
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
      label.paint(g2);
      g2.dispose();

      return image;
    }
  void displayWifiPassword() {
    Config config = Config.instance();
    config.setEmail(emailField.getText());
    config.setRememberPassword(rememberPasswordCheckbox.getState());
    config.setPassword(passField.getText());

    config.updateConfig();

    if (Config.instance().getQRImage() == null || Config.instance().getWifiPassword().isEmpty()) {
      if (Config.instance().getWifiPassword().isEmpty()) {
        wifiPasswordField.setText("");
      }

      hintLabel.setText("QRCode has not been generated");
      qrCodeLabel.setIcon(idleIcon);
      return;
    }

    try {

      wifiPasswordField.setText(Config.instance().getWifiPassword());

      BufferedImage qrImage = Config.instance().getQRImage();

      int width = qrCodeLabel.getWidth();
      int height = qrCodeLabel.getHeight();

      // make a square image
      int length = width < height ? width : height;

      ImageIcon imgIcon = new ImageIcon();
      imgIcon.setImage(qrImage.getScaledInstance(length, length, Image.SCALE_AREA_AVERAGING));

      hintLabel.setText("Scan QRCode with mobile client to login clear-guest!");
      wifiPasswordField.setText(Config.instance().getWifiPassword());
      qrCodeLabel.setIcon(imgIcon);
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          mainPanel,
          "Failed to generate QR Image, please try again",
          "QRCode Generation Failed",
          JOptionPane.ERROR_MESSAGE);
      e.printStackTrace();
    }
  }
 /**
  * show date chooser panel
  *
  * @param owner: {@link Component}
  */
 private void showPanel(Component owner) {
   if (pop != null) {
     pop.hide();
   }
   Point show = new Point(0, showDate.getHeight());
   SwingUtilities.convertPointToScreen(show, showDate);
   Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
   int x = show.x;
   int y = show.y;
   if (x < 0) {
     x = 0;
   }
   if (x > size.width - 380) {
     x = size.width - 380;
   }
   if (y < size.height - 170) {
   } else {
     y -= 188;
   }
   pop = PopupFactory.getSharedInstance().getPopup(owner, monthPanel, x, y);
   pop.show();
   isShow = true;
 }
    @Override
    public Pair<Image, Point> createDraggedImage(DnDAction action, Point dragOrigin) {
      final TreePath[] paths = getSelectionPaths();
      if (paths == null) return null;

      final int count = paths.length;

      final JLabel label = new JLabel(String.format("%s item%s", count, count == 1 ? "" : "s"));
      label.setOpaque(true);
      label.setForeground(myTree.getForeground());
      label.setBackground(myTree.getBackground());
      label.setFont(myTree.getFont());
      label.setSize(label.getPreferredSize());
      final BufferedImage image =
          UIUtil.createImage(label.getWidth(), label.getHeight(), BufferedImage.TYPE_INT_ARGB);

      Graphics2D g2 = (Graphics2D) image.getGraphics();
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
      label.paint(g2);
      g2.dispose();

      return new Pair<Image, Point>(
          image, new Point(-image.getWidth(null), -image.getHeight(null)));
    }
  public void dessinerComposants() {
    process.setBounds(50, 20, process.getWidth(), process.getHeight());

    infos.setBounds(175, 600, infos.getWidth(), infos.getHeight());
    infos_coups.setBounds(600, 600, infos_coups.getWidth(), infos_coups.getHeight());

    imageTower1.setBounds(tower1TopLeft, 100, imageTower1.getWidth(), imageTower1.getHeight());
    imageTower2.setBounds(tower2TopLeft, 100, imageTower2.getWidth(), imageTower2.getHeight());
    imageTower3.setBounds(tower3TopLeft, 100, imageTower3.getWidth(), imageTower3.getHeight());

    buttonTower1.setBounds(
        tower1TopLeft + 25, 520, buttonTower1.getWidth(), buttonTower1.getHeight());
    buttonTower2.setBounds(
        tower2TopLeft + 25, 520, buttonTower2.getWidth(), buttonTower2.getHeight());
    buttonTower3.setBounds(
        tower3TopLeft + 25, 520, buttonTower3.getWidth(), buttonTower3.getHeight());

    // dessiner dynamiquement
    this.dessinerComposantsDynamiques(stackTower1, imageTower1, tower1TopLeft);
    this.dessinerComposantsDynamiques(stackTower2, imageTower2, tower2TopLeft);
    this.dessinerComposantsDynamiques(stackTower3, imageTower3, tower3TopLeft);
  }
  public void loadComponent() {
    this.removeAll();
    JLabel sep2 = new JLabel();
    sep2.setBounds(0, 40, FRAME_WIDTH, 1);
    sep2.setBorder(BorderFactory.createLineBorder(ColorUtils.Separator));
    this.add(sep2);

    JLabel title = new JLabel();
    title.setBounds(FRAME_WIDTH / 8, 0, FRAME_WIDTH * 3 / 4, 40);
    title.setText("<html><h1>" + scheda.title + "</html>");
    title.setHorizontalAlignment(JLabel.CENTER);
    this.add(title);

    ImageButton backbt =
        new ImageButton(
            ImageUtils.getImage("gui/icon32px/arrow_left.png"),
            ImageUtils.getImage("gui/icon32px/arrow_left_over.png"),
            ImageUtils.getImage("gui/icon32px/arrow_left_over.png"),
            BackGui);
    backbt.setBounds(5, 5, 32, 32);
    backbt.setToolTipText("Indietro");
    this.add(backbt);

    ImageButton homePage =
        new ImageButton(
            ImageUtils.getImage("gui/icon32px/home.png"),
            ImageUtils.getImage("gui/icon32px/home_over.png"),
            ImageUtils.getImage("gui/icon32px/home_over.png"),
            OpenHomePage);
    homePage.setBounds(40, 5, 32, 32);
    homePage.setToolTipText("Home");
    this.add(homePage);

    if (cover == null) cover = new JLabel();

    if ((int) ((FRAME_WIDTH / 4) * 1.49) < FRAME_HEIGHT / 2)
      cover.setBounds(20, 80, FRAME_WIDTH / 4, (int) ((FRAME_WIDTH / 4) * 1.5));
    else cover.setBounds(20, 80, (int) ((FRAME_HEIGHT / 2) * 0.67), FRAME_HEIGHT / 2);

    cover.setBorder(BorderFactory.createEtchedBorder());
    cover.setIcon(
        ImageUtils.getIcon(
            ImageUtils.scaleImage(
                scheda.initPoster_w500(cover), cover.getWidth(), cover.getHeight())));

    add(cover);

    text = new JEditorPane();
    text.setEditable(false);
    text.setHighlighter(null);
    text.setOpaque(false);
    text.setContentType("text/html");
    text.setText("<html><h2>" + scheda.desc + "</html>");
    text.setBorder(BorderFactory.createEmptyBorder());
    text.setBackground(ColorUtils.Trasparent);

    scroll = new JScrollPane(text);
    scroll.setFocusable(true);
    scroll.setBorder(BorderFactory.createEmptyBorder());
    scroll.setBackground(ColorUtils.Trasparent);

    if ((int) ((FRAME_WIDTH / 4) * 1.49) < FRAME_HEIGHT / 2)
      scroll.setBounds(
          FRAME_WIDTH / 4 + 60,
          80,
          FRAME_WIDTH - (FRAME_WIDTH / 4 + 80),
          (int) ((FRAME_WIDTH / 4) * 1.49) - 35);
    else
      scroll.setBounds(
          (int) ((FRAME_HEIGHT / 2) * 0.67) + 60,
          80,
          FRAME_WIDTH - ((int) ((FRAME_HEIGHT / 2) * 0.67) + 80),
          FRAME_HEIGHT / 2 - 35);

    scroll.setOpaque(false);
    scroll.setVisible(false);
    this.add(scroll);
    ThreadManager.submitCacheTask(UpdateText);

    info = new JLabel();
    if ((int) ((FRAME_WIDTH / 4) * 1.49) < FRAME_HEIGHT / 2)
      info.setBounds(
          FRAME_WIDTH / 4 + 60,
          (int) ((FRAME_WIDTH / 4) * 1.49) + 50,
          FRAME_WIDTH - (FRAME_WIDTH / 4 + 80),
          30);
    else
      info.setBounds(
          (int) ((FRAME_HEIGHT / 2) * 0.67) + 60,
          FRAME_HEIGHT / 2 + 50,
          FRAME_WIDTH - ((int) ((FRAME_HEIGHT / 2) * 0.67) + 80),
          30);

    info.setText(
        "<html><h4> "
            + "Data di Uscita: "
            + scheda.relese
            + "<br>"
            + "Generi: "
            + scheda.getGeneri()
            + "</html>");
    info.setVisible(true);
    this.add(info);
    drawRating();

    downloads =
        new ImageButton(
            ImageUtils.getImage("gui/icon64px/download.png"),
            ImageUtils.getImage("gui/icon64px/download_over.png"),
            ImageUtils.getImage("gui/icon64px/download_over.png"),
            OpenDownloads);
    downloads.setBounds((FRAME_WIDTH - 64) / 2, FRAME_HEIGHT - 100, 64, 64);
    downloads.setVisible(!syncRunning);
    downloads.setToolTipText("Scarica");
    this.add(downloads);

    sync = new AnimatedImageButton("SyncBig(n)", 5, null, 500);
    sync.setBounds((FRAME_WIDTH - 64) / 2, FRAME_HEIGHT - 100, 64, 64);
    sync.setToolTipText("Sincronizzazione con il server Attedere qualche secondo");
    sync.setVisible(syncRunning);
    this.add(sync);

    if (backGround == null) {
      backGround = new JLabel();
      scheda.initBack_w1920(backGround);
    }

    backGround.setBounds(0, 0, FRAME_WIDTH, FRAME_HEIGHT);

    if (scheda.back_w1920 != null) {
      if (backGround.getWidth() > backGround.getHeight()) {
        BufferedImage img =
            ImageUtils.scaleWithAspectHeight(scheda.back_w1920, backGround.getHeight());
        if (img.getWidth() < backGround.getWidth())
          img = ImageUtils.scaleWithAspectWidth(scheda.back_w1920, backGround.getWidth());
        backGround.setIcon(ImageUtils.getIcon(img));
      } else {
        BufferedImage img =
            ImageUtils.scaleWithAspectWidth(scheda.back_w1920, backGround.getWidth());
        if (img.getHeight() < backGround.getHeight())
          img = ImageUtils.scaleWithAspectHeight(scheda.back_w1920, backGround.getHeight());
        backGround.setIcon(ImageUtils.getIcon(img));
      }
    }
    this.add(backGround);
    super.loadComponent();
  }
 // Make Duke follow the cursor.
 public void mouseMoved(MouseEvent e) {
   dukeLabel.setLocation(
       e.getX() - dukeLabel.getWidth() / 2, e.getY() - dukeLabel.getHeight() / 2);
 }
  private void jbInit() throws Exception {

    this.setJMenuBar(menuBar);
    this.getContentPane().setLayout(layoutMain);
    panelCenter.setLayout(null);

    this.setTitle("Facturas Taxi. Mariano y Conchi");
    menuFile.setText("Archivo");
    menuFileExit.setText("Salir");
    menuFileExit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            fileExit_ActionPerformed(ae);
          }
        });
    menuHelp.setText("Ayuda");
    menuHelpAbout.setText("Sobre");
    menuHelpAbout.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            helpAbout_ActionPerformed(ae);
          }
        });
    statusBar.setText("");
    buttonOpen.setToolTipText("Abrir Ficha Cliente");
    buttonOpen.setIcon(imageOpen);
    buttonOpen.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            abrirFicheroExpediente();
          }
        });

    buttonClose.setToolTipText("Guardar Ficha Cliente");
    buttonClose.setIcon(imageClose);
    buttonClose.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {

            if (validarMinimosRellenos()) {
              preguntarGuardar();
            }
          }
        });

    buttonHelp.setToolTipText("About");
    buttonHelp.setIcon(imageHelp);
    jPanel1.setBounds(new Rectangle(-5, 0, 530, 165));
    jPanel1.setLayout(null);
    jTable1.setShowGrid(true);
    jScrollPane1.setBounds(new Rectangle(0, 135, 490, 135));
    jScrollPane1.setBounds(new Rectangle(125, 135, 2, 2));

    jButton1.setText("Imprimir");
    jButton1.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            imprimirjButton_mouseClicked(e);
          }
        });
    insertarjButton.setText("Insertar Fila");

    insertarjButton.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            insertarjButton_mouseClicked(e);
          }
        });

    ponerTextoLabel(jLabelNombreCompanyia, nombreCompanyiajTextField1, "Nombre Compañía");
    jLabelNombreCompanyia.setBounds(new Rectangle(10, 5, 95, 20));

    nombreCompanyiajTextField1.setBounds(
        jLabelNombreCompanyia.getX() + jLabelNombreCompanyia.getWidth(),
        jLabelNombreCompanyia.getY(),
        270,
        jLabelNombreCompanyia.getHeight());

    ponerTextoLabel(jLabelNumeroFactura, numeroFacturajTextField1, "Nº Factura");
    jLabelNumeroFactura.setBounds(
        new Rectangle(
            nombreCompanyiajTextField1.getX()
                + nombreCompanyiajTextField1.getWidth()
                + SEPARACION_X,
            nombreCompanyiajTextField1.getY(),
            60,
            jLabelNombreCompanyia.getHeight()));

    numeroFacturajTextField1.setBounds(
        new Rectangle(
            jLabelNumeroFactura.getX() + jLabelNumeroFactura.getWidth(),
            nombreCompanyiajTextField1.getY(),
            65,
            jLabelNombreCompanyia.getHeight()));

    ponerTextoLabel(jLabelDireccion, direccionCompnanyia, "Dirección");
    jLabelDireccion.setBounds(
        new Rectangle(
            jLabelNombreCompanyia.getX(),
            jLabelNombreCompanyia.getHeight() + SEPARACION_Y,
            155,
            jLabelNombreCompanyia.getHeight()));
    // direccionCompnanyia.setBounds(new
    // Rectangle(nombreCompanyiajTextField1.getX(), jLabelDireccion.getY(),
    // 350, 40));
    scrollPane.setBounds(nombreCompanyiajTextField1.getX(), jLabelDireccion.getY(), 155, 60);

    ponerTextoLabel(jLabel6Ciudad, ciudadjTextField, "Ciudad");
    jLabel6Ciudad.setBounds(
        new Rectangle(
            jLabelDireccion.getX(),
            scrollPane.getY() + scrollPane.getHeight() + SEPARACION_Y,
            50,
            jLabelNombreCompanyia.getHeight()));
    ciudadjTextField.setBounds(
        new Rectangle(
            jLabel6Ciudad.getX() + jLabel6Ciudad.getWidth(),
            jLabel6Ciudad.getY(),
            110,
            jLabelNombreCompanyia.getHeight()));

    ponerTextoLabel(jLabel7CP, codigoPostaljTextField, "CP");
    jLabel7CP.setBounds(
        new Rectangle(
            ciudadjTextField.getX() + ciudadjTextField.getWidth() + SEPARACION_X,
            ciudadjTextField.getY(),
            45,
            jLabelNombreCompanyia.getHeight()));
    codigoPostaljTextField.setBounds(
        new Rectangle(
            jLabel7CP.getX() + jLabel7CP.getWidth(),
            jLabel7CP.getY(),
            85,
            jLabelNombreCompanyia.getHeight()));

    ponerTextoLabel(jLabelFecha, fechajTextField, "Fecha de Facturación");
    jLabelFecha.setBounds(
        new Rectangle(
            codigoPostaljTextField.getX() + codigoPostaljTextField.getWidth() + SEPARACION_X,
            codigoPostaljTextField.getY(),
            110,
            jLabelNombreCompanyia.getHeight()));
    fechajTextField.setBounds(
        new Rectangle(
            jLabelFecha.getX() + jLabelFecha.getWidth(),
            jLabelFecha.getY(),
            70,
            jLabelNombreCompanyia.getHeight()));

    ponerTextoLabel(jLabel8Telefono, telefonojTextField, "Teléfono");
    jLabel8Telefono.setBounds(
        new Rectangle(
            jLabel6Ciudad.getX(),
            jLabel6Ciudad.getY() + jLabel6Ciudad.getHeight() + SEPARACION_Y,
            jLabel6Ciudad.getWidth(),
            jLabel6Ciudad.getHeight()));
    telefonojTextField.setBounds(
        new Rectangle(
            jLabel8Telefono.getX() + jLabel8Telefono.getWidth(),
            jLabel8Telefono.getY(),
            ciudadjTextField.getWidth(),
            jLabelNombreCompanyia.getHeight()));
    // telefonojTextField.setDocument( new VentanaPrincipal(13));

    ponerTextoLabel(jLabelCIF, cifjTextField2, "CIF/NIF");
    jLabelCIF.setBounds(
        new Rectangle(
            telefonojTextField.getX() + telefonojTextField.getWidth() + SEPARACION_X,
            jLabel8Telefono.getY(),
            45,
            jLabelNombreCompanyia.getHeight()));
    cifjTextField2.setBounds(
        new Rectangle(
            jLabelCIF.getX() + jLabelCIF.getWidth(),
            jLabelCIF.getY(),
            codigoPostaljTextField.getWidth(),
            jLabelNombreCompanyia.getHeight()));

    jScrollPaneTabla.setBounds(
        new Rectangle(
            jLabel8Telefono.getX(),
            jLabelCIF.getY() + jLabelCIF.getHeight() + SEPARACION_Y,
            505,
            175));

    insertarjButton.setBounds(
        new Rectangle(
            200, jScrollPaneTabla.getY() + jScrollPaneTabla.getHeight() + SEPARACION_Y, 130, 20));

    this.setSize(new Dimension(531, 451));

    menuFile.add(menuFileExit);
    menuBar.add(menuFile);
    menuHelp.add(menuHelpAbout);
    menuBar.add(menuHelp);
    this.getContentPane().add(statusBar, BorderLayout.SOUTH);
    toolBar.add(buttonOpen);
    toolBar.add(buttonClose);
    toolBar.add(buttonHelp);
    toolBar.add(jButton1, null);
    this.getContentPane().add(toolBar, BorderLayout.NORTH);
    this.getContentPane().add(panelCenter, BorderLayout.CENTER);

    jPanel1.add(jLabel8Telefono, null);
    jPanel1.add(codigoPostaljTextField, null);
    jPanel1.add(jLabel7CP, null);
    jPanel1.add(jLabel6Ciudad, null);
    jPanel1.add(ciudadjTextField, null);
    jPanel1.add(jScrollPane1, null);
    jPanel1.add(cifjTextField2, null);
    jPanel1.add(jLabelCIF, null);
    jPanel1.add(fechajTextField, null);
    jPanel1.add(jLabelFecha, null);
    jPanel1.add(numeroFacturajTextField1, null);
    jPanel1.add(jLabelNumeroFactura, null);
    jPanel1.add(jLabelNombreCompanyia, null);
    jPanel1.add(nombreCompanyiajTextField1, null);

    jPanel1.add(jLabelDireccion, null);

    // jTable1
    // _panelScroll.add(jTable1);

    // jPanel1.add(scrollPane, new GridBagConstraints(3, 0, 1, 1, 1.0, 1.0,
    // GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0,
    // 140, 70), 0, 0));
    // scrollPane.setBounds(nombreCompanyiajTextField1.getX(), 30, 155, 40);
    jPanel1.add(scrollPane, null);
    jPanel1.add(telefonojTextField, null);
    panelCenter.add(jScrollPane1, null);
    jScrollPaneTabla.getViewport().add(jTable1, null);
    panelCenter.add(insertarjButton, null);
    panelCenter.add(jScrollPaneTabla, null);
    panelCenter.add(jPanel1, null);

    ajustarCamposTable(jTable1);
  }
  // ************ Constructor start
  public SpaceInvadersPanel() {
    setLayout(null);

    // Used to evaluate if functions should be done, they stop null pointer
    // exceptions
    playing = true;
    won = false;
    lost = false;

    difficultyLabel = new JLabel("Choose difficulty:");
    difficultyLabel.setBounds(350, 350, 200, 50);
    difficultyLabel.setForeground(Color.WHITE);
    difficultyLabel.setVisible(true);
    add(difficultyLabel);

    instructionLabel = new JLabel("Use arrow keys to move and press up to shoot");
    instructionLabel.setBounds(350, 300, 350, 50);
    instructionLabel.setForeground(Color.WHITE);
    instructionLabel.setVisible(true);
    add(instructionLabel);

    difficultyButton = new JButton[4];
    // Array of buttons that show at start and after restart
    for (int i = 0; i < 4; i++) {
      difficultyButton[i] = new JButton("" + (i + 1));
      difficultyButton[i].setBounds((i * bWidth) + 200, 450, bWidth, bHeight);
      difficultyButton[i].setVisible(true);
      difficultyButton[i].addActionListener(this);
      difficultyButton[i].addKeyListener(this);
      difficultyButton[i].setFocusable(false);
      add(difficultyButton[i]);
    }

    // Not really changed
    speed = 20;

    ticks = 0;
    velocityX = 0;
    score = 0;
    rand = new Random();

    // Your shootything
    playerProj = new PlayerProjectile(450, 700);
    playerProj.setVisible(false);
    add(playerProj);

    // This class implements listeners, so this class has this to add to
    // them
    addKeyListener(this);
    this.setFocusable(true);
    // So players can't use tab to switch focus
    this.setFocusTraversalKeysEnabled(false);

    // Arrays of FUN
    enemies = new InvaderEntity[10][10]; // Y < 4; X < 10
    livesImages = new JLabel[3];
    enemyProjX = new int[projectileAmount];
    enemyProj = new InvaderProjectile[projectileAmount];

    // Making projectiles...
    // Not all are used, but to avoid outofbounds, the projectileAmount MUST
    // be final
    for (int i = 0; i < projectileAmount; i++) {
      enemyProj[i] = new InvaderProjectile(200, 100);
      enemyProj[i].setVisible(false);
      add(enemyProj[i]);
    }

    // Labels for lives
    for (int i = 0; i < 3; i++) {
      livesImages[i] = new JLabel();
      Image img = null;
      try {
        img = ImageIO.read(new File("player.png"));
      } catch (IOException e) {
        e.printStackTrace();
      }

      ImageIcon icon = new ImageIcon(img);
      livesImages[i].setIcon(icon);
      livesImages[i].setBounds((i * 40) + 70, 10, 40, 40);
      livesImages[i].setVisible(false);
      add(livesImages[i]);
    }

    tickLabel = new JLabel();
    tickLabel.setForeground(Color.WHITE);
    tickLabel.setBounds(450, 25, 200, 45);
    tickLabel.setVisible(false);
    add(tickLabel);

    outcomeLabel = new JLabel();
    outcomeLabel.setForeground(Color.WHITE);
    outcomeLabel.setBounds(450, 450, 200, 20);
    outcomeLabel.setVisible(false);
    add(outcomeLabel);

    scoreLabel = new JLabel();
    scoreLabel.setForeground(Color.WHITE);
    scoreLabel.setBounds(900 - 200, 25, 200, 45);
    scoreLabel.setVisible(false);
    add(scoreLabel);

    shield =
        new JLabel(
            "------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
    shield.setForeground(Color.BLUE);
    shield.setBounds(0, 650, 900, 10);
    shield.setVisible(false);
    add(shield);

    ceiling = new JLabel(shield.getText());
    ceiling.setForeground(Color.WHITE);
    ceiling.setBounds(0, 50, 900, 10);
    ceiling.setVisible(false);
    add(ceiling);

    floor = new JLabel(shield.getText());
    floor.setForeground(ceiling.getForeground());
    floor.setSize(ceiling.getWidth(), ceiling.getHeight());
    floor.setLocation(0, 755);
    floor.setVisible(false);
    add(floor);

    playerLabel = new JLabel("Ships left:");
    playerLabel.setForeground(Color.WHITE);
    playerLabel.setBounds(0, 10, 93, 45);
    playerLabel.setVisible(false);
    add(playerLabel);

    exitButton = new JButton("Exit");
    exitButton.setBounds((bWidth * 4) + 250, 450, bWidth, bHeight);
    exitButton.addActionListener(this);
    exitButton.addKeyListener(this);
    exitButton.setFocusable(false);
    exitButton.setVisible(true);
    add(exitButton);

    resetButton = new JButton("Restart");
    resetButton.setBounds(bWidth, 800, bWidth, bHeight);
    resetButton.addActionListener(this);
    resetButton.addKeyListener(this);
    resetButton.setFocusable(false);
    resetButton.setVisible(false);
    add(resetButton);

    // Make gunners and Tankers
    for (int y = 0; y < 4; y++) {
      for (int x = 0; x < 10; x++) {
        if (y < 2) {
          enemies[y][x] = new Gunner(x, y);
        } else {
          enemies[y][x] = new Tanker(x, y);
        }
        enemies[y][x].setVisible(false);
        add(enemies[y][x]);
      }
    }

    // Instantiate PlayerEntity
    player = new PlayerEntity(PLAYER_START_X, PLAYER_START_Y);
    player.addKeyListener(this);
    player.setFocusable(false);
    player.setVisible(false);
    add(player);

    askDifficulty();
  }
Beispiel #18
0
  @SuppressWarnings("deprecation")
  public void init() {
    int w = frame.getWidth() / 851;
    int h = frame.getHeight() / 576;
    AllImage.welcome.setImage(
        AllImage.welcome
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_version.setImage(
        AllImage.welcome_version
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_login.setImage(
        AllImage.welcome_login
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_input2.setImage(
        AllImage.welcome_input2
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_input1.setImage(
        AllImage.welcome_input1
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_aboutus.setImage(
        AllImage.welcome_aboutus
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));
    AllImage.welcome_none.setImage(
        AllImage.welcome_none
            .getImage()
            .getScaledInstance(panel.getWidth(), panel.getHeight(), Image.SCALE_DEFAULT));

    welcome = new JLabel(AllImage.welcome);
    welcome.setSize(panel.getWidth(), panel.getHeight());
    welcome.setLocation(0, 0);

    welcome_none = new JLabel(AllImage.welcome_none);
    welcome_none.setSize(panel.getWidth(), panel.getHeight());
    welcome_none.setLocation(0, 0);
    welcome_none.setVisible(false);

    aboutusPane.setSize(508 * w, 346 * h);
    aboutusPane.setLocation(176 * w, 122 * h);
    aboutusPane.setVisible(false);
    searchField.setOpaque(false);
    searchField.setBorder(null);
    searchField.setFont(new Font("ºÚÌå", Font.PLAIN, 18));
    searchField.setForeground(Color.BLACK);
    searchField.setSize(w * 290, h * 54);
    searchField.setLocation(w * 240, h * 221);
    searchField.addMouseListener(
        new MouseAdapter() {
          public void mouseEntered(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_input1);
            panel.repaint();
          }

          public void mouseClicked(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_input2);
            panel.repaint();
          }

          public void mouseExited(MouseEvent e) {
            welcome.setIcon(AllImage.welcome);
            panel.repaint();
          }
        });

    panel.setLayout(null);
    welComeLabel.setSize(frame.getWidth() / 4, frame.getHeight() / 10);
    welComeLabel.setLocation(
        frame.getWidth() / 8 * 3, frame.getHeight() / 5 * 2 - welComeLabel.getHeight());
    welComeLabel.setFont(new Font("ºÚÌå", 0, 30));

    search.setOpaque(false);
    search.setBorder(null);
    search.setSize(58 * w, 62 * h);
    search.setLocation(565 * w, 236 * h);

    aboutUs.setOpaque(false);
    aboutUs.setBorder(null);
    aboutUs.setSize(54 * w, 15 * h);
    aboutUs.setLocation(432 * w, 470 * h);

    version.setOpaque(false);
    version.setBorder(null);
    version.setSize(50 * w, 11 * h);
    version.setLocation(350 * w, 470 * h);

    aboutusClose.setOpaque(false);
    aboutusClose.setBorder(null);
    aboutusClose.setSize(18 * w, 18 * h);
    aboutusClose.setLocation(648 * w, 132 * h);

    login.setOpaque(false);
    login.setBorder(null);
    login.setSize(75 * w, 13 * h);
    login.setLocation(768 * w, 54 * h);

    panel.add(aboutusClose);
    panel.add(aboutusPane);
    panel.add(login);
    panel.add(search);
    panel.add(welComeLabel);
    panel.add(searchField);
    panel.add(aboutUs);
    panel.add(version);
    panel.add(welcome);
    panel.add(welcome_none);
    search.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {}

          public void mouseEntered(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_input2);
            panel.repaint();
          }

          public void mouseExited(MouseEvent e) {
            welcome.setIcon(AllImage.welcome);
            panel.repaint();
          }
        });

    aboutusClose.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            aboutusPane.setVisible(false);
            welcome_none.setVisible(false);
            welcome.setVisible(true);
            panel.add(searchField);
            panel.add(search);
            panel.repaint();
          }
        });

    aboutUs.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_aboutus);
            panel.repaint();
          }

          public void mouseExited(MouseEvent e) {
            welcome.setIcon(AllImage.welcome);
            panel.repaint();
          }

          public void mouseClicked(MouseEvent e) {
            panel.remove(searchField);
            panel.remove(search);
            welcome.setVisible(false);
            welcome_none.setVisible(true);
            aboutusPane.setVisible(true);
            panel.repaint();
          }
        });
    version.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_version);
            panel.repaint();
          }

          public void mouseExited(MouseEvent e) {
            welcome.setIcon(AllImage.welcome);
            panel.repaint();
          }

          public void mouseClicked(MouseEvent e) {
            panel.remove(searchField);
            panel.remove(search);
            welcome.setVisible(false);
            welcome_none.setVisible(true);
            aboutusPane.setVisible(true);
            panel.repaint();
          }
        });
    login.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            removeA();
            panel.repaint();
            MainController.jumpToRightui(Rightui.Login);
          }

          public void mouseEntered(MouseEvent e) {
            welcome.setIcon(AllImage.welcome_login);
            panel.repaint();
          }

          public void mouseExited(MouseEvent e) {
            welcome.setIcon(AllImage.welcome);
            panel.repaint();
          }
        });
    panel.repaint();
  }
  public CardSelectionFrame(Player p, int maxNumberOfCards, boolean forcedToExchange) {
    this.player = p;
    this.maxNumberOfCards = maxNumberOfCards;
    if (forcedToExchange) {
      this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    } else {
      this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
    this.setTitle(
        String.format("%s's cards%s", p.getName(), forcedToExchange ? " (Must exchange)" : ""));
    this.setSize(new Dimension(1100 + 2 * 2 * 5, 600));
    this.getContentPane().setLayout(new BorderLayout());
    this.setResizable(false);
    this.setLocationRelativeTo(null);

    /* Card display panel */
    this.cardDisplayPanel = new JPanel();
    this.cardDisplayPanel.setLayout(new BoxLayout(cardDisplayPanel, BoxLayout.X_AXIS));

    for (Card c : p.getCards()) {
      JLabel cardLabel = new JLabel();
      cardLabel.setSize(220, 363);
      cardLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
      cardLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
      cardLabel.addMouseListener(this);
      String imagePath;
      if (c instanceof TerritoryCard) {
        TerritoryCard tc = (TerritoryCard) c;
        imagePath =
            String.format(
                "resources/cards/war_carta_%s.png",
                tc.getTerritory().getName().toLowerCase().replaceAll("\\s+", ""));
        imagePath = Normalizer.normalize(imagePath, Normalizer.Form.NFD);
        imagePath = imagePath.replaceAll("[^\\x00-\\x7F]", "");
      } else {
        imagePath = "resources/cards/war_carta_coringa.png";
      }
      ImageIcon cardImage = new ImageIcon(imagePath);
      Image resizedImage =
          cardImage
              .getImage()
              .getScaledInstance(cardLabel.getWidth(), cardLabel.getHeight(), Image.SCALE_SMOOTH);
      cardLabel.setIcon(new ImageIcon(resizedImage));

      this.cards.put(cardLabel, c);
      this.cardDisplayPanel.add(cardLabel);
    }
    String exchangeCardsButtonText =
        String.format(
            "Exchange cards for %d armies", WarGame.getInstance().getCardExchangeArmyCount());
    if (WarGame.getInstance().isAttacking()) {
      exchangeCardsButtonText = String.format("Take these cards from %s", p.getName());
    }
    this.exchangeCardsButton = new JButton(exchangeCardsButtonText);
    ActionListener exchangeCardsListener =
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent ae) {
            WarGame.getInstance().exchangeCards(selectedCards);
            dispose();
          }
        };
    this.exchangeCardsButton.addActionListener(exchangeCardsListener);
    this.exchangeCardsButton.setEnabled(false);

    this.getContentPane().add(this.cardDisplayPanel, BorderLayout.CENTER);
    this.getContentPane().add(this.exchangeCardsButton, BorderLayout.PAGE_END);
  }
Beispiel #20
0
  /** performs the creation of the dialog and all its components. */
  protected void initGUI() {
    JPanel panel;
    SpinnerNumberModel model;
    JPanel panel2;

    getContentPane().setLayout(new BorderLayout());

    panel = new JPanel(new GridLayout(6, 1));
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    getContentPane().add(panel, BorderLayout.CENTER);

    // mean precision
    m_MeanPrecSpinner = new JSpinner();
    m_MeanPrecSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            getData();
          }
        });
    model = (SpinnerNumberModel) m_MeanPrecSpinner.getModel();
    model.setMaximum(new Integer(20));
    model.setMinimum(new Integer(0));
    m_MeanPrecLabel = new JLabel("Mean Precision");
    m_MeanPrecLabel.setDisplayedMnemonic('M');
    m_MeanPrecLabel.setLabelFor(m_MeanPrecSpinner);
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_MeanPrecLabel);
    panel2.add(m_MeanPrecSpinner);
    panel.add(panel2);

    // stddev precision
    m_StdDevPrecSpinner = new JSpinner();
    m_StdDevPrecSpinner.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            getData();
          }
        });
    model = (SpinnerNumberModel) m_StdDevPrecSpinner.getModel();
    model.setMaximum(new Integer(20));
    model.setMinimum(new Integer(0));
    m_StdDevPrecLabel = new JLabel("StdDev. Precision");
    m_StdDevPrecLabel.setDisplayedMnemonic('S');
    m_StdDevPrecLabel.setLabelFor(m_StdDevPrecSpinner);
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_StdDevPrecLabel);
    panel2.add(m_StdDevPrecSpinner);
    panel.add(panel2);

    // Format
    m_OutputFormatComboBox = new JComboBox(m_OutputFormatNames);
    m_OutputFormatComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            getData();
          }
        });
    m_OutputFormatLabel = new JLabel("Output Format");
    m_OutputFormatLabel.setDisplayedMnemonic('F');
    m_OutputFormatLabel.setLabelFor(m_OutputFormatComboBox);
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_OutputFormatLabel);
    panel2.add(m_OutputFormatComboBox);
    panel.add(panel2);

    // Average
    m_ShowAverageCheckBox = new JCheckBox("");
    m_ShowAverageCheckBox.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            getData();
          }
        });
    m_ShowAverageLabel = new JLabel("Show Average");
    m_ShowAverageLabel.setDisplayedMnemonic('A');
    m_ShowAverageLabel.setLabelFor(m_ShowAverageCheckBox);
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_ShowAverageLabel);
    panel2.add(m_ShowAverageCheckBox);
    panel.add(panel2);

    // Remove filter classname
    m_RemoveFilterNameCheckBox = new JCheckBox("");
    m_RemoveFilterNameCheckBox.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            getData();
          }
        });
    m_RemoveFilterNameLabel = new JLabel("Remove filter classnames");
    m_RemoveFilterNameLabel.setDisplayedMnemonic('R');
    m_RemoveFilterNameLabel.setLabelFor(m_RemoveFilterNameCheckBox);
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_RemoveFilterNameLabel);
    panel2.add(m_RemoveFilterNameCheckBox);
    panel.add(panel2);

    // Advanced setup
    m_ResultMatrix = ExperimenterDefaults.getOutputFormat();
    m_ResultMatrixEditor = new GenericObjectEditor(true);
    m_ResultMatrixEditor.setClassType(ResultMatrix.class);
    m_ResultMatrixEditor.setValue(m_ResultMatrix);
    m_ResultMatrixEditor.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            // user selected different class?
            if (!m_ResultMatrix.getClass().equals(m_ResultMatrixEditor.getValue().getClass())) {
              // if it's the preferred class, then automaticallly use the Experimenter defaults
              if (m_ResultMatrixEditor
                  .getValue()
                  .getClass()
                  .equals(ExperimenterDefaults.getOutputFormat().getClass())) {
                m_ResultMatrix = ExperimenterDefaults.getOutputFormat();
                m_ResultMatrixEditor.setValue(ExperimenterDefaults.getOutputFormat());
              } else {
                m_ResultMatrix = (ResultMatrix) m_ResultMatrixEditor.getValue();
              }
              setData();
            }
            repaint();
          }
        });
    ((GenericObjectEditor.GOEPanel) m_ResultMatrixEditor.getCustomEditor())
        .addOkListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                m_ResultMatrix = (ResultMatrix) m_ResultMatrixEditor.getValue();
                setData();
              }
            });
    m_ResultMatrixPanel = new PropertyPanel(m_ResultMatrixEditor, false);
    m_ResultMatrixLabel = new JLabel("Advanced setup");
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2.add(m_ResultMatrixLabel);
    panel2.add(m_ResultMatrixPanel);
    panel.add(panel2);

    // Buttons
    panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    getContentPane().add(panel, BorderLayout.SOUTH);
    m_CancelButton = new JButton("Cancel");
    m_CancelButton.setMnemonic('C');
    m_CancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            m_Result = CANCEL_OPTION;
            setVisible(false);
          }
        });
    m_OkButton = new JButton("OK");
    m_OkButton.setMnemonic('O');
    m_OkButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            getData();
            m_Result = APPROVE_OPTION;
            setVisible(false);
          }
        });
    panel.add(m_OkButton);
    panel.add(m_CancelButton);

    // default button
    getRootPane().setDefaultButton(m_OkButton);

    // initial layout (to get widths and heights)
    pack();

    // adjust dimensions
    m_MeanPrecLabel.setPreferredSize(
        new Dimension(m_RemoveFilterNameLabel.getWidth(), m_MeanPrecLabel.getHeight()));
    m_MeanPrecSpinner.setPreferredSize(
        new Dimension(m_MeanPrecSpinner.getWidth() * 3, m_MeanPrecSpinner.getHeight()));
    m_StdDevPrecLabel.setPreferredSize(
        new Dimension(m_RemoveFilterNameLabel.getWidth(), m_StdDevPrecLabel.getHeight()));
    m_StdDevPrecSpinner.setPreferredSize(
        new Dimension(m_StdDevPrecSpinner.getWidth() * 3, m_StdDevPrecSpinner.getHeight()));
    m_OutputFormatLabel.setPreferredSize(
        new Dimension(m_RemoveFilterNameLabel.getWidth(), m_OutputFormatLabel.getHeight()));
    m_ShowAverageLabel.setPreferredSize(
        new Dimension(m_RemoveFilterNameLabel.getWidth(), m_ShowAverageLabel.getHeight()));
    m_ResultMatrixLabel.setPreferredSize(
        new Dimension(m_RemoveFilterNameLabel.getWidth(), m_ResultMatrixLabel.getHeight()));
    m_ResultMatrixPanel.setPreferredSize(
        new Dimension(
            (int) (m_ResultMatrixPanel.getWidth() * 1.5), m_ResultMatrixPanel.getHeight()));

    // final layout
    pack();
  }
  public void dessinerComposantsDynamiques(Pile stackTower, JLabel labelTower, int xTower) {

    if (stackTower.getStack()[0] == 3) {
      discBig.setBounds(
          xTower + labelTower.getWidth() / 2 - discBig.getWidth() / 2,
          350,
          discBig.getWidth(),
          discBig.getHeight());
    } else if (stackTower.getStack()[0] == 2) {
      discMeduim.setBounds(
          xTower + labelTower.getWidth() / 2 - discMeduim.getWidth() / 2,
          350,
          discMeduim.getWidth(),
          discMeduim.getHeight());
    } else if (stackTower.getStack()[0] == 1) {
      discSmall.setBounds(
          xTower + labelTower.getWidth() / 2 - discSmall.getWidth() / 2,
          350,
          discSmall.getWidth(),
          discSmall.getHeight());
    } else {
      // Noting
    }

    if (stackTower.getStack()[1] == 3) {
      discBig.setBounds(
          xTower + labelTower.getWidth() / 2 - discBig.getWidth() / 2,
          275,
          discBig.getWidth(),
          discBig.getHeight());
    } else if (stackTower.getStack()[1] == 2) {
      discMeduim.setBounds(
          xTower + labelTower.getWidth() / 2 - discMeduim.getWidth() / 2,
          275,
          discMeduim.getWidth(),
          discMeduim.getHeight());
    } else if (stackTower.getStack()[1] == 1) {
      discSmall.setBounds(
          xTower + labelTower.getWidth() / 2 - discSmall.getWidth() / 2,
          275,
          discSmall.getWidth(),
          discSmall.getHeight());
    } else {
      // Nothing
    }

    if (stackTower.getStack()[2] == 3) {
      discBig.setBounds(
          xTower + labelTower.getWidth() / 2 - discBig.getWidth() / 2,
          200,
          discBig.getWidth(),
          discBig.getHeight());
    } else if (stackTower.getStack()[2] == 2) {
      discMeduim.setBounds(
          xTower + labelTower.getWidth() / 2 - discMeduim.getWidth() / 2,
          200,
          discMeduim.getWidth(),
          discMeduim.getHeight());
    } else if (stackTower.getStack()[2] == 1) {
      discSmall.setBounds(
          xTower + labelTower.getWidth() / 2 - discSmall.getWidth() / 2,
          200,
          discSmall.getWidth(),
          discSmall.getHeight());
    } else {
      // Nothing
    }
  }
 protected void adjustMetrics(int[] metrics) {
   columnLabel.setPreferredSize(new Dimension(metrics[0], columnLabel.getHeight()));
   valueFieldPanel.setPreferredSize(new Dimension(metrics[1], valueFieldPanel.getHeight()));
 }
Beispiel #23
0
  public void paint(final Graphics graphics, final JComponent comp) {

    final JLabel label = (JLabel) comp;

    if (label.getWidth() > label.getHeight() && !alwaysVertical) {
      super.paint(graphics, comp);
    } else {
      final String text = label.getText();
      final Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();

      if ((icon == null) && (text == null)) {
        return;
      }

      final FontMetrics fontMetrics = graphics.getFontMetrics();
      paintViewInsets = comp.getInsets(paintViewInsets);

      paintViewR.x = paintViewInsets.left;
      paintViewR.y = paintViewInsets.top;

      // Use inverted height & width
      paintViewR.height = comp.getWidth() - (paintViewInsets.left + paintViewInsets.right);
      paintViewR.width = comp.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);

      paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
      paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;

      final String clippedText =
          layoutCL(label, fontMetrics, text, icon, paintViewR, paintIconR, paintTextR);

      final Graphics2D g2D = (Graphics2D) graphics;
      final AffineTransform oldTransform = g2D.getTransform();
      if (clockwise) {
        g2D.rotate(Math.PI / 2);
        g2D.translate(0, -comp.getWidth());
      } else {
        g2D.rotate(-Math.PI / 2);
        g2D.translate(-comp.getHeight(), 0);
      }

      if (icon != null) {
        icon.paintIcon(comp, graphics, paintIconR.x, paintIconR.y);
      }

      if (text != null) {
        final View view = (View) comp.getClientProperty(BasicHTML.propertyKey);

        if (view == null) {
          final int textX = paintTextR.x;
          final int textY = paintTextR.y + fontMetrics.getAscent();

          if (label.isEnabled()) {
            paintEnabledText(label, graphics, clippedText, textX, textY);
          } else {
            paintDisabledText(label, graphics, clippedText, textX, textY);
          }
        } else {
          view.paint(graphics, paintTextR);
        }
      }

      g2D.setTransform(oldTransform);
    }
  }
  /** Create the frame. */
  private void initComponents() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 450, 300);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    setLocationRelativeTo(null);

    registration = new JTextField();
    registration.setBounds(220, 61, 165, 20);
    contentPane.add(registration);
    registration.setColumns(10);

    JLabel lblRegistration = new JLabel("Matricula");
    lblRegistration.setLabelFor(registration);
    lblRegistration.setBounds(220, 36, 71, 14);
    contentPane.add(lblRegistration);

    JLabel lblPassword = new JLabel("Senha");
    lblPassword.setFont(new Font("Tahoma", Font.PLAIN, 12));
    lblPassword.setBounds(220, 92, 46, 14);
    contentPane.add(lblPassword);

    JLabel foto = new JLabel("");
    foto.setBounds(10, 36, 150, 150);

    ImageIcon imagem =
        new ImageIcon(LoginFrame.class.getResource("/br/com/controle_de_micros/img/bandeira.png"));
    Image imag =
        imagem.getImage().getScaledInstance(foto.getWidth(), foto.getHeight(), Image.SCALE_SMOOTH);
    foto.setIcon(new ImageIcon(imag));

    contentPane.add(foto);

    JButton btnLogin = new JButton("Login");
    btnLogin.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {

            String reg = registration.getText();
            @SuppressWarnings("deprecation")
            String pass = password.getText();

            try {

              // verica se o campo matricula e senha esta vazio

              if (reg.isEmpty()) {
                throw new Exception("O campo Matricula é obrigatório.");
              } else if (pass.isEmpty()) {
                throw new Exception("O campo senha é obrigatório");
              }

              // algoritmo de criptografia
              MessageDigest algorithm = MessageDigest.getInstance("SHA-256");
              byte messageDigest[] = algorithm.digest(pass.getBytes("UTF-8"));

              StringBuilder hexString = new StringBuilder();
              for (byte b : messageDigest) hexString.append(String.format("%02X", 0xFF & b));

              String cripPass = hexString.toString(); // hash da senha

              UserControl uc = new UserControl();
              User user = uc.getUser(Long.parseLong(reg));
              user.setPassword(cripPass);

              if (uc.makeLogin(user)) {
                SessionControl session = new SessionControl();
                session.setUser(user); // Cria sessao do usuário.

                dispose();
                JFrame menu = new MenuFrame();
                menu.setVisible(true);
              } else {
                throw new Exception("Os dados informados não são validos.");
              }

            } catch (Exception e) {
              JOptionPane.showMessageDialog(contentPane, e.getMessage());
            }
          }
        });
    btnLogin.setBounds(220, 148, 165, 23);
    contentPane.add(btnLogin);

    password = new JPasswordField();
    lblPassword.setLabelFor(password);
    password.setBounds(220, 117, 165, 20);
    contentPane.add(password);
  }
  public PicsHerosFrame(PicsHerosHeroManager heroManager) {
    super("3 photos 1 Hero");

    this.heroManager = heroManager;
    heroManager.createHeroList();
    // dhmiourgoume prwta thn lista hrwwn

    this.setSize(900, 680);
    // mpainei prin ta setBounds gia na doulepsei to this

    setBounds(100, 100, this.getWidth(), this.getHeight());
    mainPanel = new JPanel();
    mainPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(mainPanel);
    mainPanel.setLayout(null);

    anyHero = this.heroManager.getHero();

    photo1 = new JLabel();
    photo1.setBounds(50, 200, 250, 250);
    mainPanel.add(photo1);

    photo2 = new JLabel();
    photo2.setBounds(310, 200, 250, 250);
    mainPanel.add(photo2);

    photo3 = new JLabel();
    photo3.setBounds(570, 200, 250, 250);
    mainPanel.add(photo3);

    commitBt = new JButton("The pics are about...");
    commitBt.setBounds(200, 500, 150, 30);

    buttonListener = new myButtonListener();
    commitBt.addActionListener(buttonListener);

    mainPanel.add(commitBt);

    nameArea = new JTextArea();
    nameArea.setBounds(350, 500, 300, 30);
    nameArea.setBackground(Color.ORANGE);
    nameArea.setEditable(true);
    mainPanel.add(nameArea);
    // kataskeyh stoixeiwn parathyrou

    ImageIcon background = new ImageIcon("olympus.jpg");
    Image image = background.getImage();
    backlbl = new JLabel();
    backlbl.setBounds(0, 0, this.getWidth(), this.getHeight());
    Image resizedImage = image.getScaledInstance(backlbl.getWidth(), backlbl.getHeight(), 0);
    backlbl.setIcon(new ImageIcon(resizedImage));
    // prosarmogh eikonas fontou
    mainPanel.add(backlbl);

    getNextHero();
    // yparxei gia na exoume enan arxiko hrwa alliws bgazei keno

    this.setResizable(false);
    // den epitrepei allagh megethous sto parathyro
    this.setVisible(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }