@Override
 public Dimension minimumLayoutSize(Container parent) {
   Component toolbar = parent.getComponent(0);
   Dimension toolbarSize = toolbar.isVisible() ? toolbar.getMinimumSize() : new Dimension();
   Dimension contentSize = parent.getComponent(1).getMinimumSize();
   return new Dimension(
       Math.max(toolbarSize.width, contentSize.width), toolbarSize.height + contentSize.height);
 }
 @Override
 public void layoutContainer(Container parent) {
   int width = parent.getWidth();
   int height = parent.getHeight();
   Component toolbar = parent.getComponent(0);
   Dimension toolbarSize = toolbar.isVisible() ? toolbar.getPreferredSize() : new Dimension();
   toolbar.setBounds(0, 0, width, toolbarSize.height);
   parent.getComponent(1).setBounds(0, toolbarSize.height, width, height - toolbarSize.height);
 }
  private boolean is(boolean first) {
    Container parent = getParent();
    if (parent == null) return false;

    int max = first ? Integer.MAX_VALUE : 0;
    ToolWindowAnchor anchor = getAnchor();
    Component c = null;
    int count = parent.getComponentCount();
    for (int i = 0; i < count; i++) {
      Component component = parent.getComponent(i);
      if (!component.isVisible()) continue;
      Rectangle r = component.getBounds();
      if (anchor == ToolWindowAnchor.LEFT || anchor == ToolWindowAnchor.RIGHT) {
        if (first && (max > r.y) || (!first && max < r.y)) {
          max = r.y;
          c = component;
        }
      } else {
        if (first && (max > r.x) || (!first && max < r.x)) {
          max = r.x;
          c = component;
        }
      }
    }

    return c == this;
  }
    @Override
    public void layoutContainer(final Container parent) {
      final int componentCount = parent.getComponentCount();
      if (componentCount == 0) return;
      final EditorEx history = myHistoryViewer;
      final EditorEx editor = componentCount == 2 ? myConsoleEditor : null;

      if (editor == null) {
        parent.getComponent(0).setBounds(parent.getBounds());
        return;
      }

      final Dimension panelSize = parent.getSize();
      if (panelSize.getHeight() <= 0) return;
      final Dimension historySize = history.getContentSize();
      final Dimension editorSize = editor.getContentSize();
      final Dimension newEditorSize = new Dimension();

      // deal with width
      final int width = Math.max(editorSize.width, historySize.width);
      newEditorSize.width = width + editor.getScrollPane().getHorizontalScrollBar().getHeight();
      history.getSoftWrapModel().forceAdditionalColumnsUsage();
      editor
          .getSettings()
          .setAdditionalColumnsCount(
              2 + (width - editorSize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, editor));
      history
          .getSettings()
          .setAdditionalColumnsCount(
              2 + (width - historySize.width) / EditorUtil.getSpaceWidth(Font.PLAIN, history));

      // deal with height
      if (historySize.width == 0) historySize.height = 0;
      final int minHistorySize =
          historySize.height > 0
              ? 2 * history.getLineHeight() + (myShowSeparatorLine ? SEPARATOR_THICKNESS : 0)
              : 0;
      final int minEditorSize = editor.isViewer() ? 0 : editor.getLineHeight();
      final int editorPreferred =
          editor.isViewer() ? 0 : Math.max(minEditorSize, editorSize.height);
      final int historyPreferred = Math.max(minHistorySize, historySize.height);
      if (panelSize.height < minEditorSize) {
        newEditorSize.height = panelSize.height;
      } else if (panelSize.height < editorPreferred) {
        newEditorSize.height = panelSize.height - minHistorySize;
      } else if (panelSize.height < editorPreferred + historyPreferred) {
        newEditorSize.height = editorPreferred;
      } else {
        newEditorSize.height = editorPreferred == 0 ? 0 : panelSize.height - historyPreferred;
      }
      final Dimension newHistorySize =
          new Dimension(width, panelSize.height - newEditorSize.height);

      // apply
      editor
          .getComponent()
          .setBounds(0, newHistorySize.height, panelSize.width, newEditorSize.height);
      myForceScrollToEnd.compareAndSet(false, shouldScrollHistoryToEnd());
      history.getComponent().setBounds(0, 0, panelSize.width, newHistorySize.height);
    }
  public static final Component getChildAtLine(
      Container container, Point point, boolean horizontal) {
    if (horizontal) {
      for (int i = 0; i < container.getComponentCount(); i++) {
        Component component = container.getComponent(i);
        if (point.x >= component.getX() && point.x < component.getX() + component.getWidth())
          return component;
      }
    } else {
      for (int i = 0; i < container.getComponentCount(); i++) {
        Component component = container.getComponent(i);
        if (point.y >= component.getY() && point.y < component.getY() + component.getHeight())
          return component;
      }
    }

    return null;
  }
