/** Set the time spinner's font. */
  protected void setupTimeFont() {
    Font font;
    if (spinner == null) return;

    // If not null, use what the user gave us

    if (timeFont != null) {
      spinner.setFont(timeFont);
    } else {
      font = UIManager.getFont("Spinner.font");
      spinner.setFont(font);
    }
  }
	/**
	 * Returns the maximum frequency spinner.
	 * If the spinner doesn't exist it is created:
	 * <ul>
	 * <li>with the specified {@link #getMaxFrequencyModel() model},</li>
	 * <li>to have specified size (80x25 pixel),</li>
	 * <li>with the listener which updates the value of the {@link
	 * #getMinFrequencySpinner() minimum frequency spinner} to be at least
	 * {@code 0.01} smaller then the value of this spinner.</li></ul>
	 * @return the maximum frequency spinner
	 */
	public JSpinner getMaxFrequencySpinner() {
		if (maxFrequencySpinner == null) {
			maxFrequencySpinner = new JSpinner(getMaxFrequencyModel());

			Dimension spinnerSize = new Dimension(80,25);
			maxFrequencySpinner.setPreferredSize(spinnerSize);
			maxFrequencySpinner.setMinimumSize(spinnerSize);
			maxFrequencySpinner.setMaximumSize(spinnerSize);

			maxFrequencySpinner.addChangeListener(new ChangeListener() {

				@Override
				public void stateChanged(ChangeEvent e) {

					double value = ((Number) maxFrequencySpinner.getValue()).doubleValue();

					double otherValue = ((Number) getMinFrequencySpinner().getValue()).doubleValue();

					if ((value-0.01) < otherValue) {
						getMinFrequencySpinner().setValue(value - 0.01);
					}

				}

			});

			maxFrequencySpinner.setEditor(new JSpinner.NumberEditor(maxFrequencySpinner, "0.00"));
			maxFrequencySpinner.setFont(maxFrequencySpinner.getFont().deriveFont(Font.PLAIN));

		}
		return maxFrequencySpinner;
	}
