コード例 #1
0
  public CustomerEdit(
      String title,
      boolean visible,
      boolean undecorate,
      boolean resizeable,
      Dimension dimension,
      final String id)
      throws SQLException, ClassNotFoundException {
    super(title, visible, undecorate, resizeable, dimension);
    setUndecorated(true);
    RemovablePanel contenPane = new RemovablePanel(this);
    Color BackGround = Color.getHSBColor(20, 12, 21);
    contenPane.setBackground(BackGround);
    this.setContentPane(contenPane);
    setLayout(null);
    CustomLabel titleLabel =
        new CustomLabel(
            "Edit customer",
            Color.BLACK,
            Configure.DEFAULT_RIGHT_PANEL_COLOR,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 24),
            new Point(20, 17),
            new Dimension(360, 40),
            true,
            SwingConstants.LEFT,
            SwingConstants.CENTER,
            contenPane);

    Dimension dim = dimension;
    final HintTextField name =
        new HintTextField(
            " Name",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(20, 70),
            new Dimension(dim.width - 40, 30),
            contenPane,
            false);
    final HintTextField type =
        new HintTextField(
            " Type",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(20, 110),
            new Dimension(dim.width - 40, 30),
            contenPane,
            false);
    final HintTextField relationShip =
        new HintTextField(
            " Relationship",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(20, 150),
            new Dimension(dim.width - 40, 30),
            contenPane,
            false);
    final HintTextField phone =
        new HintTextField(
            " Phone",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(20, 190),
            new Dimension((dim.width - 40) / 2 - 5, 30),
            contenPane,
            false);
    final HintTextField fax =
        new HintTextField(
            " Fax",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(205, 190),
            new Dimension((dim.width - 40) / 2 - 5, 30),
            contenPane,
            false);
    final HintTextField email =
        new HintTextField(
            " Email",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(20, 230),
            new Dimension((dim.width - 40) / 2 - 5, 30),
            contenPane,
            false);
    final HintTextField address =
        new HintTextField(
            " Address",
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(205, 230),
            new Dimension((dim.width - 40) / 2 - 5, 30),
            contenPane,
            false);

    final CustomButton ok =
        new CustomButton(
            "Save",
            Color.WHITE,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 14),
            false,
            false,
            Color.GRAY,
            true,
            new Point(20, 280),
            new Dimension((dim.width - 50) / 2, 30),
            contenPane);

    Customers custemp = Customers.viewCustomer(id);

    name.setText(custemp.getCustomerName());
    type.setText(custemp.getCustomerType());
    relationShip.setText(custemp.getCustomerRelationship());
    phone.setText(custemp.getCustomerPhone());
    fax.setText(custemp.getCustomerFax());
    email.setText(custemp.getCustomerEmail());
    address.setText(custemp.getCustomerAddress());
    System.out.println(
        name.getText().toString() + " " + phone.getText().toString() + "kfsjdhfdskjfh");
    ok.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {

            String namex = name.getText().toString();
            String typex = type.getText().toString();
            String relx = relationShip.getText().toString();
            String phonex = phone.getText().toString();
            String faxx = fax.getText().toString();
            String emailx = email.getText().toString();
            String addressx = address.getText().toString();
            try {
              Customers.editCustomer(namex, typex, phonex, faxx, emailx, addressx, relx, id);
            } catch (SQLException ex) {
              Logger.getLogger(CustomerEdit.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ClassNotFoundException ex) {
              Logger.getLogger(CustomerEdit.class.getName()).log(Level.SEVERE, null, ex);
            }

            CustomerEdit.this.dispose();
          }
        });

    final CustomButton cancel =
        new CustomButton(
            "Cancel",
            Color.WHITE,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 14),
            false,
            false,
            Color.LIGHT_GRAY,
            true,
            new Point(20 + 10 + (dim.width - 50) / 2, 280),
            new Dimension((dim.width - 50) / 2, 30),
            contenPane);

    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            CustomerEdit.this.dispose();
          }
        });
  }
コード例 #2
0
  public BillingDialog(
      String title,
      boolean visible,
      boolean undecorate,
      boolean resizeable,
      Dimension dim,
      final String id) {
    super(title, visible, undecorate, resizeable, dim);
    RemovablePanel contenPane = new RemovablePanel(this);
    Color BackGround = Color.GRAY;
    contenPane.setBackground(Color.getHSBColor(20, 12, 21));
    this.setContentPane(contenPane);
    setLocationRelativeTo(null);
    setLayout(null);
    CustomLabel titleLabel =
        new CustomLabel(
            title,
            Color.BLACK,
            Configure.DEFAULT_RIGHT_PANEL_COLOR,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 15),
            new Point(20, 10),
            new Dimension(360, 40),
            true,
            SwingConstants.LEFT,
            SwingConstants.CENTER,
            contenPane);
    final CustomButton ok =
        new CustomButton(
            "Yes",
            Color.WHITE,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 14),
            false,
            false,
            Color.GRAY,
            true,
            new Point(20, 50),
            new Dimension((dim.width - 50) / 2, 30),
            contenPane);
    ok.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              //
              Bills.deleteBill(id);
            } catch (SQLException ex) {
              Logger.getLogger(BillingDialog.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ClassNotFoundException ex) {
              Logger.getLogger(BillingDialog.class.getName()).log(Level.SEVERE, null, ex);
            }
            BillingDialog.this.dispose();
          }
        });
    final CustomButton cancel =
        new CustomButton(
            "No",
            Color.WHITE,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 14),
            false,
            false,
            Color.LIGHT_GRAY,
            true,
            new Point(20 + 10 + (dim.width - 50) / 2, 50),
            new Dimension((dim.width - 50) / 2, 30),
            contenPane);
    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            BillingDialog.this.dispose();
          }
        });
  }
