コード例 #1
0
  /**
   * <div> Agregamos los componentes ordenados según el tamaño del panel.
   *
   * <p>Definimos que el botón de borrado tendrá 80pxl, el resto se calcula en base al tamaño del
   * panel. </div>
   *
   * @param txtField (Tipo JTextField) Es el display o pantalla.
   * @param bttn (Tipo JButton) Es el botón de borrado.
   * @param iTamPanelX (Tipo int) Tamaño del panel con respecto del eje X, o tamaño horizontal.
   * @param iTamPanelY (Tipo int) Tamaño del panel con respecto del eje Y, o tamaño vertical.
   */
  private void agregarComponentesOrdenados(
      JTextField txtField, JButton bttn, int iTamPanelX, int iTamPanelY) {
    // Atributos Locales
    int iTamBotonClearX = 80;

    // Cuerpo del método
    if (txtField != null && bttn != null) {
      this.agregarComponentes(txtField, bttn);

      txtField.setLocation(0, 0);
      txtField.setSize(iTamPanelX - iTamBotonClearX, iTamPanelY - 1);

      bttn.setLocation(txtField.getWidth(), 0);
      bttn.setSize(iTamBotonClearX, iTamPanelY - 1);
    } // Fin del if (txtField != null && bttn != null)
  }
コード例 #2
0
  private void init_discounts() {

    Object[][] obj = new Object[discounts.size()][2];
    int i = 0;
    for (Discounts.to_discounts to : discounts) {
      obj[i][0] = " " + FitIn.fmt_wc_0(to.discount_rate);
      obj[i][1] = " " + to.discount_name;
      i++;
    }
    JLabel[] labels = {};
    int[] tbl_widths_customers = {50, jTextField1.getWidth() - 50};
    int width = 0;
    String[] col_names = {"Rate", "Discount"};
    TableRenderer tr = new TableRenderer();
    TableRenderer.setPopup(jTextField1, obj, labels, tbl_widths_customers, col_names);
    tr.setCallback(
        new TableRenderer.Callback() {
          @Override
          public void ok(TableRenderer.OutputData data) {
            Discounts.to_discounts to = discounts.get(data.selected_row);
            if (to.id == 0) {
              jTextField3.setText("0.00");
              jTextField2.setEnabled(true);
              jTextField2.grabFocus();
            } else {

              jTextField1.setText(to.discount_name);
              jTextField3.setText(FitIn.fmt_wc_0(to.discount_rate));
              double discount_amount =
                  (to.discount_rate / 100) * FitIn.toDouble(jTextField6.getText());
              jTextField2.setText(FitIn.fmt_wc_0(discount_amount));
              jTextField4.grabFocus();
            }
          }
        });
  }
コード例 #3
0
 /**
  * Sets the height of the table cell in which this is displayed
  *
  * @param h cell height
  */
 public void setHeight(int h) {
   setSize(getWidth(), h);
   m_numer.setSize(m_numer.getWidth(), h);
   m_divider.setSize(m_divider.getWidth(), h);
   m_denom.setSize(m_denom.getWidth(), h);
 }
コード例 #4
0
  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);
  }