Exemplo n.º 1
0
 public void setEditable(boolean isEditable) {
   isEditable_ = isEditable;
   if (inputType_.equals("ALPHA") || inputType_.equals("KANJI") || inputType_.equals("NUMERIC")) {
     ((JTextField) component).setEditable(isEditable_);
     ((JTextField) component).setFocusable(isEditable_);
   }
   if (inputType_.equals("DATE")) {
     ((XFDateField) component).setEditable(isEditable_);
     ((XFDateField) component).setFocusable(isEditable_);
     int fieldWidth = XFUtility.getWidthOfDateValue(dialog_.getSession().getDateFormat(), 14);
     if (isEditable_) {
       this.setBounds(
           this.getBounds().x, this.getBounds().y, 150 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT);
     } else {
       this.setBounds(
           this.getBounds().x, this.getBounds().y, 124 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT);
     }
   }
   if (inputType_.equals("LISTBOX")) {
     ((JComboBox) component).setEditable(isEditable_);
     ((JComboBox) component).setFocusable(isEditable_);
   }
   if (inputType_.equals("CHECKBOX")) {
     ((JCheckBox) component).setEnabled(isEditable_);
     ((JCheckBox) component).setFocusable(isEditable_);
   }
 }
Exemplo n.º 2
0
 public XFInputDialogField(
     String fieldCaption, String inputType, String parmID, XFInputDialog dialog) {
   super();
   parmID_ = parmID;
   if (!inputType.equals("ALPHA")
       && !inputType.equals("KANJI")
       && !inputType.equals("NUMERIC")
       && !inputType.equals("DATE")
       && !inputType.equals("LISTBOX")
       && !inputType.equals("CHECKBOX")) {
     inputType_ = "ALPHA";
   }
   inputType_ = inputType;
   dialog_ = dialog;
   jLabelField.setText(fieldCaption + " ");
   jLabelField.setFocusable(false);
   jLabelField.setHorizontalAlignment(SwingConstants.RIGHT);
   jLabelField.setVerticalAlignment(SwingConstants.TOP);
   jLabelField.setFont(new java.awt.Font("Dialog", 0, 14));
   metrics = jLabelField.getFontMetrics(new java.awt.Font("Dialog", 0, 14));
   jLabelField.setPreferredSize(new Dimension(120, XFUtility.FIELD_UNIT_HEIGHT));
   if (metrics.stringWidth(fieldCaption) > 120) {
     jLabelField.setFont(new java.awt.Font("Dialog", 0, 12));
     metrics = jLabelField.getFontMetrics(new java.awt.Font("Dialog", 0, 12));
     if (metrics.stringWidth(fieldCaption) > 120) {
       jLabelField.setFont(new java.awt.Font("Dialog", 0, 10));
     }
   }
   if (inputType_.equals("ALPHA") || inputType_.equals("KANJI") || inputType_.equals("NUMERIC")) {
     JTextField field = new JTextField();
     field.addFocusListener(new ComponentFocusListener());
     if (inputType_.equals("NUMERIC")) {
       field.setHorizontalAlignment(SwingConstants.RIGHT);
       field.setDocument(new LimitedDocument(this));
     }
     component = field;
   }
   if (inputType_.equals("DATE")) {
     XFDateField field = new XFDateField(dialog_.getSession());
     component = field;
   }
   if (inputType_.equals("LISTBOX")) {
     JComboBox field = new JComboBox();
     component = field;
   }
   if (inputType_.equals("CHECKBOX")) {
     JCheckBox field = new JCheckBox();
     component = field;
   }
   component.setFont(new java.awt.Font("Monospaced", 0, 14));
   metrics = component.getFontMetrics(new java.awt.Font("Monospaced", 0, 14));
   this.setOpaque(false);
   if (inputType_.equals("DATE")) {
     int fieldWidth = XFUtility.getWidthOfDateValue(dialog_.getSession().getDateFormat(), 14);
     this.setBounds(
         this.getBounds().x, this.getBounds().y, 150 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT);
   } else {
     this.setBounds(this.getBounds().x, this.getBounds().y, 150, XFUtility.FIELD_UNIT_HEIGHT);
   }
   this.setLayout(new BorderLayout());
   this.add(jLabelField, BorderLayout.WEST);
   this.add(component, BorderLayout.CENTER);
 }