コード例 #1
0
  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;
  }
コード例 #2
0
ファイル: ListPane.java プロジェクト: NotJRM/jrm-code-project
 public Dimension preferredLayoutSize(Container target) {
   Insets insets = target.getInsets();
   Dimension compMax = new Dimension(0, 0);
   int maxheight = target.getBounds().height - (insets.top + insets.bottom + vgap * 2);
   int nmembers = target.getComponentCount();
   int visiblecount = 0;
   for (int i = 0; i < nmembers; i++) {
     Component m = target.getComponent(i);
     if (m.isVisible()) {
       ++visiblecount;
       Dimension d = m.getPreferredSize();
       compMax.width = Math.max(compMax.width, d.width);
       compMax.height = Math.max(compMax.height, d.height);
     }
   }
   if (visiblecount > 0) {
     int nrows = Math.max(1, (maxheight + compMax.height / 4) / compMax.height);
     int ncols = (visiblecount + nrows - 1) / nrows;
     compMax.height = compMax.height * nrows + vgap * (nrows - 1);
     compMax.width = compMax.width * ncols + hgap * (ncols - 1);
   }
   compMax.height += insets.top + insets.bottom + vgap * 2;
   compMax.width += insets.left + insets.right + hgap * 2;
   return compMax;
 }
コード例 #3
0
ファイル: ListPane.java プロジェクト: NotJRM/jrm-code-project
  public void layoutContainer(Container target) {
    Insets insets = target.getInsets();
    Dimension size = target.getSize();
    Dimension compMax = new Dimension(0, 0);
    int maxheight = size.height - (insets.top + insets.bottom + vgap * 2);
    int nmembers = target.getComponentCount();
    int visiblecount = 0;
    for (int i = 0; i < nmembers; i++) {
      Component m = target.getComponent(i);
      if (m.isVisible()) {
        ++visiblecount;
        Dimension d = m.getPreferredSize();
        compMax.width = Math.max(compMax.width, d.width);
        compMax.height = Math.max(compMax.height, d.height);
      }
    }
    if (visiblecount > 0) {
      int nrows = Math.max(1, (maxheight + compMax.height / 4) / compMax.height);
      int ncols = (visiblecount + nrows - 1) / nrows;
      int row = 0, col = 0, currComp = 0;

      for (int i = 0; i < nmembers; i++) {
        Component m = target.getComponent(i);
        if (m.isVisible()) {
          Dimension d = m.getPreferredSize();
          int x = insets.left + hgap + col * (compMax.width + hgap);
          int y = insets.top + vgap + row * (compMax.height + vgap);

          m.setBounds(x, y, d.width, d.height);

          // move index to next component
          ++currComp;
          if (++row >= nrows) {
            row = 0;
            ++col;
          }
        }
      }
    }
    repaint();
  }
コード例 #4
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);
    }
  }
コード例 #5
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());
    }
コード例 #6
0
ファイル: PosFrame.java プロジェクト: simpleman19/POS
  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
  }
コード例 #7
0
ファイル: CriarEleicao.java プロジェクト: OctavioMaia/DSS
  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
  }