コード例 #1
0
  public Dimension minimumLayoutSize(Container c) {
    if (c != null) {
      Component[] children = c.getComponents();

      if (children != null && children.length > 0) {
        Dimension aSize;
        int numChildren = children.length;
        int height = 0;
        Insets cInsets = c.getInsets();
        int extraHeight = cInsets.top + cInsets.bottom;

        if (syncAllWidths) {
          int maxWidth = getMinimumButtonWidth();

          for (int counter = 0; counter < numChildren; counter++) {
            aSize = children[counter].getPreferredSize();
            height = Math.max(height, aSize.height);
            maxWidth = Math.max(maxWidth, aSize.width);
          }
          return new Dimension(
              maxWidth * numChildren + (numChildren - 1) * padding, extraHeight + height);
        }
        int totalWidth = 0;

        for (int counter = 0; counter < numChildren; counter++) {
          aSize = children[counter].getPreferredSize();
          height = Math.max(height, aSize.height);
          totalWidth += aSize.width;
        }
        totalWidth += ((numChildren - 1) * padding);
        return new Dimension(totalWidth, extraHeight + height);
      }
    }
    return new Dimension(0, 0);
  }
コード例 #2
0
ファイル: SSLayout.java プロジェクト: tomw2/visad
  /** Lays out the components. */
  public void layoutContainer(Container parent) {
    // get parent's components
    Component[] c = parent.getComponents();
    if (c.length < NumCols * NumRows) c = fillOut(c);

    // get preferred widths
    int[] pw = new int[NumCols];
    for (int i = 0; i < NumCols; i++) {
      pw[i] = c[i].getPreferredSize().width;
    }

    // get preferred heights
    int[] ph = new int[NumRows];
    for (int j = 0; j < NumRows; j++) {
      ph[j] = c[NumCols * j].getPreferredSize().height;
    }

    // lay out all components
    int sy = 0;
    for (int j = 0; j < NumRows; j++) {
      int sx = 0;
      for (int i = 0; i < NumCols; i++) {
        c[NumCols * j + i].setBounds(sx, sy, pw[i], ph[j]);
        sx += pw[i] + ColSpace;
      }
      sy += ph[j] + RowSpace;
    }
  }
コード例 #3
0
 public void validacamposobrigatorio(Container container, String tabela) {
   conecta_oracle.executeSQL("select * from" + tabela + "where rownum = 1");
   Component components[] = container.getComponents();
   for (Component component : components) {
     if (component instanceof JTextField) {
       JTextField field = (JTextField) component;
       String nome = field.getName();
       String conteudo = field.getText();
       String text = field.getToolTipText();
       int chave = field.getColumns();
       try {
         int numcols = conecta_oracle.metaData.getColumnCount();
         for (int conta = 1; conta <= numcols; conta++) {
           String colsname = conecta_oracle.metaData.getColumnName(conta);
           int obrigatorio = conecta_oracle.metaData.isNullable(conta);
           if (conteudo.equals("") && obrigatorio == 0) {
             if (chave != 1) {
               JOptionPane.showMessageDialog(null, "Campo " + text + " Obrigatório");
               field.grabFocus();
               retorno = 1;
               return;
             }
           }
         }
       } catch (SQLException erro) {
         JOptionPane.showMessageDialog(null, erro);
       }
     }
   }
 }
コード例 #4
0
 public Dimension preferredLayoutSize(Container parent) {
   return LayoutUtil.add(
       useSelectedComponentSize
           ? component == null ? new Dimension(0, 0) : component.getPreferredSize()
           : LayoutUtil.getMaxPreferredSize(parent.getComponents()),
       parent.getInsets());
 }
コード例 #5
0
  public void habilitarCampo(Container cont, boolean ToF) {
    for (Object campo : cont.getComponents()) {
      if (campo instanceof JFormattedTextField) {
        ((JFormattedTextField) campo).setEnabled(ToF);
      }
      if (campo instanceof JComboBox) {
        if (((JComboBox) campo).getName() != "cbTipoBanco") {
          ((JComboBox) campo).setEnabled(ToF);
        }
      }
      if (campo instanceof JTextField) {
        if (((JTextField) campo).getName() != "tfCodigo") {
          ((JTextField) campo).setEnabled(ToF);
        }
      }

      //            if (campo instanceof JButton) {
      //                if (((JButton) campo).getText() != "Novo" || ((JButton) campo).getText() !=
      // "Fechar") {
      //                    ((JTextField) campo).setEnabled(ToF);
      //                }
      //
      //
      //
      //            }
    }
  }