Esempio n. 6
0
 public static void recursiveSetBackground(Component comp, Color color) {
   if (comp instanceof JToolBar || comp instanceof JButton) return;
   comp.setBackground(color);
   if (comp instanceof Container) {
     Container cc = (Container) comp;
     for (int i = 0; i < cc.getComponentCount(); i++)
       recursiveSetBackground(cc.getComponent(i), color);
   }
 }
Esempio n. 7
0
 private static void updateSizesFromChildren(DimensionInfo info, boolean min, int[] widths) {
   for (int i = info.getComponentCount() - 1; i >= 0; --i) {
     Component child = info.getComponent(i);
     GridConstraints c = info.getConstraints(i);
     if (c.isUseParentLayout() && child instanceof Container) {
       Container container = (Container) child;
       if (container.getLayout() instanceof GridLayoutManager) {
         updateSizesFromChild(info, min, widths, container, i);
       } else if (container.getComponentCount() == 1
           && container.getComponent(0) instanceof Container) {
         Container childContainer = (Container) container.getComponent(0);
         if (childContainer.getLayout() instanceof GridLayoutManager) {
           updateSizesFromChild(info, min, widths, childContainer, i);
         }
       }
     }
   }
 }
 public static void setAllOpaque(Container container, boolean opaque) {
   if (container instanceof JComponent) {
     ((JComponent) container).setOpaque(opaque);
     for (int i = 0; i < container.getComponentCount(); i++) {
       Component component = container.getComponent(i);
       if (component instanceof Container) setAllOpaque((Container) component, opaque);
     }
   }
 }
  public static final Component getVisibleChildAt(Container container, Point point) {
    for (int i = 0; i < container.getComponentCount(); i++) {
      Component component = container.getComponent(i);
      if (component.isVisible()
          && component.contains(point.x - component.getX(), point.y - component.getY()))
        return component;
    }

    return null;
  }
  public static int countComponents(Container container) {
    int num = 1;
    for (int i = 0; i < container.getComponentCount(); i++) {
      Component comp = container.getComponent(i);
      if (comp instanceof Container) num += countComponents((Container) comp);
      else num++;
    }

    return num;
  }
  public static final int getComponentIndex(Component component) {
    if (component != null && component.getParent() != null) {
      Container container = component.getParent();
      for (int i = 0; i < container.getComponentCount(); i++) {
        if (container.getComponent(i) == component) return i;
      }
    }

    return -1;
  }
Esempio n. 12
0
 @Override
 public Dimension preferredLayoutSize(final Container parent) {
   Dimension result = new Dimension();
   for (int i = 0; i < parent.getComponentCount(); i++) {
     final Dimension prefSize = parent.getComponent(i).getPreferredSize();
     result.width += prefSize.width;
     result.height = Math.max(prefSize.height, result.height);
   }
   return result;
 }
  public static int getVisibleChildrenCount(Component component) {
    if (component == null || !(component instanceof Container)) return 0;

    int count = 0;
    Container container = (Container) component;

    for (int i = 0; i < container.getComponentCount(); i++)
      if (container.getComponent(i).isVisible()) count++;

    return count;
  }