コード例 #3
0
  public CustomerRow(
      final String id,
      String name,
      String type,
      String address,
      String phone,
      int idSize,
      int nameSize,
      int typeSize,
      int addressSize,
      int phoneSize,
      int optionSize,
      Point pos,
      JPanel parentPanel) {
    super();
    setLayout(null);
    Color BackGround = null;
    if (white) BackGround = Color.WHITE;
    else BackGround = Color.getHSBColor(20, 12, 21);
    setBackground(BackGround);
    white = !white;
    setBounds(
        pos.x, pos.y, idSize + nameSize + typeSize + addressSize + phoneSize + optionSize, 40);
    CustomLabel idLabel =
        new CustomLabel(
            id,
            Color.GRAY,
            Color.WHITE,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(pos.x, pos.y),
            new Dimension(idSize, 40),
            true,
            SwingConstants.CENTER,
            SwingConstants.CENTER,
            parentPanel);
    CustomLabel nameLabel =
        new CustomLabel(
            name,
            Color.GRAY,
            Color.WHITE,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(pos.x + idSize, pos.y),
            new Dimension(nameSize, 40),
            true,
            SwingConstants.CENTER,
            SwingConstants.CENTER,
            parentPanel);
    CustomLabel typeLabel =
        new CustomLabel(
            type,
            Color.GRAY,
            Color.WHITE,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(pos.x + idSize + nameSize, pos.y),
            new Dimension(typeSize, 40),
            true,
            SwingConstants.CENTER,
            SwingConstants.CENTER,
            parentPanel);
    CustomLabel addressLabel =
        new CustomLabel(
            address,
            Color.GRAY,
            Color.WHITE,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(pos.x + idSize + typeSize + nameSize, pos.y),
            new Dimension(addressSize, 40),
            true,
            SwingConstants.CENTER,
            SwingConstants.CENTER,
            parentPanel);
    CustomLabel ramainLabel =
        new CustomLabel(
            phone,
            Color.GRAY,
            Color.WHITE,
            CustomFont.getFont(Configure.DEFAULT_FONT, Font.PLAIN, 13),
            new Point(pos.x + idSize + typeSize + addressSize + nameSize, pos.y),
            new Dimension(phoneSize, 40),
            true,
            SwingConstants.CENTER,
            SwingConstants.CENTER,
            parentPanel);
    CustomButton devider =
        new CustomButton(
            "",
            Color.WHITE,
            null,
            false,
            false,
            Color.LIGHT_GRAY,
            true,
            new Point(pos.x, pos.y + 39),
            new Dimension(idSize + nameSize + typeSize + addressSize + phoneSize + optionSize, 1),
            parentPanel);

    CustomButton details =
        new CustomButton(
            new ImageIcon("src/GUI/Resources/details.bin"),
            "",
            Color.WHITE,
            null,
            false,
            false,
            BackGround,
            true,
            new Point(
                idSize + nameSize + typeSize + addressSize + phoneSize + (optionSize - 80) / 2, 5),
            new Dimension(20, 30),
            CustomerRow.this,
            SwingConstants.CENTER,
            SwingConstants.CENTER);
    details.setRolloverIcon(new ImageIcon("src/GUI/Resources/detailsRollover.bin"));
    CustomButton edit =
        new CustomButton(
            new ImageIcon("src/GUI/Resources/edit.bin"),
            "",
            Color.WHITE,
            null,
            false,
            false,
            BackGround,
            true,
            new Point(
                idSize + nameSize + typeSize + addressSize + phoneSize + (optionSize - 80) / 2 + 25,
                5),
            new Dimension(20, 30),
            CustomerRow.this,
            SwingConstants.CENTER,
            SwingConstants.CENTER);
    edit.setRolloverIcon(new ImageIcon("src/GUI/Resources/editRollover.bin"));
    CustomButton delete =
        new CustomButton(
            new ImageIcon("src/GUI/Resources/delete.bin"),
            "",
            Color.WHITE,
            null,
            false,
            false,
            BackGround,
            true,
            new Point(
                idSize + nameSize + typeSize + addressSize + phoneSize + (optionSize - 80) / 2 + 48,
                5),
            new Dimension(20, 30),
            CustomerRow.this,
            SwingConstants.CENTER,
            SwingConstants.CENTER);
    delete.setRolloverIcon(new ImageIcon("src/GUI/Resources/deleteRollover.bin"));

    details.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            CustomerDetails addCustomer = null;
            try {
              addCustomer =
                  new CustomerDetails("", false, false, false, new Dimension(400, 340), id);
            } catch (SQLException ex) {
              Logger.getLogger(CustomerRow.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ClassNotFoundException ex) {
              Logger.getLogger(CustomerRow.class.getName()).log(Level.SEVERE, null, ex);
            }
            addCustomer.setVisible(true);
          }
        });

    edit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            CustomerEdit addCustomers = null;
            try {
              addCustomers = new CustomerEdit("", false, false, false, new Dimension(400, 340), id);
            } catch (SQLException ex) {
              Logger.getLogger(CustomerRow.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ClassNotFoundException ex) {
              Logger.getLogger(CustomerRow.class.getName()).log(Level.SEVERE, null, ex);
            }
            addCustomers.setVisible(true);
          }
        });

    delete.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            CustomerDialog dialog =
                new CustomerDialog(
                    "Are you sure ?", true, true, false, new Dimension(200, 100), id);
          }
        });
  }