Esempio n. 1
0
 private static void setComponentName(JComponent component, String name) {
   if (component != null) {
     Container parent = component.getParent();
     if (parent != null) {
       component.setName(parent.getName() + "." + name);
     } else {
       component.setName(name);
     }
   }
 }
Esempio n. 2
0
 /**
  * Print Oarent of Component
  *
  * @param c component
  */
 static void printParents(JComponent c) {
   if (c.getName() == null) c.setName("C" + String.valueOf(s_no++));
   System.out.print(c.getName());
   System.out.print(" - " + c.getClass().getName());
   System.out.println(
       " ** "
           + c.isOpaque()
           + " bg="
           + (c.getClientProperty(CompiereLookAndFeel.BACKGROUND) != null));
   //
   Container container = c.getParent();
   while (container != null) {
     System.out.print(
         " - "
             + container.getName()
             + " "
             + container.getClass().getName()
             + " ** "
             + container.isOpaque());
     if (container instanceof JComponent)
       System.out.print(
           " bg="
               + (((JComponent) container).getClientProperty(CompiereLookAndFeel.BACKGROUND)
                   != null));
     System.out.println();
     container = container.getParent();
   }
 } //  printParents
Esempio n. 3
0
 /**
  * Constructs a default <code>JTable</code> that is initialized with a default data model, a
  * default column model, and a default selection model. The identifier JComponent is used to save
  * the state of the table columns in the actual view. Not using this one constructor may lead to
  * inconsistent behavior of the view if this JTable's parent component has no unique name. It is
  * recommended to use this constructor in Yabs.
  *
  * @see #createDefaultDataModel
  * @see #createDefaultColumnModel
  * @see #createDefaultSelectionModel
  */
 public MPTable(JComponent identifier) {
   super();
   setName("43");
   if (identifier.getName() == null) {
     identifier.setName(identifier.getClass().getSimpleName());
   }
   setPersistanceHandler(new TableViewPersistenceHandler(this, identifier));
 }
Esempio n. 4
0
  /** Sets the name of the node. */
  public final void setName(String name) {
    if (name == null) {
      throw new NullPointerException("Name must not be null.");
    }

    super.setName(name);

    if (displayComp != null) {
      displayComp.setName(name);
    }

    repaint();
  }
Esempio n. 5
0
 public void parseAttributes(Element elm, JComponent comp) {
   String enabled = elm.getAttribute("enabled");
   if (enabled != null) {
     comp.setEnabled(!enabled.equals("false"));
   }
   String id = elm.getAttribute("id");
   if (id.length() > 0) {
     components.put(id, comp);
     comp.setName(id);
   }
   String tooltip = elm.getAttribute("tooltip");
   if (tooltip.length() > 0) {
     comp.setToolTipText(tooltip);
   }
 }
Esempio n. 6
0
  /**
   * Constructor
   *
   * @param columnName ColumnName
   * @param mandatory mandatory
   * @param isReadOnly read only
   * @param isUpdateable updateable
   * @param mLocator locator (lookup) model
   * @param WindowNo window no
   */
  public VLocator(
      String columnName,
      boolean mandatory,
      boolean isReadOnly,
      boolean isUpdateable,
      MLocatorLookup mLocator,
      int WindowNo) {
    super();
    super.setName(columnName);
    m_columnName = columnName;
    m_mLocator = mLocator;
    m_WindowNo = WindowNo;
    //
    LookAndFeel.installBorder(this, "TextField.border");
    this.setLayout(new BorderLayout());

    //
    // Text
    VEditorUtils.setupInnerTextComponentUI(m_text);
    m_text.setEditable(true);
    m_text.setFocusable(true);
    m_text.addActionListener(this);
    this.add(m_text, BorderLayout.CENTER);

    //
    // Button
    {
      m_button = VEditorUtils.createActionButton("Locator", m_text);
      m_button.addActionListener(this);
      VEditorDialogButtonAlign.addVEditorButtonUsingBorderLayout(getClass(), this, m_button);
    }

    //
    // Size
    VEditorUtils.setupVEditorDimensionFromInnerTextDimension(this, m_text);

    //	ReadWrite
    if (isReadOnly || !isUpdateable) setReadWrite(false);
    else setReadWrite(true);
    setMandatory(mandatory);

    setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ]

    //
    // Create and bind the context menu
    new EditorContextPopupMenu(this);
  } //	VLocator
