Пример #1
0
  public static ZenInstance create(int width, int height, String options) {
    if (!mustBeAnWebApplet) mustBeAnApplication = true;
    synchronized (Zen.class) {
      ZenInstance instance = instanceMap.get();
      if (instance == null) { // no instance set for this thread
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // System.err.println("Creating Instance");
        Zen zen = new Zen();
        zen.bufferSize = new Dimension(width, height);
        zen.bufferOptions = options;
        zen.frame = frame;

        instanceMap.set(zen.master);
        Container pane = zen.frame.getContentPane();
        pane.add(zen);
        pane.setSize(zen.getSize());
        pane.setMinimumSize(zen.getSize());
        // frame.getContentPane().setIgnoreRepaint(true);
        zen.init();
        frame.pack();
        frame.setVisible(true);

        zen.start();
        return zen.master;
      }
      return instance;
    }
  }
Пример #2
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());
    }
Пример #3
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
  }
Пример #4
0
  public void updateSize() {
    this.setMinimumSize(this.prefixRowsPanel.getSize());

    // --- update width of the JTextFieldResizing to the max size per
    // column
    // - begin ---
    if (this.prefixRowsPanel.getComponentCount() >= 3) {
      // -- get max width for each column - begin --
      int maxWidthLeftColumn = 10;
      int maxWidthRightColumn = 150;
      Container textField = null;
      Dimension d = null;

      // walk through rows...
      for (int i = 0; i < this.prefixRowsPanel.getComponentCount(); i += 1) {
        // left text field...
        i += 1; // skip Label
        textField = (Container) this.prefixRowsPanel.getComponent(i);

        final Dimension leftSize =
            (textField instanceof JTextFieldResizing)
                ? ((JTextFieldResizing) textField).calculateSize()
                : textField.getPreferredSize();

        maxWidthLeftColumn = Math.max(maxWidthLeftColumn, leftSize.width);

        // right text field...
        i += 1;
        i += 1; // skip Label
        textField = (Container) this.prefixRowsPanel.getComponent(i);

        final Dimension rightSize =
            (textField instanceof JTextFieldResizing)
                ? ((JTextFieldResizing) textField).calculateSize()
                : textField.getPreferredSize();

        maxWidthRightColumn = Math.max(maxWidthRightColumn, rightSize.width);

        i += 1; // skip delete-label
      }
      // -- get max width for each column - end --

      // -- update elements of each column - begin --
      // walk through rows...
      for (int i = 0; i < this.prefixRowsPanel.getComponentCount(); i += 1) {
        i += 1; // skip Label
        // left text field...
        textField = (Container) this.prefixRowsPanel.getComponent(i);
        d = new Dimension(maxWidthLeftColumn, textField.getPreferredSize().height);
        textField.setPreferredSize(d);
        textField.setSize(d);
        textField.setMaximumSize(d);
        textField.setMinimumSize(d);
        textField.repaint();

        // right text field...
        i += 1;
        i += 1; // skip Label
        textField = (Container) this.prefixRowsPanel.getComponent(i);
        d = new Dimension(maxWidthRightColumn, textField.getPreferredSize().height);
        textField.setPreferredSize(d);
        textField.setSize(d);
        textField.setMaximumSize(d);
        textField.setMinimumSize(d);
        textField.repaint();

        i += 1; // skip delete-label
      }
      // -- update elements of each column - end --
    }
    // --- update width of the JTextFieldResizing to the max size per
    // column
    // - begin ---

    // update height of the GraphBox...
    if (this.getBox() != null) {
      this.getBox().height = this.getPreferredSize().height;
    }

    this.setSize(this.getPreferredSize());
    this.revalidate(); // re-validate the PrefixPanel
  }
Пример #5
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
  }