Esempio n. 14
0
  public Dimension preferredLayoutSize(Container parent) {
    Insets insets = parent.insets();
    int ncomponents = parent.countComponents();
    int nrows = getRows();
    int ncols = getColumns();
    int hgap = getHgap();
    int vgap = getVgap();

    if (nrows > 0) {
      ncols = (ncomponents + nrows - 1) / nrows;
    } else {
      nrows = (ncomponents + ncols - 1) / ncols;
    }

    int nComps = parent.getComponentCount();

    int y = insets.top;
    for (int row = 0; row < nrows; row++) {
      int h = 0;
      for (int col = 0; col < ncols; col++) {
        if (row * ncols + col < nComps) {
          Component c = parent.getComponent(row * ncols + col);
          h = Math.max(h, c.getMinimumSize().height);
        }
      }
      y += h + vgap;
    }

    int x = insets.left;
    for (int col = 0; col < ncols; col++) {
      int w = 0;
      for (int row = 0; row < nrows; row++) {
        if (row * ncols + col < nComps) {
          Component c = parent.getComponent(row * ncols + col);
          w = Math.max(w, c.getMinimumSize().width);
        }
      }
      x += w + hgap;
    }
    return new Dimension(x, y);
  }
  public static Component findFirstComponentOfType(Component component, Class nowClass) {
    if (nowClass.isInstance(component)) return component;

    if (component instanceof Container) {
      Container container = (Container) component;
      for (int i = 0; i < container.getComponentCount(); i++) {
        Component firstComponent = findFirstComponentOfType(container.getComponent(i), nowClass);
        if (firstComponent != null) return firstComponent;
      }
    }
    return null;
  }
Esempio n. 16
0
    @Override
    public void layoutContainer(final Container parent) {
      assert parent.getComponentCount() == 2; // 1. info; 2. progress

      Component infoPanel = parent.getComponent(0);
      Component progressPanel = parent.getComponent(1);
      int progressPrefWidth = progressPanel.getPreferredSize().width;

      final Dimension size = parent.getSize();
      int maxProgressWidth = (int) (size.width * 0.8);
      int minProgressWidth = (int) (size.width * 0.5);
      if (progressPrefWidth > myProgressWidth) {
        myProgressWidth = progressPrefWidth;
      }
      if (myProgressWidth > maxProgressWidth) {
        myProgressWidth = maxProgressWidth;
      }
      if (myProgressWidth < minProgressWidth) {
        myProgressWidth = minProgressWidth;
      }
      infoPanel.setBounds(0, 0, size.width - myProgressWidth, size.height);
      progressPanel.setBounds(size.width - myProgressWidth, 0, myProgressWidth, size.height);
    }
Esempio n. 17
0
  public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();

    Component c;
    c = parent.getComponent(0);
    if (c.isVisible()) {
      c.setBounds(insets.left + 152, insets.top + 64, 176, 24);
    }
    c = parent.getComponent(1);
    if (c.isVisible()) {
      c.setBounds(insets.left + 152, insets.top + 96, 176, 24);
    }
    c = parent.getComponent(2);
    if (c.isVisible()) {
      c.setBounds(insets.left + 72, insets.top + 8, 184, 32);
    }
    c = parent.getComponent(3);
    if (c.isVisible()) {
      c.setBounds(insets.left + 16, insets.top + 64, 128, 24);
    }
    c = parent.getComponent(4);
    if (c.isVisible()) {
      c.setBounds(insets.left + 16, insets.top + 96, 128, 24);
    }
    c = parent.getComponent(5);
    if (c.isVisible()) {
      c.setBounds(insets.left + 56, insets.top + 176, 96, 32);
    }
    c = parent.getComponent(6);
    if (c.isVisible()) {
      c.setBounds(insets.left + 176, insets.top + 176, 96, 32);
    }
    c = parent.getComponent(7);
    if (c.isVisible()) {
      c.setBounds(insets.left + 152, insets.top + 128, 176, 24);
    }
    c = parent.getComponent(8);
    if (c.isVisible()) {
      c.setBounds(insets.left + 16, insets.top + 128, 128, 24);
    }
  }
