Esempio n. 1
0
  /** Initialize */
  @Override
  public void init() {
    //	Content
    MigLayout layout = new MigLayout("ins 0 0", "[fill|fill|fill|fill]", "[nogrid]unrel[||]");
    setLayout(layout);

    Font bigFont = AdempierePLAF.getFont_Field().deriveFont(16f);

    String buttonSize = "w 50!, h 50!,";
    // NEW
    f_bNew = createButtonAction("New", KeyStroke.getKeyStroke(KeyEvent.VK_F2, Event.F2));
    add(f_bNew, buttonSize);

    // EDIT
    f_bEdit = createButtonAction("Edit", null);
    add(f_bEdit, buttonSize);
    f_bEdit.setEnabled(false);

    // HISTORY
    f_history = createButtonAction("History", null);
    add(f_history, buttonSize);

    // CANCEL
    f_process = createButtonAction("Cancel", null);
    add(f_process, buttonSize);
    f_process.setEnabled(false);

    // PAYMENT
    f_cashPayment = createButtonAction("Payment", null);
    f_cashPayment.setActionCommand("Cash");
    add(f_cashPayment, buttonSize);
    f_cashPayment.setEnabled(false);

    // PRINT
    f_print = createButtonAction("Print", null);
    add(f_print, buttonSize);
    f_print.setEnabled(false);

    // Settings
    f_bSettings = createButtonAction("Preference", null);
    add(f_bSettings, buttonSize);

    //
    f_logout = createButtonAction("Logout", null);
    add(f_logout, buttonSize + ", gapx 25, wrap");

    // DOC NO
    add(new CLabel(Msg.getMsg(Env.getCtx(), "DocumentNo")), "");

    f_DocumentNo = new CTextField("");
    f_DocumentNo.setName("DocumentNo");
    f_DocumentNo.setEditable(false);
    add(f_DocumentNo, "growx, pushx");

    CLabel lNet = new CLabel(Msg.translate(Env.getCtx(), "SubTotal"));
    add(lNet, "");
    f_net = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_net.setHorizontalAlignment(JTextField.TRAILING);
    f_net.setEditable(false);
    f_net.setFocusable(false);
    lNet.setLabelFor(f_net);
    add(f_net, "wrap, growx, pushx");
    f_net.setValue(Env.ZERO);
    //

    /*
    	// BPARTNER
    	f_bSearch = createButtonAction ("BPartner", KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.CTRL_MASK));
    	add (f_bSearch,buttonSize + ", spany 2");
    */

    /*
     * f_name.setName("Name");
    f_name.addActionListener(this);
    f_name.addFocusListener(this);
    add (f_name, "wrap");
    */

    // SALES REP
    add(new CLabel(Msg.translate(Env.getCtx(), "SalesRep_ID")), "");
    f_RepName = new CTextField("");
    f_RepName.setName("SalesRep");
    f_RepName.setEditable(false);
    add(f_RepName, "growx, pushx");

    CLabel lTax = new CLabel(Msg.translate(Env.getCtx(), "TaxAmt"));
    add(lTax);
    f_tax = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_tax.setHorizontalAlignment(JTextField.TRAILING);
    f_tax.setEditable(false);
    f_tax.setFocusable(false);
    lTax.setLabelFor(f_tax);
    add(f_tax, "wrap, growx, pushx");
    f_tax.setValue(Env.ZERO);
    //

    /*
    	f_location = new CComboBox();
    	add (f_location, " wrap");
    */

    // BP
    add(new CLabel(Msg.translate(Env.getCtx(), "C_BPartner_ID")), "");
    f_name = new CTextField();
    f_name.setEditable(false);
    f_name.setName("Name");
    add(f_name, "growx, pushx");

    //
    CLabel lTotal = new CLabel(Msg.translate(Env.getCtx(), "GrandTotal"));
    lTotal.setFont(bigFont);
    add(lTotal, "");
    f_total = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_total.setHorizontalAlignment(JTextField.TRAILING);
    f_total.setFont(bigFont);
    f_total.setEditable(false);
    f_total.setFocusable(false);
    lTotal.setLabelFor(f_total);
    add(f_total, "growx, pushx");
    f_total.setValue(Env.ZERO);
    /*
    //
    f_user = new CComboBox();
    add (f_user, "skip 1");
    */
  } //	init
  @Override
  public void installUI(JComponent c) {
    super.installUI(c);

    textFormattedField = (JFormattedTextField) c;

    textFormattedField.setFocusable(true);
    textFormattedField.setOpaque(false);
    textFormattedField.setMargin(new Insets(0, 0, 0, 0));
    textFormattedField.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    textFormattedField.setFont(AdobeLookAndFeel.fontBold);
    textFormattedField.setForeground(AdobeLookAndFeel.colorText);
    textFormattedField.setSelectionColor(new Color(100, 100, 100));
    textFormattedField.setCaretColor(AdobeLookAndFeel.colorText);

    mouseAdapter =
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent e) {
            textFormattedField.repaint();
          }

          @Override
          public void mousePressed(MouseEvent e) {
            textFormattedField.repaint();
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            textFormattedField.repaint();
          }
        };
    textFormattedField.addMouseListener(mouseAdapter);

    keyAdapter =
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            textFormattedField.repaint();
          }
        };
    textFormattedField.addKeyListener(keyAdapter);

    focusListener =
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            textFormattedField.repaint();
          }

          @Override
          public void focusLost(FocusEvent e) {
            textFormattedField.repaint();
          }
        };
    textFormattedField.addFocusListener(focusListener);

    propertyChangeListener =
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            textFormattedField.repaint();
          }
        };
    textFormattedField.addPropertyChangeListener(
        AccessibleContext.ACCESSIBLE_STATE_PROPERTY, propertyChangeListener);
  }