コード例 #6
0
ファイル: UIUtils.java プロジェクト: ypkkhatri/gmt
 public static void setStarkRed(Container container) {
   Component[] components = container.getComponents();
   for (Component component : components) {
     if (component instanceof JLabel) {
       JLabel l = (JLabel) component;
       String text = l.getText();
       if (!text.endsWith("*")) {
         continue;
       }
       text =
           "<html>" + text.substring(0, text.length() - 1) + "<font color='red' size='5'>*</font>";
       l.setText(text);
     } else if (component instanceof Container) {
       if (component instanceof JPanel) {
         Border b = ((JPanel) component).getBorder();
         if (b instanceof TitledBorder) {
           TitledBorder tb = (TitledBorder) b;
           String text = tb.getTitle();
           if (text.endsWith("*")) {
             text =
                 "<html>"
                     + text.substring(0, text.length() - 1)
                     + "<font color='red' size='5'>*</font>";
             tb.setTitle(text);
           }
         }
       }
       setStarkRed((Container) component);
     }
   }
 }
コード例 #7
0
ファイル: GenericListener.java プロジェクト: q1051278389/HMCL
 private void detachFromHierarchyOf(Container container) {
   container.removeContainerListener(this);
   Component[] components = container.getComponents();
   for (int i = 0; i < components.length; i++) {
     detachFrom(components[i]); // Will callback recursively any nested JPanels
   }
 }
コード例 #8
0
  private void recursiveButtonSearch(Container container) {
    for (Component component : container.getComponents()) {
      if (component instanceof Container) {
        recursiveButtonSearch((Container) component);
      }
      if (component instanceof JButton) {
        JButton button = (JButton) component;
        String buttonText = button.getText();

        // Using end of button text to determine whether button shouild be disabled
        // then disable it.  This is because JEditorPane does not disable buttons
        // disabled in the form html
        if (buttonText.endsWith(":disabled")) {
          buttonText = buttonText.substring(0, buttonText.lastIndexOf(":disabled"));
          button.setText(buttonText);
          button.setEnabled(false);
        }

        String extension = FileUtils.getFileExtension(buttonText);
        if (!extension.isEmpty()) {
          Icon icon = iconManager.get().getIconForExtension(extension);
          button.setIcon(icon);
        }
      }
    }
  }
コード例 #9
0
ファイル: PgmListLayout.java プロジェクト: sgr/niconama-alert
 private Dimension calcSizeWithRestriction(int width, Container target) {
   int h = 0;
   for (Component c : target.getComponents()) {
     ((PgmPanel) c).setWidth(width);
     h += c.getPreferredSize().height + SEPARATOR_THICKNESS;
   }
   return new Dimension(width, h);
 }
コード例 #10
0
 protected boolean containerHasComponent(Container container, Component comp) {
   for (Component _comp : container.getComponents()) {
     if (_comp == comp) {
       return true;
     }
   }
   return false;
 }
コード例 #11
0
 private static void setEnabled(Container container, boolean enabled) {
   for (Component component : container.getComponents()) {
     component.setEnabled(enabled);
     if (component instanceof Container) {
       setEnabled((Container) component, enabled);
     }
   }
 }
コード例 #12
0
 public static void habilitarPanel(Container panel, boolean valor) {
   panel.setEnabled(valor);
   for (Component componente : panel.getComponents()) {
     if (componente instanceof Container) {
       habilitarPanel((Container) componente, valor);
     }
   }
 }
コード例 #13
0
ファイル: PgmListLayout.java プロジェクト: sgr/niconama-alert
 private Dimension calcSizeNoRestriction(Container target) {
   int w = 0;
   int h = 0;
   for (Component c : target.getComponents()) {
     w += c.getPreferredSize().width;
     h += c.getPreferredSize().height + SEPARATOR_THICKNESS;
   }
   return new Dimension(w, h);
 }