Esempio n. 18
0
  /**
   * @param aContainer
   * @param aComponentClass
   * @return
   */
  private static Component findComponent(
      final Container aContainer, final Class<? extends Component> aComponentClass) {
    Component result = null;

    final int cnt = aContainer.getComponentCount();
    for (int i = 0; (result == null) && (i < cnt); i++) {
      final Component comp = aContainer.getComponent(i);
      if (aComponentClass.equals(comp.getClass())) {
        result = comp;
      } else if (comp instanceof Container) {
        result = findComponent((Container) comp, aComponentClass);
      }
    }
    return result;
  }
  /**
   * Aligns the first <code>rows</code> * <code>cols</code> components of <code>parent</code> in a
   * grid. Each component is as big as the maximum preferred width and height of the components. The
   * parent is made just big enough to fit them all.
   *
   * @param rows number of rows
   * @param cols number of columns
   * @param initialX x location to start the grid at
   * @param initialY y location to start the grid at
   * @param xPad x padding between cells
   * @param yPad y padding between cells
   */
  public static void makeGrid(
      Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) {
    SpringLayout layout;
    try {
      layout = (SpringLayout) parent.getLayout();
    } catch (ClassCastException exc) {
      System.err.println("The first argument to makeGrid must use SpringLayout.");
      return;
    }

    Spring xPadSpring = Spring.constant(xPad);
    Spring yPadSpring = Spring.constant(yPad);
    Spring initialXSpring = Spring.constant(initialX);
    Spring initialYSpring = Spring.constant(initialY);
    int max = rows * cols;

    // Calculate Springs that are the max of the width/height so that all
    // cells have the same size.
    Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
    Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
    for (int i = 1; i < max; i++) {
      SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));

      maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
      maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
    }

    // Apply the new width/height Spring. This forces all the
    // components to have the same size.
    for (int i = 0; i < max; i++) {
      SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));

      cons.setWidth(maxWidthSpring);
      cons.setHeight(maxHeightSpring);
    }

    // Then adjust the x/y constraints of all the cells so that they
    // are aligned in a grid.
    SpringLayout.Constraints lastCons = null;
    SpringLayout.Constraints lastRowCons = null;
    for (int i = 0; i < max; i++) {
      SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));
      if (i % cols == 0) { // start of new row
        lastRowCons = lastCons;
        cons.setX(initialXSpring);
      } else { // x position depends on previous component
        cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST), xPadSpring));
      }

      if (i / cols == 0) { // first row
        cons.setY(initialYSpring);
      } else { // y position depends on previous row
        cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH), yPadSpring));
      }
      lastCons = cons;
    }

    // Set the parent's size.
    SpringLayout.Constraints pCons = layout.getConstraints(parent);
    pCons.setConstraint(
        SpringLayout.SOUTH,
        Spring.sum(Spring.constant(yPad), lastCons.getConstraint(SpringLayout.SOUTH)));
    pCons.setConstraint(
        SpringLayout.EAST,
        Spring.sum(Spring.constant(xPad), lastCons.getConstraint(SpringLayout.EAST)));
  }
 /* Used by makeCompactGrid. */
 private static SpringLayout.Constraints getConstraintsForCell(
     int row, int col, Container parent, int cols) {
   SpringLayout layout = (SpringLayout) parent.getLayout();
   Component c = parent.getComponent(row * cols + col);
   return layout.getConstraints(c);
 }