Esempio n. 3
0
 @Override
 public void setFont(final Font font) {
   super.setFont(font);
   if (cboDisplayType == null) {
     return;
   }
   cboDisplayType.setFont(font);
   cmdSave.setFont(font);
   cmdUnzoom.setFont(font);
   cmdResetView.setFont(font);
   cmdMaximize.setFont(font);
   spnBins.setFont(font);
   lblBins.setFont(font);
 }
  private void initComponents() {
    jLabel1 = new javax.swing.JLabel();
    spinDays = new javax.swing.JSpinner();
    spinMonth = new javax.swing.JSpinner();
    spinYear = new javax.swing.JSpinner();
    jLabel2 = new javax.swing.JLabel();
    txtWeek = new javax.swing.JTextField(2);
    jLabel3 = new javax.swing.JLabel();
    txtDays = new javax.swing.JTextField(1);
    jLabel4 = new javax.swing.JLabel();
    btnLMP = new javax.swing.JButton();
    btnUSG = new javax.swing.JButton();
    btnClear = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    txtResult = new javax.swing.JTextArea();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenu3 = new javax.swing.JMenuItem();

    jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    jLabel1.setText("Date");

    spinDays.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
    spinDays.setName("spDay"); // NOI18N
    spinDays.setNextFocusableComponent(spinMonth);
    spinDays.addChangeListener(
        new javax.swing.event.ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent evt) {
            jSpinner2StateChanged(evt);
          }
        });

    spinMonth.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
    spinMonth.setName("spMonth"); // NOI18N
    spinMonth.setNextFocusableComponent(spinYear);
    spinMonth.addChangeListener(
        new javax.swing.event.ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent evt) {
            jSpinner3StateChanged(evt);
          }
        });

    spinYear.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
    spinYear.setName("spYear"); // NOI18N
    spinYear.addChangeListener(
        new javax.swing.event.ChangeListener() {
          public void stateChanged(javax.swing.event.ChangeEvent evt) {
            jSpinner4StateChanged(evt);
          }
        });

    jLabel2.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    jLabel2.setText("Gestacional age");

    txtWeek.setColumns(2);
    txtWeek.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
    txtWeek.setText("00");

    jLabel3.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    jLabel3.setText("weeks");

    txtDays.setColumns(1);
    txtDays.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
    txtDays.setText("0");

    jLabel4.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    jLabel4.setText("days");

    btnLMP.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    btnLMP.setText("L.M.P.");
    btnLMP.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Calendar lpm = Calendar.getInstance();
            Calendar today = Calendar.getInstance();
            lpm.set(dtYear, dtMonth, dtDay);
            txtResult.setText("");
            if (lpm.getTime().after(today.getTime())) {
              txtResult.insert("Invalid L.P.M.", 0);
            } else {
              // defines gestacional ages
              gest.setDum(lpm.getTime());
              // show calcs
              ShowCalcs("L.P.M.");
            }
            ;
          }
        });

    btnUSG.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    btnUSG.setText("Exam");
    btnUSG.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Calendar dtExam = Calendar.getInstance();
            Calendar today = Calendar.getInstance();
            dtExam.set(dtYear, dtMonth, dtDay);
            txtResult.setText("");
            if (dtExam.getTime().after(today.getTime())) {
              txtResult.insert("Invalid Date", 0);
            } else {
              // defines gestacional ages
              try {
                if (txtWeek.getText().equals("")) {
                  txtWeek.setText("0");
                }
                if (txtDays.getText().equals("")) {
                  txtDays.setText("0");
                }
                int wk = Integer.parseInt(txtWeek.getText()),
                    dy = Integer.parseInt(txtDays.getText());
                gest.setDum(dtExam.getTime(), wk, dy);
                // show calcs
                ShowCalcs("US");
              } catch (NumberFormatException nfex) {
                JOptionPane.showMessageDialog(
                    null, nfex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
              } catch (Exception ex) {
                JOptionPane.showMessageDialog(
                    null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
              }
            }
          }
        });

    btnClear.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    btnClear.setText("Clear");
    btnClear.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            txtResult.setText("");
          }
        });

    txtResult.setColumns(20);
    txtResult.setRows(5);
    txtResult.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    jScrollPane1.setViewportView(txtResult);

    jMenuBar1.setName("mainMenuBar"); // NOI18N

    jMenu1.setText("File");

    jMenu3.setMnemonic('x');
    jMenu3.setText("Exit");
    jMenu3.setName("mnitExit"); // NOI18N
    jMenu3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            exit();
          }
        });

    jMenu1.add(jMenu3);

    jMenuBar1.add(jMenu1);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(
                                        spinDays,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        77,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                    .addComponent(
                                        spinMonth,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        77,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(
                                        spinYear,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        117,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGroup(
                                        layout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel1)
                                            .addComponent(
                                                jLabel2,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                194,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(
                                                layout
                                                    .createSequentialGroup()
                                                    .addComponent(
                                                        txtWeek,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        66,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement
                                                            .RELATED)
                                                    .addComponent(jLabel3)
                                                    .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement
                                                            .UNRELATED)
                                                    .addComponent(
                                                        txtDays,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(
                                                        javax.swing.LayoutStyle.ComponentPlacement
                                                            .RELATED)
                                                    .addComponent(jLabel4)))
                                    .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addComponent(
                                        btnLMP,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        81,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                    .addComponent(
                                        btnUSG,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        81,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(
                                        btnClear,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        82,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(
                                        spinDays,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        66,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(
                                        spinMonth,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        66,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(
                                spinYear,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                66,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                txtWeek,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                50,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(
                                txtDays,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                50,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                btnLMP,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                48,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnUSG,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                48,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                btnClear,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                48,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(
                        jScrollPane1,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        225,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(18, Short.MAX_VALUE)));

    pack();
  }
Esempio n. 5
0
  private void generateLeftPanelElements() {
    labelSeason = new JLabel("Season:");
    labelSeason.setFont(new Font("Consolas", Font.BOLD, 14));
    currentSeason = new JLabel("2012");
    currentSeason.setFont(new Font("Consolas", Font.ITALIC, 17));

    localTeam = new JComboBox();
    localTeam.setFont(new Font("Consolas", Font.PLAIN, 12));
    localTeam.setModel(new DefaultComboBoxModel(Teams.getTeamsByYear(CommonGui.DEFAULT_SEASON)));
    localTeam.setBackground(new Color(204, 204, 204));
    awayTeam = new JComboBox();
    awayTeam.setFont(new Font("Consolas", Font.PLAIN, 12));
    awayTeam.setModel(new DefaultComboBoxModel(Teams.getTeamsByYear(CommonGui.DEFAULT_SEASON)));
    awayTeam.setBackground(new Color(204, 204, 204));
    week = new JSpinner();
    week.setModel(new SpinnerNumberModel(1, 1, 50, 1));
    week.setFont(new Font("Consolas", Font.PLAIN, 13));

    GroupLayout gl_leftPanel = new GroupLayout(leftPanel);
    gl_leftPanel.setHorizontalGroup(
        gl_leftPanel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_leftPanel
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        gl_leftPanel
                            .createParallelGroup(Alignment.LEADING)
                            .addGroup(
                                gl_leftPanel
                                    .createSequentialGroup()
                                    .addComponent(
                                        labelSeason,
                                        GroupLayout.PREFERRED_SIZE,
                                        74,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(currentSeason))
                            .addGroup(
                                gl_leftPanel
                                    .createSequentialGroup()
                                    .addComponent(
                                        localTeam,
                                        GroupLayout.PREFERRED_SIZE,
                                        112,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addComponent(
                                        awayTeam,
                                        GroupLayout.PREFERRED_SIZE,
                                        112,
                                        GroupLayout.PREFERRED_SIZE)
                                    .addGap(14)
                                    .addComponent(
                                        week,
                                        GroupLayout.PREFERRED_SIZE,
                                        37,
                                        GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    gl_leftPanel.setVerticalGroup(
        gl_leftPanel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_leftPanel
                    .createSequentialGroup()
                    .addGap(34)
                    .addGroup(
                        gl_leftPanel
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(
                                currentSeason,
                                GroupLayout.PREFERRED_SIZE,
                                28,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                labelSeason,
                                GroupLayout.PREFERRED_SIZE,
                                28,
                                GroupLayout.PREFERRED_SIZE))
                    .addGap(51)
                    .addGroup(
                        gl_leftPanel
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(
                                localTeam,
                                GroupLayout.PREFERRED_SIZE,
                                26,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                awayTeam,
                                GroupLayout.PREFERRED_SIZE,
                                26,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                week, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE))
                    .addGap(11)));
    leftPanel.setLayout(gl_leftPanel);
  }
  private void initGUI() {
    try {
      this.setPreferredSize(new java.awt.Dimension(471, 531));
      this.setBounds(0, 0, 642, 304);
      setVisible(true);
      this.setIconifiable(true);
      this.setClosable(true);
      {
        jDesktopPane1 = new JDesktopPane();
        jDesktopPane1.setBackground(Color.WHITE);
        this.getContentPane().add(jDesktopPane1, BorderLayout.CENTER);
        jDesktopPane1.setPreferredSize(new java.awt.Dimension(462, 497));
        jDesktopPane1.setLayout(null);

        jTextFieldSSCC = new JTextField4j();
        AbstractDocument doc = (AbstractDocument) jTextFieldSSCC.getDocument();
        doc.setDocumentFilter(new JFixedSizeFilter(JDBPallet.field_sscc));
        jTextFieldSSCC.addKeyListener(
            new KeyAdapter() {
              @Override
              public void keyReleased(KeyEvent arg0) {
                refresh();
              }
            });
        jTextFieldSSCC.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                refresh();
              }
            });
        jDesktopPane1.add(jTextFieldSSCC);
        jTextFieldSSCC.setBounds(121, 24, 134, 21);

        jTextFieldNewSSCC = new JTextField4j();
        jDesktopPane1.add(jTextFieldNewSSCC);
        jTextFieldNewSSCC.setEditable(false);
        jTextFieldNewSSCC.setEnabled(false);
        jTextFieldNewSSCC.setBounds(121, 53, 134, 21);

        jFormattedTextFieldQuantity = new JQuantityInput(new BigDecimal("0"));
        jDesktopPane1.add(jFormattedTextFieldQuantity);
        jFormattedTextFieldQuantity.setFont(Common.font_std);
        jFormattedTextFieldQuantity.setHorizontalAlignment(SwingConstants.TRAILING);
        jFormattedTextFieldQuantity.setBounds(464, 24, 91, 21);
        jFormattedTextFieldQuantity.setVerifyInputWhenFocusTarget(false);
        jFormattedTextFieldQuantity.setEnabled(false);

        jFormattedTextFieldNewQuantity = new JQuantityInput(new BigDecimal("0"));
        jDesktopPane1.add(jFormattedTextFieldNewQuantity);
        jFormattedTextFieldNewQuantity.setFont(Common.font_std);
        jFormattedTextFieldNewQuantity.setHorizontalAlignment(SwingConstants.TRAILING);
        jFormattedTextFieldNewQuantity.setBounds(464, 53, 91, 21);
        jFormattedTextFieldNewQuantity.setVerifyInputWhenFocusTarget(false);
        jFormattedTextFieldNewQuantity.setEnabled(false);

        jFormattedTextFieldSplitQuantity = new JQuantityInput(new BigDecimal("0"));
        jDesktopPane1.add(jFormattedTextFieldSplitQuantity);
        jFormattedTextFieldSplitQuantity.setFont(Common.font_std);
        jFormattedTextFieldSplitQuantity.setHorizontalAlignment(SwingConstants.TRAILING);
        jFormattedTextFieldSplitQuantity.setBounds(269, 87, 91, 21);
        jFormattedTextFieldSplitQuantity.setVerifyInputWhenFocusTarget(false);

        labelSSCCQuantity = new JLabel4j_std();
        jDesktopPane1.add(labelSSCCQuantity);
        labelSSCCQuantity.setText(lang.get("lbl_Pallet_Quantity"));
        labelSSCCQuantity.setHorizontalAlignment(SwingConstants.TRAILING);
        labelSSCCQuantity.setBounds(369, 24, 88, 21);

        labelSSCCNewQuantity = new JLabel4j_std();
        jDesktopPane1.add(labelSSCCNewQuantity);
        labelSSCCNewQuantity.setText(lang.get("lbl_Pallet_Quantity"));
        labelSSCCNewQuantity.setHorizontalAlignment(SwingConstants.TRAILING);
        labelSSCCNewQuantity.setBounds(369, 53, 88, 21);

        labelNewSSCCQuantity = new JLabel4j_std();
        jDesktopPane1.add(labelNewSSCCQuantity);
        labelNewSSCCQuantity.setText(lang.get("lbl_Required_Quantity"));
        labelNewSSCCQuantity.setHorizontalAlignment(SwingConstants.TRAILING);
        labelNewSSCCQuantity.setBounds(137, 86, 125, 21);

        jButtonSplit = new JButton4j(Common.icon_split);
        jButtonSplit.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                String splitSSCC =
                    pal.splitPallet(
                        jTextFieldSSCC.getText(),
                        new BigDecimal(jFormattedTextFieldSplitQuantity.getValue().toString()));
                if (splitSSCC.equals("") == false) {
                  lblStatus.setText(
                      "SSCC "
                          + jTextFieldSSCC.getText()
                          + " updated, SSCC "
                          + splitSSCC
                          + " created.");
                  jTextFieldNewSSCC.setText(splitSSCC);
                  jFormattedTextFieldNewQuantity.setValue(
                      jFormattedTextFieldSplitQuantity.getValue());
                  String pq = comboBoxPrintQueue.getSelectedItem().toString();
                  if (checkBoxPrintOldSSCC.isSelected()) {
                    buildSQL1Record(jTextFieldSSCC.getText());
                    JLaunchReport.runReport(
                        "RPT_PALLET_LABEL",
                        listStatement,
                        jCheckBoxAutoPreview.isSelected(),
                        pq,
                        Integer.valueOf(jSpinnerCopies.getValue().toString()),
                        checkBoxIncHeaderText.isSelected());
                  }
                  if (checkBoxPrintNewSSCC.isSelected()) {
                    buildSQL1Record(jTextFieldNewSSCC.getText());
                    JLaunchReport.runReport(
                        "RPT_PALLET_LABEL",
                        listStatement,
                        jCheckBoxAutoPreview.isSelected(),
                        pq,
                        Integer.valueOf(jSpinnerCopies.getValue().toString()),
                        checkBoxIncHeaderText.isSelected());
                  }
                } else {
                  JUtility.errorBeep();
                  JOptionPane.showMessageDialog(
                      Common.mainForm,
                      pal.getErrorMessage(),
                      lang.get("dlg_Error"),
                      JOptionPane.WARNING_MESSAGE);
                }
              }
            });

        jDesktopPane1.add(jButtonSplit);
        jButtonSplit.setText(lang.get("btn_Split"));
        jButtonSplit.setMnemonic(lang.getMnemonicChar());
        jButtonSplit.setBounds(151, 205, 111, 28);

        jButtonHelp = new JButton4j(Common.icon_help);
        jDesktopPane1.add(jButtonHelp);
        jButtonHelp.setText(lang.get("btn_Help"));
        jButtonHelp.setMnemonic(lang.getMnemonicChar());
        jButtonHelp.setBounds(265, 205, 111, 28);

        jButtonCancel = new JButton4j(Common.icon_close);
        jDesktopPane1.add(jButtonCancel);
        jButtonCancel.setText(lang.get("btn_Close"));
        jButtonCancel.setMnemonic(lang.getMnemonicChar());
        jButtonCancel.setBounds(378, 205, 111, 28);
        jButtonCancel.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
                dispose();
              }
            });

        labelSSCC = new JLabel4j_std();
        jDesktopPane1.add(labelSSCC);
        labelSSCC.setText(lang.get("lbl_Source_SSCC"));
        labelSSCC.setBounds(6, 24, 103, 21);
        labelSSCC.setHorizontalAlignment(SwingConstants.TRAILING);

        labelNewSSCC = new JLabel4j_std();
        jDesktopPane1.add(labelNewSSCC);
        labelNewSSCC.setText(lang.get("lbl_Destination_SSCC"));
        labelNewSSCC.setBounds(18, 53, 91, 21);
        labelNewSSCC.setHorizontalAlignment(SwingConstants.TRAILING);

        JLabel4j_std labelHeader = new JLabel4j_std();
        labelHeader.setHorizontalAlignment(SwingConstants.TRAILING);
        labelHeader.setText(lang.get("lbl_Label_Header_Text"));
        labelHeader.setBounds(18, 112, 91, 21);
        jDesktopPane1.add(labelHeader);

        checkBoxIncHeaderText.setText("New JCheckBox");
        checkBoxIncHeaderText.setSelected(true);
        checkBoxIncHeaderText.setBackground(Color.WHITE);
        checkBoxIncHeaderText.setBounds(121, 112, 21, 21);
        jDesktopPane1.add(checkBoxIncHeaderText);

        JLabel4j_std labelQuantity = new JLabel4j_std();
        labelQuantity.setBounds(248, 112, 182, 21);
        labelQuantity.setHorizontalAlignment(SwingConstants.RIGHT);
        labelQuantity.setText(lang.get("lbl_Number_of_SSCCs"));
        jDesktopPane1.add(labelQuantity);

        JLabel4j_std labelCopies = new JLabel4j_std();
        labelCopies.setHorizontalAlignment(SwingConstants.RIGHT);
        labelCopies.setBounds(248, 141, 182, 21);
        labelCopies.setText(lang.get("lbl_Labels_Per_SSCC"));
        jDesktopPane1.add(labelCopies);

        jSpinnerQuantity.setEnabled(false);
        jSpinnerQuantity.setModel(
            new SpinnerNumberModel(new Integer(1), null, null, new Integer(1)));
        jSpinnerQuantity.setFont(Common.font_std);
        jSpinnerQuantity.setBounds(437, 112, 39, 21);
        JSpinner.NumberEditor ne = new JSpinner.NumberEditor(jSpinnerQuantity);
        ne.getTextField().setFont(Common.font_std);
        jSpinnerQuantity.setEditor(ne);
        jDesktopPane1.add(jSpinnerQuantity);

        jSpinnerCopies.setFont(Common.font_std);
        jSpinnerCopies.setBounds(437, 141, 39, 21);
        jSpinnerCopies.setInputVerifier(null);
        jSpinnerCopies.setModel(copiesnumbermodel);
        JSpinner.NumberEditor nec2 = new JSpinner.NumberEditor(jSpinnerCopies);
        nec2.getTextField().setFont(Common.font_std);
        jSpinnerCopies.setEditor(nec2);
        jDesktopPane1.add(jSpinnerCopies);

        JLabel4j_std label_3 = new JLabel4j_std(lang.get("lbl_Print_Queue"));
        label_3.setHorizontalAlignment(SwingConstants.TRAILING);
        label_3.setBounds(18, 174, 91, 21);
        jDesktopPane1.add(label_3);

        comboBoxPrintQueue.setSelectedIndex(-1);
        comboBoxPrintQueue.setBounds(121, 170, 471, 23);
        jDesktopPane1.add(comboBoxPrintQueue);

        jCheckBoxAutoPreview = new JCheckBox();
        jCheckBoxAutoPreview.setToolTipText("Auto SSCC");
        jCheckBoxAutoPreview.setText("New JCheckBox");
        jCheckBoxAutoPreview.setSelected(true);
        jCheckBoxAutoPreview.setEnabled(false);
        jCheckBoxAutoPreview.setBackground(Color.WHITE);
        jCheckBoxAutoPreview.setBounds(121, 141, 21, 21);
        jCheckBoxAutoPreview.setEnabled(
            Common.userList.getUser(Common.sessionID).isModuleAllowed("FRM_PRODDEC_PREVIEW"));
        jDesktopPane1.add(jCheckBoxAutoPreview);

        labelPreview = new JLabel4j_std();
        labelPreview.setBounds(18, 141, 91, 21);
        labelPreview.setHorizontalTextPosition(SwingConstants.CENTER);
        labelPreview.setHorizontalAlignment(SwingConstants.TRAILING);
        labelPreview.setText(lang.get("lbl_Preview"));
        jDesktopPane1.add(labelPreview);

        lblStatus.setForeground(Color.RED);
        lblStatus.setBackground(Color.GRAY);
        lblStatus.setBounds(2, 235, 610, 21);
        jDesktopPane1.add(lblStatus);

        JPanel panel = new JPanel();
        panel.setBackground(Color.WHITE);
        panel.setBorder(
            new TitledBorder(
                null, lang.get("btn_Print"), TitledBorder.CENTER, TitledBorder.TOP, null, null));
        panel.setBounds(270, 6, 90, 75);
        jDesktopPane1.add(panel);
        panel.setLayout(null);

        checkBoxPrintOldSSCC.setSelected(true);
        checkBoxPrintOldSSCC.setBounds(32, 17, 28, 23);
        panel.add(checkBoxPrintOldSSCC);

        checkBoxPrintNewSSCC.setSelected(true);
        checkBoxPrintNewSSCC.setBounds(32, 46, 28, 23);
        panel.add(checkBoxPrintNewSSCC);

        mod.setModuleId("RPT_PALLET_LABEL");
        mod.getModuleProperties();

        if (mod.getReportType().equals("Label")) {
          jCheckBoxAutoPreview.setSelected(false);
          jCheckBoxAutoPreview.setEnabled(false);

        } else {
          jSpinnerCopies.setVisible(false);
          labelCopies.setVisible(false);
        }
        populatePrinterList(JPrint.getDefaultPrinterQueueName());
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 7
0
  /** Create the panel. */
  public ProductDisplay(Product p, boolean featured, boolean list, ActionListener al) {
    addMouseListener(new ThisMouseListener());
    setBackground(Color.WHITE);
    listener = al;
    product = p;
    setBorder(new LineBorder(Color.LIGHT_GRAY));
    setLayout(new BorderLayout(0, 0));
    this.list = list;

    panel = new JPanel();
    panel.setBackground(Color.WHITE);
    add(panel, BorderLayout.CENTER);
    GroupLayout gl_panel = new GroupLayout(panel);

    if (list) {
      setPreferredSize(new Dimension(900, 52));
      titleLabel = new JLabel("Label");
      titleLabel.setFont(new Font("SansSerif", Font.BOLD, 12));

      buyButton =
          new JButton(
              new ImageIcon(ProductStripe.class.getResource("/imat/resources/buyButtonMini.PNG")));
      buyButton.setPreferredSize(new Dimension(40, 20));
      buyButton.setOpaque(false);
      buyButton.setFont(new Font("SansSerif", Font.BOLD, 12));

      priceLabel = new JLabel("Desc");
      priceLabel.setFont(new Font("SansSerif", Font.PLAIN, 10));

      sumLabel = new JLabel("0,00 kr");
      sumLabel.setFont(new Font("SansSerif", Font.BOLD, 10));
      sumLabel.setHorizontalAlignment(SwingConstants.RIGHT);

      qSpinner = new JSpinner();
      qSpinner.addChangeListener(new QSpinnerChangeListener());
      qSpinner.setFont(new Font("SansSerif", Font.BOLD, 10));

      suffixLabel = new JLabel("st");
      suffixLabel.setFont(new Font("SansSerif", Font.PLAIN, 10));

      favButton = new JButton("");
      favButton.setPreferredSize(new Dimension(20, 20));
      favButton.setMinimumSize(new Dimension(20, 20));
      favButton.addActionListener(this);
      favButton.setActionCommand("fav");
      favButton.setFont(new Font("Dialog", Font.BOLD, 10));
      if (IDH.isFavorite(product)) {
        favButton.setIcon(
            new ImageIcon(ProductDisplay.class.getResource("/imat/resources/favmini.PNG")));
        favButton.setToolTipText("Ta bort favorit");
      } else {
        favButton.setIcon(
            new ImageIcon(ProductDisplay.class.getResource("/imat/resources/unfavmini.PNG")));
        favButton.setToolTipText("Lägg till som favorit");
      }
      gl_panel = new GroupLayout(panel);
      gl_panel.setHorizontalGroup(
          gl_panel
              .createParallelGroup(Alignment.LEADING)
              .addGroup(
                  gl_panel
                      .createSequentialGroup()
                      .addContainerGap()
                      .addGroup(
                          gl_panel
                              .createParallelGroup(Alignment.LEADING)
                              .addComponent(priceLabel)
                              .addComponent(titleLabel))
                      .addPreferredGap(ComponentPlacement.RELATED)
                      .addGroup(
                          gl_panel
                              .createParallelGroup(Alignment.TRAILING)
                              .addGroup(
                                  gl_panel
                                      .createSequentialGroup()
                                      .addComponent(
                                          favButton,
                                          GroupLayout.PREFERRED_SIZE,
                                          GroupLayout.DEFAULT_SIZE,
                                          GroupLayout.PREFERRED_SIZE)
                                      .addPreferredGap(ComponentPlacement.RELATED)
                                      .addComponent(
                                          qSpinner,
                                          GroupLayout.PREFERRED_SIZE,
                                          48,
                                          GroupLayout.PREFERRED_SIZE)
                                      .addGap(3)
                                      .addComponent(
                                          suffixLabel,
                                          GroupLayout.PREFERRED_SIZE,
                                          26,
                                          GroupLayout.PREFERRED_SIZE)
                                      .addGap(2)
                                      .addComponent(
                                          buyButton,
                                          GroupLayout.PREFERRED_SIZE,
                                          GroupLayout.DEFAULT_SIZE,
                                          GroupLayout.PREFERRED_SIZE))
                              .addComponent(
                                  sumLabel, GroupLayout.DEFAULT_SIZE, 776, Short.MAX_VALUE))
                      .addContainerGap()));
      gl_panel.setVerticalGroup(
          gl_panel
              .createParallelGroup(Alignment.LEADING)
              .addGroup(
                  gl_panel
                      .createSequentialGroup()
                      .addContainerGap()
                      .addGroup(
                          gl_panel
                              .createParallelGroup(Alignment.TRAILING)
                              .addComponent(
                                  buyButton,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE)
                              .addGroup(
                                  gl_panel
                                      .createParallelGroup(Alignment.LEADING, false)
                                      .addComponent(favButton, 0, 0, Short.MAX_VALUE)
                                      .addGroup(
                                          Alignment.TRAILING,
                                          gl_panel
                                              .createParallelGroup(Alignment.BASELINE)
                                              .addComponent(titleLabel)
                                              .addComponent(suffixLabel)
                                              .addComponent(qSpinner))))
                      .addPreferredGap(ComponentPlacement.RELATED)
                      .addGroup(
                          gl_panel
                              .createParallelGroup(Alignment.BASELINE)
                              .addComponent(priceLabel)
                              .addComponent(sumLabel))
                      .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    } else {
      titleLabel = new JLabel("Label");
      titleLabel.setFont(new Font("SansSerif", Font.BOLD, 18));

      qSpinner = new JSpinner();
      qSpinner.setFont(new Font("SansSerif", Font.BOLD, 12));
      qSpinner.addChangeListener(new QSpinnerChangeListener());

      suffixLabel = new JLabel("st");
      suffixLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));

      buyButton =
          new JButton(
              new ImageIcon(
                  ProductDisplay.class.getResource("/imat/resources/buyButton60x30.PNG")));
      buyButton.setMaximumSize(new Dimension(60, 30));
      buyButton.setMinimumSize(new Dimension(60, 30));
      buyButton.setPreferredSize(new Dimension(60, 30));
      buyButton.setOpaque(false);
      buyButton.setFont(new Font("SansSerif", Font.BOLD, 12));

      sumLabel = new JLabel("Sum");
      sumLabel.setHorizontalAlignment(SwingConstants.RIGHT);

      priceLabel = new JLabel("Desc");
      priceLabel.setFont(new Font("SansSerif", Font.PLAIN, 12));

      favButton = new JButton("");
      favButton.setPreferredSize(new Dimension(32, 32));
      favButton.setMinimumSize(new Dimension(32, 32));

      favButton.addActionListener(this);
      favButton.setActionCommand("fav");
      if (IDH.isFavorite(product)) {
        favButton.setIcon(
            new ImageIcon(ProductDisplay.class.getResource("/imat/resources/fav.PNG")));
        favButton.setToolTipText("Ta bort favorit");
      } else {
        favButton.setIcon(
            new ImageIcon(ProductDisplay.class.getResource("/imat/resources/unfav.PNG")));
        favButton.setToolTipText("Lägg till som favorit");
      }
      gl_panel = new GroupLayout(panel);
      gl_panel.setHorizontalGroup(
          gl_panel
              .createParallelGroup(Alignment.LEADING)
              .addGroup(
                  gl_panel
                      .createSequentialGroup()
                      .addContainerGap()
                      .addGroup(
                          gl_panel
                              .createParallelGroup(Alignment.LEADING)
                              .addComponent(titleLabel)
                              .addGroup(
                                  Alignment.TRAILING,
                                  gl_panel
                                      .createSequentialGroup()
                                      .addGroup(
                                          gl_panel
                                              .createParallelGroup(Alignment.LEADING)
                                              .addGroup(
                                                  gl_panel
                                                      .createSequentialGroup()
                                                      .addComponent(
                                                          qSpinner,
                                                          GroupLayout.PREFERRED_SIZE,
                                                          48,
                                                          GroupLayout.PREFERRED_SIZE)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(suffixLabel)
                                                      .addPreferredGap(ComponentPlacement.RELATED)
                                                      .addComponent(
                                                          sumLabel,
                                                          GroupLayout.DEFAULT_SIZE,
                                                          110,
                                                          Short.MAX_VALUE)
                                                      .addPreferredGap(ComponentPlacement.RELATED))
                                              .addGroup(
                                                  gl_panel
                                                      .createSequentialGroup()
                                                      .addComponent(priceLabel)
                                                      .addGap(103)))
                                      .addGroup(
                                          gl_panel
                                              .createParallelGroup(Alignment.TRAILING)
                                              .addComponent(
                                                  buyButton,
                                                  GroupLayout.PREFERRED_SIZE,
                                                  GroupLayout.DEFAULT_SIZE,
                                                  GroupLayout.PREFERRED_SIZE)
                                              .addComponent(
                                                  favButton,
                                                  GroupLayout.PREFERRED_SIZE,
                                                  GroupLayout.DEFAULT_SIZE,
                                                  GroupLayout.PREFERRED_SIZE))))
                      .addContainerGap()));
      gl_panel.setVerticalGroup(
          gl_panel
              .createParallelGroup(Alignment.TRAILING)
              .addGroup(
                  gl_panel
                      .createSequentialGroup()
                      .addGroup(
                          gl_panel
                              .createParallelGroup(Alignment.TRAILING)
                              .addGroup(
                                  gl_panel
                                      .createSequentialGroup()
                                      .addContainerGap()
                                      .addComponent(titleLabel)
                                      .addPreferredGap(ComponentPlacement.RELATED)
                                      .addComponent(priceLabel)
                                      .addPreferredGap(
                                          ComponentPlacement.RELATED, 27, Short.MAX_VALUE))
                              .addGroup(
                                  gl_panel
                                      .createSequentialGroup()
                                      .addContainerGap()
                                      .addComponent(
                                          favButton,
                                          GroupLayout.PREFERRED_SIZE,
                                          GroupLayout.DEFAULT_SIZE,
                                          GroupLayout.PREFERRED_SIZE)
                                      .addPreferredGap(ComponentPlacement.UNRELATED)))
                      .addGroup(
                          gl_panel
                              .createParallelGroup(Alignment.TRAILING)
                              .addGroup(
                                  gl_panel
                                      .createParallelGroup(Alignment.BASELINE)
                                      .addComponent(
                                          qSpinner,
                                          GroupLayout.PREFERRED_SIZE,
                                          GroupLayout.DEFAULT_SIZE,
                                          GroupLayout.PREFERRED_SIZE)
                                      .addComponent(suffixLabel)
                                      .addComponent(sumLabel))
                              .addComponent(
                                  buyButton,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE))
                      .addContainerGap()));
    }

    Component[] tmp = qSpinner.getComponents();
    for (Component c : tmp) {
      c.addMouseListener(new ThisMouseListener());
    }
    favButton.addMouseListener(new ThisMouseListener());
    buyButton.addMouseListener(new ThisMouseListener());

    panel.setLayout(gl_panel);

    panel_1 = new JPanel();
    panel_1.setBackground(Color.WHITE);
    add(panel_1, BorderLayout.WEST);

    imageLabel = new JLabel("");
    imageLabel.setBorder(new LineBorder(new Color(128, 128, 128), 2));
    panel_1.add(imageLabel);

    // Set labels and image according to the product
    titleLabel.setText(product.getName());
    priceLabel.setText(format.format(p.getPrice()) + p.getUnit().substring(2));

    // Add actions for the buy button
    buyButton.setActionCommand("buy");
    buyButton.addActionListener(this);

    // Drag and drop!

    handler = new DragHandler();
    try {
      flavor =
          new DataFlavor(
              DataFlavor.javaSerializedObjectMimeType
                  + ";class=se.chalmers.ait.dat215.project.ShoppingItem");
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }

    setTransferHandler(handler);

    source = new DragSource();
    source.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, this);
    addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            ProductDisplay.this
                .getTransferHandler()
                .exportAsDrag(ProductDisplay.this, e, TransferHandler.COPY);
          }
        });

    if (list) {
      imageLabel.setIcon(IDH.getImageIcon(p, new Dimension(67, 50)));
    } else {
      if (featured) {
        //				this.setPreferredSize(new Dimension(300, 10));
        titleLabel.setFont(new Font("SansSerif", Font.BOLD, 27));
        priceLabel.setFont(new Font("SansSerif", Font.PLAIN, 18));
        imageLabel.setIcon(IDH.getImageIcon(p, new Dimension(200, 150)));
      } else {
        imageLabel.setIcon(IDH.getImageIcon(p, new Dimension(140, 105)));
      }
    }

    if (p.getUnitSuffix().equals("kg")) {
      qSpinner.setModel(kgModel);
      suffixLabel.setText(p.getUnitSuffix());
    } else {
      qSpinner.setModel(stModel);
      suffixLabel.setText("st");
    }
    favButton.setVisible(false);
    favButton.setContentAreaFilled(false);
    favButton.setBorderPainted(false);
    updateSum();
  }