コード例 #14
0
ファイル: GenericListener.java プロジェクト: q1051278389/HMCL
 void attachToHierarchyOf(Container container) {
   if (!Arrays.asList(container.getContainerListeners()).contains(this)) {
     container.addContainerListener(this);
   }
   Component[] components = container.getComponents();
   for (int i = 0; i < components.length; i++) {
     attachTo(components[i]); // Will recursively add any child components in
   }
 }
コード例 #15
0
ファイル: UIUtils.java プロジェクト: ypkkhatri/gmt
 public static void setContainerEnabled(Container container, boolean aFlag) {
   Component[] components = container.getComponents();
   for (Component component : components) {
     component.setEnabled(aFlag);
     if (component instanceof Container) {
       setContainerEnabled((Container) component, aFlag);
     }
   }
 }
コード例 #16
0
  public void layoutContainer(Container parent) {
    Component[] c = parent.getComponents();
    Insets parentInsets = parent.getInsets();
    Dimension size = LayoutUtil.getInteriorSize(parent);

    for (int i = 0; i < c.length; i++) {
      c[i].setBounds(parentInsets.left, parentInsets.top, size.width, size.height);
    }
  }
コード例 #17
0
 private void componentAdded(Component comp) {
   comp.addKeyListener(keyHandler);
   if (comp instanceof Container) {
     Container cont = (Container) comp;
     cont.addContainerListener(this);
     Component[] comps = cont.getComponents();
     for (Component comp1 : comps) componentAdded(comp1);
   }
 }
コード例 #18
0
ファイル: VictimGUI.java プロジェクト: jamesesilvia/CS509
 /**
  * Disables the checkboxes in this panel. First, a search is performed to determine if the
  * textfield in this JPanel should be saved. If not, then all components are disabled. This forces
  * the user to only select one checkbox per panel.
  *
  * @param container - the panel to search for checkboxes.
  * @param cb - the checkbox to leave enabled.
  */
 public void toggleAllCheckBoxesInPanel(Container container, Object cb) {
   for (int i = 0; i < container.getComponents().length; i++) {
     if (container.getComponent(i) instanceof JCheckBox) {
       if (!container.getComponent(i).equals(cb)) {
         container.getComponent(i).setEnabled(!container.getComponent(i).isEnabled());
       }
     }
   }
 }
コード例 #19
0
 private void enableComponents(Container container, boolean enable) {
   Component[] components = container.getComponents();
   for (Component component : components) {
     component.setEnabled(enable);
     if (component instanceof Container) {
       enableComponents((Container) component, enable);
     }
   }
 }
コード例 #20
0
ファイル: OrderText.java プロジェクト: jiangwenqiang/GitHub
 /** @param c */
 private void removeKeyAndContainerListenerRecursively(Component c) {
   c.removeKeyListener(keyListener);
   if (c instanceof Container) {
     Container cont = (Container) c;
     Component[] children = cont.getComponents();
     for (int i = 0; i < children.length; i++) {
       removeKeyAndContainerListenerRecursively(children[i]);
     }
   }
 }
コード例 #21
0
  @Override
  public void layoutContainer(Container parent) {

    if (parent != container) {
      throw new LayoutException(
          "All layout operations must occur upon this manager's parent container");
    }

    paraboxLayout.doLayout(parent.getWidth(), parent.getHeight(), parent.getComponents());
  }
コード例 #22
0
 private static void changeTablesFont(Container c, Font f) {
   Component[] comps = c.getComponents();
   for (Component comp : comps) {
     if (comp instanceof LimeJTable) {
       changeTableFont((JTable) comp, f);
     } else if (comp instanceof Container) {
       changeTablesFont((Container) comp, f);
     }
   }
 }