Esempio n. 21
0
  private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Octavio Maia
    label1 = new JLabel();
    comboBox1 = new JComboBox<>();
    label2 = new JLabel();
    data = new JLabel();
    buttonDataNascimento = new JButton();
    buttonCancelar = new JButton();
    buttonAvancar = new JButton();
    separator1 = new JSeparator();
    dialogoCalendar = new JDialog();
    calendar1 = new JCalendar();
    buttonConfirmarDataInicio = new JButton();
    buttonCancelarData = new JButton();

    // ======== this ========
    setTitle("Criar Elei\u00e7\u00e3o");
    setResizable(false);
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(null);

    // ---- label1 ----
    label1.setText("Tipo de elei\u00e7\u00e3o:");
    label1.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(label1);
    label1.setBounds(10, 10, label1.getPreferredSize().width, 25);

    // ---- comboBox1 ----
    comboBox1.setFont(new Font("Arial", Font.PLAIN, 14));
    comboBox1.setModel(
        new DefaultComboBoxModel<>(
            new String[] {"Assembleia da Rep\u00fablica", "Presid\u00eancia da Rep\u00fablica"}));
    contentPane.add(comboBox1);
    comboBox1.setBounds(125, 10, 215, 25);

    // ---- label2 ----
    label2.setText("Data:");
    label2.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(label2);
    label2.setBounds(10, 50, 101, 25);

    // ---- data ----
    data.setText("dd/mm/aa");
    data.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(data);
    data.setBounds(125, 50, 115, 25);

    // ---- buttonDataNascimento ----
    buttonDataNascimento.setText("Alterar");
    buttonDataNascimento.setFont(new Font("Arial", Font.PLAIN, 14));
    buttonDataNascimento.addActionListener(e -> buttonDataActionPerformed(e));
    contentPane.add(buttonDataNascimento);
    buttonDataNascimento.setBounds(260, 50, 80, 25);

    // ---- buttonCancelar ----
    buttonCancelar.setText("Cancelar");
    buttonCancelar.setFont(new Font("Arial", Font.PLAIN, 14));
    buttonCancelar.addActionListener(e -> buttonCancelarActionPerformed(e));
    contentPane.add(buttonCancelar);
    buttonCancelar.setBounds(100, 90, 115, 25);

    // ---- buttonAvancar ----
    buttonAvancar.setText("Avan\u00e7ar");
    buttonAvancar.setFont(new Font("Arial", Font.PLAIN, 14));
    buttonAvancar.setEnabled(false);
    buttonAvancar.addActionListener(e -> buttonAvancarActionPerformed(e));
    contentPane.add(buttonAvancar);
    buttonAvancar.setBounds(230, 90, 110, buttonAvancar.getPreferredSize().height);
    contentPane.add(separator1);
    separator1.setBounds(5, 80, 340, 5);

    { // compute preferred size
      Dimension preferredSize = new Dimension();
      for (int i = 0; i < contentPane.getComponentCount(); i++) {
        Rectangle bounds = contentPane.getComponent(i).getBounds();
        preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
        preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
      }
      Insets insets = contentPane.getInsets();
      preferredSize.width += insets.right;
      preferredSize.height += insets.bottom;
      contentPane.setMinimumSize(preferredSize);
      contentPane.setPreferredSize(preferredSize);
    }
    setSize(365, 160);
    setLocationRelativeTo(null);

    // ======== dialogoCalendar ========
    {
      dialogoCalendar.setTitle("Calendario");
      dialogoCalendar.setResizable(false);
      dialogoCalendar.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
      Container dialogoCalendarContentPane = dialogoCalendar.getContentPane();
      dialogoCalendarContentPane.setLayout(null);
      dialogoCalendarContentPane.add(calendar1);
      calendar1.setBounds(0, 0, 210, 155);

      // ---- buttonConfirmarDataInicio ----
      buttonConfirmarDataInicio.setText("Confirmar");
      buttonConfirmarDataInicio.setFont(new Font("Arial", Font.PLAIN, 12));
      buttonConfirmarDataInicio.addActionListener(e -> buttonConfirmarDataActionPerformed(e));
      dialogoCalendarContentPane.add(buttonConfirmarDataInicio);
      buttonConfirmarDataInicio.setBounds(5, 155, 90, 28);

      // ---- buttonCancelarData ----
      buttonCancelarData.setText("Cancelar");
      buttonCancelarData.setFont(new Font("Arial", Font.PLAIN, 12));
      buttonCancelarData.addActionListener(e -> buttonCancelarDataActionPerformed(e));
      dialogoCalendarContentPane.add(buttonCancelarData);
      buttonCancelarData.setBounds(110, 155, 90, 28);

      dialogoCalendarContentPane.setPreferredSize(new Dimension(225, 235));
      dialogoCalendar.setSize(225, 235);
      dialogoCalendar.setLocationRelativeTo(null);
    }
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
  }
