/** @return string containing left and right border, and open/not open */ @Override public String toString() { double left = getLeftValue(false); double right = getRightValue(false); String leftString, rightString; JComponent editor = m_left.getEditor(); if (editor instanceof JSpinner.NumberEditor) { JSpinner.NumberEditor numEdit = (JSpinner.NumberEditor) editor; leftString = numEdit.getFormat().format(left); rightString = numEdit.getFormat().format(right); } else { leftString = Double.toString(left); rightString = Double.toString(right); } String rightBorder = m_borderRight.getSelectedItem().toString(); String leftBorder = m_borderLeft.getSelectedItem().toString(); return getBinValue() + " : " + leftBorder + " " + leftString + " ... " + rightString + " " + rightBorder; }
public IntegerSpinner(int initialValue) { numberModel = new SpinnerNumberModel(initialValue, null, null, 1); spinner = new JSpinner(numberModel); DecimalFormat decimalFormat = new DecimalFormat(); decimalFormat.setGroupingSize(0); JSpinner.NumberEditor numberEditor = new JSpinner.NumberEditor(spinner, decimalFormat.toPattern()); initDigitsOnlyDocument(numberEditor.getTextField()); spinner.setEditor(numberEditor); numberEditor.getTextField().setValue(initialValue); }
private void configureSpinnerFloat(JSpinner spinner) { JSpinner.NumberEditor editor = (JSpinner.NumberEditor) spinner.getEditor(); DecimalFormat format = editor.getFormat(); format.setMinimumFractionDigits(3); format.setMinimumIntegerDigits(1); editor.getTextField().setHorizontalAlignment(SwingConstants.CENTER); Dimension d = spinner.getPreferredSize(); d.width = 60; spinner.setPreferredSize(d); spinner.addChangeListener(this); spinner.setMaximumSize(d); }
public MonetarySpinner(double decal) { super(new MonetarySpinnerModel(decal)); JSpinner.NumberEditor numEditor = new NumberEditor(this, "0.00"); DecimalFormat format = numEditor.getFormat(); Locale loc = new Locale("en"); format.setDecimalFormatSymbols(new DecimalFormatSymbols(loc)); this.setEditor(numEditor); JSpinner.DefaultEditor textEditor = (JSpinner.DefaultEditor) this.getEditor(); JTextField textField = textEditor.getTextField(); textField.addFocusListener( new FocusAdapter() { public void focusGained(final FocusEvent e) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { JTextField tf = (JTextField) e.getSource(); tf.selectAll(); } }); } }); }
@Override public JComponent createControl() { layerCanvasModelChangeChangeHandler = new LayerCanvasModelChangeHandler(); productNodeChangeHandler = createProductNodeListener(); cursorSynchronizer = new CursorSynchronizer(VisatApp.getApp()); final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.ENGLISH); scaleFormat = new DecimalFormat("#####.##", decimalFormatSymbols); scaleFormat.setGroupingUsed(false); scaleFormat.setDecimalSeparatorAlwaysShown(false); zoomInButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomIn24.gif"), false); zoomInButton.setToolTipText("Zoom in."); /*I18N*/ zoomInButton.setName("zoomInButton"); zoomInButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { zoom(getCurrentView().getZoomFactor() * 1.2); } }); zoomOutButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomOut24.gif"), false); zoomOutButton.setName("zoomOutButton"); zoomOutButton.setToolTipText("Zoom out."); /*I18N*/ zoomOutButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { zoom(getCurrentView().getZoomFactor() / 1.2); } }); zoomDefaultButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomPixel24.gif"), false); zoomDefaultButton.setToolTipText("Actual Pixels (image pixel = view pixel)."); /*I18N*/ zoomDefaultButton.setName("zoomDefaultButton"); zoomDefaultButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { zoomToPixelResolution(); } }); zoomAllButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/ZoomAll24.gif"), false); zoomAllButton.setName("zoomAllButton"); zoomAllButton.setToolTipText("Zoom all."); /*I18N*/ zoomAllButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { zoomAll(); } }); syncViewsButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/SyncViews24.png"), true); syncViewsButton.setToolTipText("Synchronise compatible product views."); /*I18N*/ syncViewsButton.setName("syncViewsButton"); syncViewsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { maybeSynchronizeCompatibleProductViews(); } }); syncCursorButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/SyncCursor24.png"), true); syncCursorButton.setToolTipText("Synchronise cursor position."); /*I18N*/ syncCursorButton.setName("syncCursorButton"); syncCursorButton.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { cursorSynchronizer.setEnabled(syncCursorButton.isSelected()); } }); AbstractButton helpButton = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Help24.gif"), false); helpButton.setToolTipText("Help."); /*I18N*/ helpButton.setName("helpButton"); final JPanel eastPane = GridBagUtils.createPanel(); final GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.gridy = 0; eastPane.add(zoomInButton, gbc); gbc.gridy++; eastPane.add(zoomOutButton, gbc); gbc.gridy++; eastPane.add(zoomDefaultButton, gbc); gbc.gridy++; eastPane.add(zoomAllButton, gbc); gbc.gridy++; eastPane.add(syncViewsButton, gbc); gbc.gridy++; eastPane.add(syncCursorButton, gbc); gbc.gridy++; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.VERTICAL; eastPane.add(new JLabel(" "), gbc); // filler gbc.fill = GridBagConstraints.NONE; gbc.weighty = 0.0; gbc.gridy++; eastPane.add(helpButton, gbc); zoomFactorField = new JTextField(); zoomFactorField.setColumns(8); zoomFactorField.setHorizontalAlignment(JTextField.CENTER); zoomFactorField.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { handleZoomFactorFieldUserInput(); } }); zoomFactorField.addFocusListener( new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { handleZoomFactorFieldUserInput(); } }); rotationAngleSpinner = new JSpinner(new SpinnerNumberModel(0.0, -1800.0, 1800.0, 5.0)); final JSpinner.NumberEditor editor = (JSpinner.NumberEditor) rotationAngleSpinner.getEditor(); rotationAngleField = editor.getTextField(); final DecimalFormat rotationFormat; rotationFormat = new DecimalFormat("#####.##", decimalFormatSymbols); rotationFormat.setGroupingUsed(false); rotationFormat.setDecimalSeparatorAlwaysShown(false); rotationAngleField.setFormatterFactory( new JFormattedTextField.AbstractFormatterFactory() { @Override public JFormattedTextField.AbstractFormatter getFormatter(JFormattedTextField tf) { return new NumberFormatter(rotationFormat); } }); rotationAngleField.setColumns(6); rotationAngleField.setEditable(true); rotationAngleField.setHorizontalAlignment(JTextField.CENTER); rotationAngleField.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleRotationAngleFieldUserInput(); } }); rotationAngleField.addFocusListener( new FocusAdapter() { @Override public void focusLost(FocusEvent e) { handleRotationAngleFieldUserInput(); } }); rotationAngleField.addPropertyChangeListener( "value", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { handleRotationAngleFieldUserInput(); } }); zoomSlider = new JSlider(JSlider.HORIZONTAL); zoomSlider.setValue(0); zoomSlider.setMinimum(MIN_SLIDER_VALUE); zoomSlider.setMaximum(MAX_SLIDER_VALUE); zoomSlider.setPaintTicks(false); zoomSlider.setPaintLabels(false); zoomSlider.setSnapToTicks(false); zoomSlider.setPaintTrack(true); zoomSlider.addChangeListener( new ChangeListener() { @Override public void stateChanged(final ChangeEvent e) { if (!inUpdateMode) { zoom(sliderValueToZoomFactor(zoomSlider.getValue())); } } }); final JPanel zoomFactorPane = new JPanel(new BorderLayout()); zoomFactorPane.add(zoomFactorField, BorderLayout.WEST); final JPanel rotationAnglePane = new JPanel(new BorderLayout()); rotationAnglePane.add(rotationAngleSpinner, BorderLayout.EAST); rotationAnglePane.add(new JLabel(" "), BorderLayout.CENTER); final JPanel sliderPane = new JPanel(new BorderLayout(2, 2)); sliderPane.add(zoomFactorPane, BorderLayout.WEST); sliderPane.add(zoomSlider, BorderLayout.CENTER); sliderPane.add(rotationAnglePane, BorderLayout.EAST); canvas = createNavigationCanvas(); canvas.setBackground(new Color(138, 133, 128)); // image background canvas.setForeground(new Color(153, 153, 204)); // slider overlay final JPanel centerPane = new JPanel(new BorderLayout(4, 4)); centerPane.add(BorderLayout.CENTER, canvas); centerPane.add(BorderLayout.SOUTH, sliderPane); final JPanel mainPane = new JPanel(new BorderLayout(8, 8)); mainPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); mainPane.add(centerPane, BorderLayout.CENTER); mainPane.add(eastPane, BorderLayout.EAST); mainPane.setPreferredSize(new Dimension(320, 320)); if (getDescriptor().getHelpId() != null) { HelpSys.enableHelpOnButton(helpButton, getDescriptor().getHelpId()); HelpSys.enableHelpKey(mainPane, getDescriptor().getHelpId()); } setCurrentView(VisatApp.getApp().getSelectedProductSceneView()); updateState(); // Add an internal frame listener to VISAT so that we can update our // navigation window with the information of the currently activated // product scene view. // VisatApp.getApp().addInternalFrameListener(new NavigationIFL()); return mainPane; }
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(); } }