Esempio n. 7
0
  /**
   * Create right aligned Number field. no popup, if WindowNo == 0 (for IDs)
   *
   * @param columnName column name
   * @param mandatory mandatory
   * @param isReadOnly read only
   * @param isUpdateable updateable
   * @param displayType display type
   * @param title title
   */
  public VNumber(
      String columnName,
      boolean mandatory,
      boolean isReadOnly,
      boolean isUpdateable,
      int displayType,
      String title) {
    super();
    super.setName(columnName);
    m_columnName = columnName;
    m_title = title;
    setDisplayType(displayType);
    //
    LookAndFeel.installBorder(this, "TextField.border");
    this.setLayout(new BorderLayout());

    //	***	Text	***
    m_text.setBorder(null);
    m_text.setHorizontalAlignment(JTextField.TRAILING);
    m_text.addKeyListener(this);
    m_text.addFocusListener(this);
    //	Background
    setMandatory(mandatory);
    this.add(m_text, BorderLayout.CENTER);

    //	***	Button	***
    m_button.setIcon(Env.getImageIcon("Calculator10.gif"));
    m_button.setMargin(new Insets(0, 0, 0, 0));
    m_button.setFocusable(false);
    m_button.addActionListener(this);
    this.add(m_button, BorderLayout.EAST);

    //  Size
    setColumns(SIZE, 0);
    //	ReadWrite
    if (isReadOnly || !isUpdateable) setReadWrite(false);
    else setReadWrite(true);

    m_text.addMouseListener(new VNumber_mouseAdapter(this));
  } //	VNumber
  public static void main(String args[]) {
    JComponent ch = new JComponent() {};
    ch.getAccessibleContext();
    ch.isFocusTraversable();
    ch.setEnabled(false);
    ch.setEnabled(true);
    ch.requestFocus();
    ch.requestFocusInWindow();
    ch.getPreferredSize();
    ch.getMaximumSize();
    ch.getMinimumSize();
    ch.contains(1, 2);
    Component c1 = ch.add(new Component() {});
    Component c2 = ch.add(new Component() {});
    Component c3 = ch.add(new Component() {});
    Insets ins = ch.getInsets();
    ch.getAlignmentY();
    ch.getAlignmentX();
    ch.getGraphics();
    ch.setVisible(false);
    ch.setVisible(true);
    ch.setForeground(Color.red);
    ch.setBackground(Color.red);
    for (String font : Toolkit.getDefaultToolkit().getFontList()) {
      for (int j = 8; j < 17; j++) {
        Font f1 = new Font(font, Font.PLAIN, j);
        Font f2 = new Font(font, Font.BOLD, j);
        Font f3 = new Font(font, Font.ITALIC, j);
        Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j);

        ch.setFont(f1);
        ch.setFont(f2);
        ch.setFont(f3);
        ch.setFont(f4);

        ch.getFontMetrics(f1);
        ch.getFontMetrics(f2);
        ch.getFontMetrics(f3);
        ch.getFontMetrics(f4);
      }
    }
    ch.enable();
    ch.disable();
    ch.reshape(10, 10, 10, 10);
    ch.getBounds(new Rectangle(1, 1, 1, 1));
    ch.getSize(new Dimension(1, 2));
    ch.getLocation(new Point(1, 2));
    ch.getX();
    ch.getY();
    ch.getWidth();
    ch.getHeight();
    ch.isOpaque();
    ch.isValidateRoot();
    ch.isOptimizedDrawingEnabled();
    ch.isDoubleBuffered();
    ch.getComponentCount();
    ch.countComponents();
    ch.getComponent(1);
    ch.getComponent(2);
    Component[] cs = ch.getComponents();
    ch.getLayout();
    ch.setLayout(new FlowLayout());
    ch.doLayout();
    ch.layout();
    ch.invalidate();
    ch.validate();
    ch.remove(0);
    ch.remove(c2);
    ch.removeAll();
    ch.preferredSize();
    ch.minimumSize();
    ch.getComponentAt(1, 2);
    ch.locate(1, 2);
    ch.getComponentAt(new Point(1, 2));
    ch.isFocusCycleRoot(new Container());
    ch.transferFocusBackward();
    ch.setName("goober");
    ch.getName();
    ch.getParent();
    ch.getGraphicsConfiguration();
    ch.getTreeLock();
    ch.getToolkit();
    ch.isValid();
    ch.isDisplayable();
    ch.isVisible();
    ch.isShowing();
    ch.isEnabled();
    ch.enable(false);
    ch.enable(true);
    ch.enableInputMethods(false);
    ch.enableInputMethods(true);
    ch.show();
    ch.show(false);
    ch.show(true);
    ch.hide();
    ch.getForeground();
    ch.isForegroundSet();
    ch.getBackground();
    ch.isBackgroundSet();
    ch.getFont();
    ch.isFontSet();
    Container c = new Container();
    c.add(ch);
    ch.getLocale();
    for (Locale locale : Locale.getAvailableLocales()) ch.setLocale(locale);

    ch.getColorModel();
    ch.getLocation();

    boolean exceptions = false;
    try {
      ch.getLocationOnScreen();
    } catch (IllegalComponentStateException e) {
      exceptions = true;
    }
    if (!exceptions)
      throw new RuntimeException("IllegalComponentStateException did not occur when expected");

    ch.location();
    ch.setLocation(1, 2);
    ch.move(1, 2);
    ch.setLocation(new Point(1, 2));
    ch.getSize();
    ch.size();
    ch.setSize(1, 32);
    ch.resize(1, 32);
    ch.setSize(new Dimension(1, 32));
    ch.resize(new Dimension(1, 32));
    ch.getBounds();
    ch.bounds();
    ch.setBounds(10, 10, 10, 10);
    ch.setBounds(new Rectangle(10, 10, 10, 10));
    ch.isLightweight();
    ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    ch.getCursor();
    ch.isCursorSet();
    ch.inside(1, 2);
    ch.contains(new Point(1, 2));
    ch.isFocusable();
    ch.setFocusable(true);
    ch.setFocusable(false);
    ch.transferFocus();
    ch.getFocusCycleRootAncestor();
    ch.nextFocus();
    ch.transferFocusUpCycle();
    ch.hasFocus();
    ch.isFocusOwner();
    ch.toString();
    ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    ch.setComponentOrientation(ComponentOrientation.UNKNOWN);
    ch.getComponentOrientation();
  }