Esempio n. 22
0
    private void initComponents() {
      label1 = new JLabel();
      comboBox1 = new JComboBox();
      button1 = new JButton();

      // ======== this ========
      setTitle("SneakyFarmer");
      Container contentPane = getContentPane();
      contentPane.setLayout(null);

      // ---- label1 ----
      label1.setText("Which herb to farm:");
      label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 1f));
      contentPane.add(label1);
      label1.setBounds(10, 10, 125, 35);

      // ---- comboBox1 ----
      comboBox1.setModel(
          new DefaultComboBoxModel(
              new String[] {
                "Guam",
                "Marrentill",
                "Tarromin",
                "Harralander",
                "Ranarr",
                "Toadflax",
                "Irit",
                "Avantoe",
                "Kwuarm",
                "Snapdragon",
                "Cadantine",
                "Lantadyme",
                "Dwarf Weed",
                "Torstol"
              }));
      contentPane.add(comboBox1);
      comboBox1.setBounds(135, 10, 90, 35);

      // ---- button1 ----
      button1.setText("Start Farming!");
      button1.setFont(button1.getFont().deriveFont(button1.getFont().getSize() + 7f));
      contentPane.add(button1);
      button1.setBounds(10, 50, 215, 35);
      button1.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              startActionPerformed(e);
            }
          });

      { // compute preferred size
        Dimension preferredSize = new Dimension();
        for (int i = 0; i < contentPane.getComponentCount(); i++) {
          Rectangle bounds = contentPane.getComponent(i).getBounds();
          preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
          preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
        }
        Insets insets = contentPane.getInsets();
        preferredSize.width += insets.right;
        preferredSize.height += insets.bottom;
        contentPane.setMinimumSize(preferredSize);
        contentPane.setPreferredSize(preferredSize);
      }
      pack();
      setLocationRelativeTo(getOwner());
    }