コード例 #23
0
 public void layoutContainer(Container parent) {
   Insets insets = parent.getInsets();
   if (parent.getComponentOrientation().isLeftToRight()) {
     int x = insets.left;
     for (Component component : parent.getComponents()) {
       Dimension ps = component.getPreferredSize();
       component.setBounds(
           x, insets.top, ps.width, parent.getHeight() - insets.top - insets.bottom);
       x += ps.width - overlap;
     }
   } else {
     int x = parent.getWidth() - insets.right;
     for (Component component : parent.getComponents()) {
       Dimension ps = component.getPreferredSize();
       component.setBounds(
           x - ps.width, insets.top, ps.width, parent.getHeight() - insets.top - insets.bottom);
       x += overlap - ps.width;
     }
   }
 }
コード例 #24
0
 public static boolean isEmpty(Container menu) {
   Component[] components = menu.getComponents();
   for (int i = 0, n = components.length; i < n; i++) {
     if (components[i] instanceof Action || components[i] instanceof JMenuItem) {
       return false;
     } else if (components[i] instanceof JMenu && !isEmpty((Container) components[i])) {
       return false;
     }
   }
   return true;
 }
コード例 #25
0
 /**
  * This method adds a {@link KeyListener} to all added components. This is done recursively.
  *
  * @param c The {@link Component} that is added.
  */
 private void addKeyAndContainerListenerRecursively(final Component c) {
   c.addKeyListener(this);
   if (c instanceof Container) {
     final Container cont = (Container) c;
     cont.addContainerListener(this);
     final Component[] children = cont.getComponents();
     for (int i = 0; i < children.length; i++) {
       addKeyAndContainerListenerRecursively(children[i]);
     }
   }
 }
コード例 #26
0
  private void removeComponents(Container cont) {
    Component[] components = cont.getComponents();
    Component comp;

    for (int i = 0; i < components.length; i++) {
      comp = components[i];
      if (comp != null) {
        cont.remove(comp);
        if (comp instanceof Container) removeComponents((Container) comp);
      }
    }
  }
コード例 #27
0
ファイル: TitledPanel.java プロジェクト: sjroot/framework
    public void layoutContainer(Container parent) {
      synchronized (parent.getTreeLock()) {
        Insets margin = parent.getInsets();
        int x = margin.left;
        int y = margin.top;
        int w = parent.getWidth() - (margin.left + margin.right);
        int h = parent.getHeight() - (margin.top + margin.bottom);
        Component header = findHeader(parent.getComponents());
        if (header != null && header.isVisible()) {
          Dimension dim = header.getPreferredSize();
          header.setBounds(x, y, w, dim.height);
          y += dim.height;
          h -= dim.height;
        }

        Component body = findBody(parent.getComponents());
        if (body != null && body.isVisible()) {
          body.setBounds(x, y, w, h);
        }
      }
    }
コード例 #28
0
  public void limpaCampo(Container cont) {
    for (Object campo : cont.getComponents()) {

      if (campo instanceof JTextField) {
        if (((JTextField) campo).getName() != "tfValor") {
          ((JTextField) campo).setText(null);
        } else {
          ((JTextField) campo).setText("0,00");
        }
      }
    }
  }
コード例 #29
0
ファイル: PgmListLayout.java プロジェクト: sgr/niconama-alert
 public Dimension minimumLayoutSize(Container target) {
   if (_minimumLayoutSize == null) {
     int w = 0;
     int h = 0;
     for (Component c : target.getComponents()) {
       w += c.getMinimumSize().width;
       h += c.getMinimumSize().height + SEPARATOR_THICKNESS;
     }
     _minimumLayoutSize = new Dimension(w, h);
   }
   return _minimumLayoutSize;
 }
コード例 #30
0
 /** 건네받는 컨테이너에 포함된 텍스트 필드와 콤보박스 초기화 */
 public static void initInformation(Container con) {
   Component[] comps = con.getComponents();
   for (Component component : comps) {
     /** 콤보박스일 경우 첫 값으로 설정 */
     if (component instanceof JComboBox) {
       ((JComboBox) component).setSelectedIndex(0);
     }
     /** 텍스트 컴포넌트일 경우 빈 값으로 설정 */
     if (component instanceof JTextComponent) {
       ((JTextComponent) component).setText("");
     }
   }
 }