Esempio n. 23
0
  private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Chance Turner
    mainMenuBar = new JMenuBar();
    maintenanceMenu = new JMenu();
    editStore = new JMenuItem();
    editItem = new JMenuItem();
    editTaxCategory = new JMenuItem();
    editCashier = new JMenuItem();
    editRegister = new JMenuItem();
    menu1 = new JMenu();
    loginToPos = new JMenuItem();
    menu2 = new JMenu();
    dailySalesReportMenuItem = new JMenuItem();
    itemSalesReportMenuItem = new JMenuItem();
    cashierSalesReportMenuItem = new JMenuItem();
    panel1 = new JPanel();

    // ======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(null);

    // ======== mainMenuBar ========
    {

      // ======== maintenanceMenu ========
      {
        maintenanceMenu.setText("Maintenance");

        // ---- editStore ----
        editStore.setText("Edit Store");
        editStore.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                editStoreActionPerformed(e);
              }
            });
        maintenanceMenu.add(editStore);

        // ---- editItem ----
        editItem.setText("Edit Item");
        editItem.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                editItemActionPerformed(e);
              }
            });
        maintenanceMenu.add(editItem);

        // ---- editTaxCategory ----
        editTaxCategory.setText("Edit Tax Category");
        editTaxCategory.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                editTaxCategoryActionPerformed(e);
              }
            });
        maintenanceMenu.add(editTaxCategory);

        // ---- editCashier ----
        editCashier.setText("Edit Cashier");
        editCashier.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                editCashierActionPerformed(e);
              }
            });
        maintenanceMenu.add(editCashier);

        // ---- editRegister ----
        editRegister.setText("Edit Register");
        editRegister.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                editRegisterActionPerformed(e);
              }
            });
        maintenanceMenu.add(editRegister);
      }
      mainMenuBar.add(maintenanceMenu);

      // ======== menu1 ========
      {
        menu1.setText("POS");

        // ---- loginToPos ----
        loginToPos.setText("Login");
        loginToPos.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                loginToPosActionPerformed(e);
              }
            });
        menu1.add(loginToPos);
      }
      mainMenuBar.add(menu1);

      // ======== menu2 ========
      {
        menu2.setText("Reports");

        // ---- dailySalesReportMenuItem ----
        dailySalesReportMenuItem.setText("Daily Sales");
        dailySalesReportMenuItem.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                dailySalesReportMenuItemActionPerformed(e);
              }
            });
        menu2.add(dailySalesReportMenuItem);

        // ---- itemSalesReportMenuItem ----
        itemSalesReportMenuItem.setText("Item Sales");
        itemSalesReportMenuItem.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                itemSalesReportMenuItemActionPerformed(e);
              }
            });
        menu2.add(itemSalesReportMenuItem);

        // ---- cashierSalesReportMenuItem ----
        cashierSalesReportMenuItem.setText("Cashier Sales");
        cashierSalesReportMenuItem.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                cashierSalesReportMenuItemActionPerformed(e);
              }
            });
        menu2.add(cashierSalesReportMenuItem);
      }
      mainMenuBar.add(menu2);
    }
    setJMenuBar(mainMenuBar);

    // ======== panel1 ========
    {

      // JFormDesigner evaluation mark
      panel1.setBorder(
          new javax.swing.border.CompoundBorder(
              new javax.swing.border.TitledBorder(
                  new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                  "JFormDesigner Evaluation",
                  javax.swing.border.TitledBorder.CENTER,
                  javax.swing.border.TitledBorder.BOTTOM,
                  new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
                  java.awt.Color.red),
              panel1.getBorder()));
      panel1.addPropertyChangeListener(
          new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent e) {
              if ("border".equals(e.getPropertyName())) throw new RuntimeException();
            }
          });

      panel1.setLayout(null);

      { // compute preferred size
        Dimension preferredSize = new Dimension();
        for (int i = 0; i < panel1.getComponentCount(); i++) {
          Rectangle bounds = panel1.getComponent(i).getBounds();
          preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
          preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
        }
        Insets insets = panel1.getInsets();
        preferredSize.width += insets.right;
        preferredSize.height += insets.bottom;
        panel1.setMinimumSize(preferredSize);
        panel1.setPreferredSize(preferredSize);
      }
    }
    contentPane.add(panel1);
    panel1.setBounds(0, 0, 580, 415);

    { // compute preferred size
      Dimension preferredSize = new Dimension();
      for (int i = 0; i < contentPane.getComponentCount(); i++) {
        Rectangle bounds = contentPane.getComponent(i).getBounds();
        preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
        preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
      }
      Insets insets = contentPane.getInsets();
      preferredSize.width += insets.right;
      preferredSize.height += insets.bottom;
      contentPane.setMinimumSize(preferredSize);
      contentPane.setPreferredSize(preferredSize);
    }
    pack();
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
  }
Esempio n. 24
0
  public void layoutContainer(Container parent) {
    Insets insets = parent.insets();
    int ncomponents = parent.countComponents();
    int nrows = getRows();
    int ncols = getColumns();
    int hgap = getHgap();
    int vgap = getVgap();

    if (nrows > 0) {
      ncols = (ncomponents + nrows - 1) / nrows;
    } else {
      nrows = (ncomponents + ncols - 1) / ncols;
    }

    // Set heights
    int x;
    int y;
    int nFills = 0;
    boolean[] fills = new boolean[nrows];
    int lastFillRow = -1;
    int nComps = parent.getComponentCount();

    y = insets.top;
    for (int row = 0; row < nrows; row++) {
      // Find largest minimum height for this row
      int h = 0;
      for (int col = 0; col < ncols; col++) {
        if (row * ncols + col < nComps) {
          Component c = parent.getComponent(row * ncols + col);
          h = Math.max(h, c.getMinimumSize().height);
        }
      }
      // Set heights for this row
      x = insets.left;
      for (int col = 0; col < ncols; col++) {
        if (row * ncols + col < nComps) {
          JComponent c = (JComponent) parent.getComponent(row * ncols + col);
          int w = c.getWidth();
          c.setBounds(x, y, w, h);
          x += w + hgap;
          if (col == 0 && getFillRow(c)) {
            fills[row] = true;
          }
        }
      }
      y += h + vgap;
      if (fills[row]) {
        nFills++;
        lastFillRow = row;
      }
    }

    // Fill heights
    if (nFills > 0 && y < parent.getHeight()) {
      // How much height to add
      int hAdd = (parent.getHeight() - y) / nFills;
      int hAdded = 0;
      for (int row = 0; row < nrows; row++) {
        if (fills[row]) {
          if (row == lastFillRow) {
            // Compensate for rounding error
            hAdd = parent.getHeight() - (y + hAdded);
          }
          for (int col = 0; col < ncols; col++) {
            if (row * ncols + col < nComps) {
              Component c = parent.getComponent(row * ncols + col);
              Rectangle b = c.getBounds();
              c.setBounds(b.x, b.y + hAdded, b.width, b.height + hAdd);
            }
          }
          hAdded += hAdd;
        }
      }
    }

    // Set widths
    nFills = 0;
    fills = new boolean[ncols];
    int lastFillCol = -1;

    x = insets.left;
    for (int col = 0; col < ncols; col++) {
      // Find largest minimum width for this column
      int w = 0;
      for (int row = 0; row < nrows; row++) {
        if (row * ncols + col < nComps) {
          Component c = parent.getComponent(row * ncols + col);
          w = Math.max(w, c.getMinimumSize().width);
        }
      }
      // Set widths for this column
      y = insets.top;
      for (int row = 0; row < nrows; row++) {
        if (row * ncols + col < nComps) {
          JComponent c = (JComponent) parent.getComponent(row * ncols + col);
          int h = c.getHeight();
          c.setBounds(x, y, w, h);
          y += h + vgap;
          if (row == 0 && getFillColumn(c)) {
            fills[col] = true;
          }
        }
      }
      x += w + hgap;
      if (fills[col]) {
        nFills++;
        lastFillCol = col;
      }
    }

    // Fill widths
    if (nFills > 0 && x < parent.getWidth()) {
      // How much width to add
      int wAdd = (parent.getWidth() - x) / nFills;
      int wAdded = 0;
      for (int col = 0; col < ncols; col++) {
        if (fills[col]) {
          if (col == lastFillCol) {
            wAdd = parent.getWidth() - (x + wAdded);
          }
          for (int row = 0; row < nrows; row++) {
            if (row * ncols + col < nComps) {
              Component c = parent.getComponent(row * ncols + col);
              Rectangle b = c.getBounds();
              c.setBounds(b.x + wAdded, b.y, b.width + wAdd, b.height);
            }
          }
          wAdded += wAdd;
        }
      }
    }
  }