protected JComponent createBeepPanel() {
    JPanel beepPanel = new JPanel();

    final JFormattedTextField beepFreq = new JFormattedTextField(Base.getLocalFormat());
    final JFormattedTextField beepDur = new JFormattedTextField(Base.getLocalFormat());
    final JButton beepButton = new JButton("Beep Beep!");

    beepFreq.setColumns(5);
    beepDur.setColumns(5);

    final int EFFECT_DO_IMMEDATELY = 0; // /
    beepButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            Base.logger.severe("running sendBeep");
            machine.runCommand(
                new SendBeep(
                    ((Number) beepFreq.getValue()).intValue(),
                    ((Number) beepDur.getValue()).intValue(),
                    EFFECT_DO_IMMEDATELY));
          }
        });

    beepPanel.add(new JLabel("Frequency"), "split");
    beepPanel.add(beepFreq, "growy");
    beepPanel.add(new JLabel("Duration"), "gap unrel");
    beepPanel.add(beepDur, "growx");
    beepPanel.add(beepButton, "gap unrel");
    return beepPanel;
  }
    ThermistorTablePanel(int which, String titleText, int toolIndex /*ToolModel tool*/) {
      super(new MigLayout());
      this.which = which;
      // this.tool = tool;
      this.toolIndex = toolIndex;
      setBorder(BorderFactory.createTitledBorder(titleText));
      betaField.setColumns(FIELD_WIDTH);
      r0Field.setColumns(FIELD_WIDTH);
      t0Field.setColumns(FIELD_WIDTH);

      double beta = target.getBeta(which, toolIndex);
      if (beta == -1) beta = 4066;

      betaField.setValue((int) beta);
      add(new JLabel("Beta"));
      add(betaField, "wrap");

      double r0 = target.getR0(which, toolIndex);
      if (r0 == -1) r0 = 100000;

      r0Field.setValue((int) r0);
      add(new JLabel("Thermistor Resistance"));
      add(r0Field, "wrap");

      double t0 = target.getT0(which, toolIndex);
      if (t0 == -1) t0 = 25;

      t0Field.setValue((int) t0);
      add(new JLabel("Base Temperature"));
      add(t0Field, "wrap");
    }
Ejemplo n.º 3
0
  public FormattedTextFieldDemo() {
    super(new BorderLayout());
    setUpFormats();
    double payment = computePayment(amount, rate, numPeriods);

    // Create the labels.
    amountLabel = new JLabel(amountString);
    rateLabel = new JLabel(rateString);
    numPeriodsLabel = new JLabel(numPeriodsString);
    paymentLabel = new JLabel(paymentString);

    // Create the text fields and set them up.
    amountField = new JFormattedTextField(amountFormat);
    amountField.setValue(new Double(amount));
    amountField.setColumns(10);
    amountField.addPropertyChangeListener("value", this);

    rateField = new JFormattedTextField(percentFormat);
    rateField.setValue(new Double(rate));
    rateField.setColumns(10);
    rateField.addPropertyChangeListener("value", this);

    numPeriodsField = new JFormattedTextField();
    numPeriodsField.setValue(new Integer(numPeriods));
    numPeriodsField.setColumns(10);
    numPeriodsField.addPropertyChangeListener("value", this);

    paymentField = new JFormattedTextField(paymentFormat);
    paymentField.setValue(new Double(payment));
    paymentField.setColumns(10);
    paymentField.setEditable(false);
    paymentField.setForeground(Color.red);

    // Tell accessibility tools about label/textfield pairs.
    amountLabel.setLabelFor(amountField);
    rateLabel.setLabelFor(rateField);
    numPeriodsLabel.setLabelFor(numPeriodsField);
    paymentLabel.setLabelFor(paymentField);

    // Lay out the labels in a panel.
    JPanel labelPane = new JPanel(new GridLayout(0, 1));
    labelPane.add(amountLabel);
    labelPane.add(rateLabel);
    labelPane.add(numPeriodsLabel);
    labelPane.add(paymentLabel);

    // Layout the text fields in a panel.
    JPanel fieldPane = new JPanel(new GridLayout(0, 1));
    fieldPane.add(amountField);
    fieldPane.add(rateField);
    fieldPane.add(numPeriodsField);
    fieldPane.add(paymentField);

    // Put the panels in this panel, labels on left,
    // text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane, BorderLayout.CENTER);
    add(fieldPane, BorderLayout.LINE_END);
  }
Ejemplo n.º 4
0
  public settings() {

    setUpFormats();
    setPreferredSize(new Dimension(100, 80));
    setBackground(Color.DARK_GRAY);
    ;
    setVisible(true);

    Font font = new Font("Verdana", Font.BOLD, 14);
    angleTag.setFont(font);
    depthTag.setFont(font);
    angleTag.setForeground(Color.white);
    depthTag.setForeground(Color.white);

    angleData = new JFormattedTextField(angleFormat);
    angleData.setValue(new Double(angleRange));
    angleData.setColumns(3);

    depthData = new JFormattedTextField(depthFormat);
    depthData.setValue(new Double(depthRange));
    depthData.setColumns(3);

    alter = new JButton("redraw");
    alter.addActionListener(new buttonListener());

    angleTag.setLabelFor(angleData);
    depthTag.setLabelFor(depthData);

    JPanel labelPanel = new JPanel(new GridLayout(0, 1));
    labelPanel.add(angleTag);
    labelPanel.add(depthTag);
    labelPanel.setBackground(Color.DARK_GRAY);

    JPanel dataPanel = new JPanel(new GridLayout(0, 1));
    dataPanel.add(angleData);
    dataPanel.add(depthData);
    dataPanel.setBackground(Color.DARK_GRAY);

    JPanel buttonPanel = new JPanel(new GridLayout(0, 1));
    buttonPanel.add(alter);
    dataPanel.setBackground(Color.DARK_GRAY);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    add(labelPanel, BorderLayout.CENTER);
    add(dataPanel, BorderLayout.LINE_END);
    add(buttonPanel, BorderLayout.EAST);

    printthing();

    setVisible(true);
    // depthTag.setFont(font);
    // depthTag.setForeground(Color.white);
    // add(depthTag);

  }
Ejemplo n.º 5
0
  public ToneMapPanel() {

    final JLabel midpointLabel = new JLabel("Midpoint:");

    toneMappingChoice.add(noTRButton);
    toneMappingChoice.add(wardTRButton);
    toneMappingChoice.add(reinhardTRButton);

    noTRButton.setSelected(true);
    final ActionListener delegatingActionListener =
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent evt) {
            midpointValue.setEnabled(reinhardTRButton.isSelected());
            midpointLabel.setEnabled(reinhardTRButton.isSelected());
            fireActionEvent();
          }
        };
    noTRButton.addActionListener(delegatingActionListener);
    wardTRButton.addActionListener(delegatingActionListener);
    reinhardTRButton.addActionListener(delegatingActionListener);

    midpointValue.setColumns(4);
    midpointValue.setValue(0.18);
    midpointValue.addActionListener(delegatingActionListener);
    midpointValue.setEnabled(reinhardTRButton.isSelected());
    midpointLabel.setEnabled(reinhardTRButton.isSelected());

    maxLumValue.setValue(0.0);
    maxLumValue.setColumns(6);
    maxLumValue.addActionListener(delegatingActionListener);
    // midpointValue.addFocusListener(new FocusAdapter() {
    //
    // @Override
    // public void focusLost(FocusEvent e) {
    // super.focusLost(e);
    // }
    //
    // });

    setLayout(
        new MigLayout(
            "wrap 2, ax center", "[align right, sg 1]r[align left, sg 1]", "[]r[]r[]r[]u[]r[]"));

    add(new JLabel("Mapping:"));
    add(noTRButton);
    add(wardTRButton, "skip 1");
    add(reinhardTRButton, "skip 1");
    add(midpointLabel);
    add(midpointValue);
    add(new JLabel("White Point: "));
    add(maxLumValue);
    add(new JLabel("(0=>auto)"), "skip 1");
  }
Ejemplo n.º 6
0
  public ToolheadIndexer(Frame parent, final Driver d) {
    super(parent, "Set Toolhead Index", true);
    Container c = getContentPane();
    c.setLayout(new MigLayout("fillx,pack pref pref"));
    c.add(new JLabel(instructions), "wrap,wmax 500px");
    c.add(new JLabel("Tool index:"), "split");
    NumberFormat.getNumberInstance();

    final JFormattedTextField toolIndexField =
        new JFormattedTextField(NumberFormat.getIntegerInstance());
    toolIndexField.setColumns(4);
    toolIndexField.setValue(new Integer(0));
    c.add(toolIndexField);
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            setVisible(false);
          }
        });
    JButton indexButton = new JButton("Set Index");
    indexButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            int value = ((Number) toolIndexField.getValue()).intValue();
            Base.logger.info("Setting toolhead index to " + Integer.toString(value));
            ((MultiTool) d).setConnectedToolIndex(value);
            setVisible(false);
          }
        });
    c.add(indexButton);
    c.add(cancelButton);
    pack();
  }
  private JPanel createParallelGenerationGroup() {
    JPanel parallelGen = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridy = 0;
    parallelGen.add(myUseNewGenerator, c);
    final ChangeListener listener =
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            myUseNewGenerator.setEnabled(myStrictMode.isSelected());
            myNumberOfParallelThreads.setEditable(
                myUseNewGenerator.isSelected() && myStrictMode.isSelected());
          }
        };
    myStrictMode.addChangeListener(listener);
    myUseNewGenerator.addChangeListener(listener);
    c.insets.left = 7;
    parallelGen.add(new JLabel("Use"), c);
    c.insets.left = 3;
    myNumberOfParallelThreads.setColumns(2);
    parallelGen.add(myNumberOfParallelThreads, c);
    c.insets.left = 2;
    parallelGen.add(new JLabel("cores"), c);
    c.weightx = 1;
    parallelGen.add(new JPanel(), c);

    parallelGen.setToolTipText(
        String.format(
            "This computer has %d processors", Runtime.getRuntime().availableProcessors()));

    myButtonState.track(myUseNewGenerator);

    return parallelGen;
  }
Ejemplo n.º 8
0
  public void initComponents() {

    setLayout(new GridLayout(18, 0, 15, 5));
    msisdnLable = new JLabel("MSISDN");
    querybtn = new JButton("Query");

    ////// Formatted text //////
    NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.getDefault());
    DecimalFormat decimalFormat = (DecimalFormat) numberFormat;
    decimalFormat.setGroupingUsed(false);
    msisdnTextFeild = new JFormattedTextField(decimalFormat);
    msisdnTextFeild.setColumns(12);
    msisdnTextFeild.setToolTipText("lenght Should be " + "at least 12 like 989209202207");
    ///////////////////////////////

    Border innerBorder = BorderFactory.createTitledBorder("Query Items");
    Border outterBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    setBorder(BorderFactory.createCompoundBorder(innerBorder, outterBorder));

    ///////////////////////////////////////////

    add(msisdnLable);
    add(msisdnTextFeild);
    add(new JLabel(""));
    add(querybtn);
  }
    PIDPanel(int which, String name, int toolIndex) {
      this.which = which;
      this.toolIndex = toolIndex;
      setLayout(new MigLayout());
      setBorder(BorderFactory.createTitledBorder(name));
      pField.setColumns(FIELD_WIDTH);
      iField.setColumns(FIELD_WIDTH);
      dField.setColumns(FIELD_WIDTH);

      add(new JLabel("P parameter"));
      add(pField, "wrap");
      add(new JLabel("I parameter"));
      add(iField, "wrap");
      add(new JLabel("D parameter"));
      add(dField, "wrap");
      OnboardParameters.PIDParameters pp = target.getPIDParameters(which, toolIndex);
      pField.setValue(pp.p);
      iField.setValue(pp.i);
      dField.setValue(pp.d);
    }
    BackoffPanel(int toolIndex /*ToolModel tool*/) {
      this.toolIndex = toolIndex;

      setLayout(new MigLayout());
      setBorder(BorderFactory.createTitledBorder("Reversal parameters"));
      stopMsField.setColumns(FIELD_WIDTH);
      reverseMsField.setColumns(FIELD_WIDTH);
      forwardMsField.setColumns(FIELD_WIDTH);
      triggerMsField.setColumns(FIELD_WIDTH);

      add(new JLabel("Time to pause (ms)"));
      add(stopMsField, "wrap");
      add(new JLabel("Time to reverse (ms)"));
      add(reverseMsField, "wrap");
      add(new JLabel("Time to advance (ms)"));
      add(forwardMsField, "wrap");
      add(new JLabel("Min. extrusion time before reversal (ms)"));
      add(triggerMsField, "wrap");
      OnboardParameters.BackoffParameters bp = target.getBackoffParameters(toolIndex);
      stopMsField.setValue(bp.stopMs);
      reverseMsField.setValue(bp.reverseMs);
      forwardMsField.setValue(bp.forwardMs);
      triggerMsField.setValue(bp.triggerMs);
    }
Ejemplo n.º 11
0
    public DateTimePropertyInputField(
        final Object value, final UpdateStatus status, final Color bgColor) {
      setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
      setBackground(bgColor);

      GregorianCalendar cal = (value == null ? new GregorianCalendar() : (GregorianCalendar) value);
      timezone = cal.getTimeZone();

      day = new SpinnerNumberModel(cal.get(Calendar.DATE), 1, 31, 1);
      addSpinner(new JSpinner(day), status);

      month = new SpinnerListModel(MONTH_STRINGS);
      month.setValue(MONTH_STRINGS[cal.get(Calendar.MONTH)]);
      JSpinner monthSpinner = new JSpinner(month);
      JComponent editor = monthSpinner.getEditor();
      if (editor instanceof JSpinner.DefaultEditor) {
        JFormattedTextField tf = ((JSpinner.DefaultEditor) editor).getTextField();
        tf.setColumns(6);
        tf.setHorizontalAlignment(JTextField.RIGHT);
      }
      addSpinner(monthSpinner, status);

      year = new SpinnerNumberModel(cal.get(Calendar.YEAR), 0, 9999, 1);
      JSpinner yearSpinner = new JSpinner(year);
      yearSpinner.setEditor(new JSpinner.NumberEditor(yearSpinner, "#"));
      yearSpinner.getEditor().setBackground(bgColor);
      addSpinner(yearSpinner, status);

      add(new JLabel("  "));

      hour = new SpinnerNumberModel(cal.get(Calendar.HOUR_OF_DAY), 0, 23, 1);
      JSpinner hourSpinner = new JSpinner(hour);
      addSpinner(hourSpinner, status);

      add(new JLabel(":"));

      min = new SpinnerNumberModel(cal.get(Calendar.MINUTE), 0, 59, 1);
      JSpinner minSpinner = new JSpinner(min);
      addSpinner(minSpinner, status);

      add(new JLabel(":"));

      sec = new SpinnerNumberModel(cal.get(Calendar.SECOND), 0, 59, 1);
      JSpinner secSpinner = new JSpinner(sec);
      addSpinner(secSpinner, status);

      add(new JLabel(" " + timezone.getDisplayName(true, TimeZone.SHORT)));
    }
    RegulatedCoolingFan(/*ToolModel tool*/ int toolIndex) {
      super(new MigLayout());

      // this.tool = tool;
      this.toolIndex = toolIndex;
      coolingFanEnabled =
          new JCheckBox(
              "Enable regulated cooling fan (stepper extruders only)",
              target.getCoolingFanEnabled(toolIndex));
      add(coolingFanEnabled, "growx,wrap");

      coolingFanSetpoint.setColumns(FIELD_WIDTH);

      coolingFanSetpoint.setValue((int) target.getCoolingFanSetpoint(toolIndex));
      add(new JLabel("Setpoint (C)"));
      add(coolingFanSetpoint, "wrap");
    }
 private JPanel createLinkErrorsGroup() {
   JPanel group = new JPanel(new GridBagLayout());
   GridBagConstraints c = new GridBagConstraints();
   c.gridy = 0;
   group.add(myLimitNumberOfModels, c);
   final ChangeListener listener =
       new ChangeListener() {
         @Override
         public void stateChanged(ChangeEvent e) {
           myNumberOfModelsToKeep.setEditable(myLimitNumberOfModels.isSelected());
         }
       };
   myLimitNumberOfModels.addChangeListener(listener);
   group.add(myLimitNumberOfModels, c);
   myNumberOfModelsToKeep.setColumns(3);
   c.insets.left = 5;
   group.add(myNumberOfModelsToKeep, c);
   c.weightx = 1;
   group.add(new JPanel(), c);
   myButtonState.track(myLimitNumberOfModels);
   return group;
 }
Ejemplo n.º 14
0
  private void createZoomTextField() {
    mZoomTextField = new JFormattedTextField(new DecimalFormat("##0.00%"));
    mZoomTextField.setFocusLostBehavior(JFormattedTextField.REVERT);
    mZoomTextField.setHorizontalAlignment(SwingConstants.CENTER);
    mZoomTextField.setColumns(6);
    mZoomTextField.setMinimumSize(mZoomTextField.getPreferredSize());

    mZoomTextField.addActionListener(
        (x) -> mImagePresentationModel.setZoom(((Number) mZoomTextField.getValue()).doubleValue()));

    mImagePresentationModel.addListener(
        new ImagePresentationModel.Listener() {
          @Override
          public void onVisibleImageContentUpdate() {
            mZoomTextField.setValue(mImagePresentationModel.getZoom());
          }

          @Override
          public void onImageChange() {
            onVisibleImageContentUpdate();
          }
        });
  }
Ejemplo n.º 15
0
  /** constructor */
  public JSpinnerExampleAUT() {
    super("JSpinner Example AUT");

    final int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    SpinnerNumberModel yearModel = new SpinnerNumberModel(currentYear, 0, 3000, 1);
    JSpinner spinnerYear = new JSpinner(yearModel);
    spinnerYear.setEditor(new JSpinner.NumberEditor(spinnerYear, "#"));
    spinnerYear.setName("Year Spinner");

    String[] months =
        new String[] {
          "January",
          "February",
          "March",
          "April",
          "May",
          "June",
          "July",
          "August",
          "September",
          "October",
          "November",
          "December"
        };
    SpinnerListModel monthModel = new SpinnerListModel(months);
    JSpinner spinnerMonth = new JSpinner(monthModel);
    spinnerMonth.setName("Month Spinner");

    Component spinnerEditor = spinnerMonth.getEditor();
    JFormattedTextField jftf = ((JSpinner.DefaultEditor) spinnerEditor).getTextField();
    jftf.setColumns(7);

    super.getContentPane().setLayout(new FlowLayout());
    super.getContentPane().add(spinnerYear);
    super.getContentPane().add(spinnerMonth);
  }
Ejemplo n.º 16
0
  private void editSliderSample(MouseEvent evt, final int sliderIndex) {
    final PropertyContainer vc = new PropertyContainer();
    vc.addProperty(Property.create("sample", getSliderSample(sliderIndex)));
    vc.getDescriptor("sample").setDisplayName("sample");
    vc.getDescriptor("sample").setUnit(getModel().getParameterUnit());
    final ValueRange valueRange;
    if (sliderIndex == 0) {
      valueRange = new ValueRange(Double.NEGATIVE_INFINITY, round(getMaxSliderSample(sliderIndex)));
    } else if (sliderIndex == getSliderCount() - 1) {
      valueRange = new ValueRange(round(getMinSliderSample(sliderIndex)), Double.POSITIVE_INFINITY);
    } else {
      valueRange =
          new ValueRange(
              round(getMinSliderSample(sliderIndex)), round(getMaxSliderSample(sliderIndex)));
    }
    vc.getDescriptor("sample").setValueRange(valueRange);

    final BindingContext ctx = new BindingContext(vc);
    final NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.0#"));
    formatter.setValueClass(Double.class); // to ensure that double values are returned
    final JFormattedTextField field = new JFormattedTextField(formatter);
    field.setColumns(11);
    field.setHorizontalAlignment(JFormattedTextField.RIGHT);
    ctx.bind("sample", field);

    showPopup(evt, field);

    ctx.addPropertyChangeListener(
        "sample",
        pce -> {
          hidePopup();
          setSliderSample(sliderIndex, (Double) ctx.getBinding("sample").getPropertyValue());
          computeZoomInToSliderLimits();
          applyChanges();
        });
  }
Ejemplo n.º 17
0
  /**
   * @param main
   * @param type
   */
  public GraphIso2(Bats main, String type) {
    this.main = main;
    this.data = main.data;
    h1 = Setting.getInt("/bat/general/font/h1");
    p = Setting.getInt("/bat/general/font/p");
    ft = Setting.getString("/bat/general/font/type");
    fTitel = new Font(ft, Font.PLAIN, h1);
    fAxes = new Font(ft, Font.PLAIN, p);
    fText = new Font(ft, Font.PLAIN, p);
    x = Setting.getString("/bat/isotope/graph/" + type + "/x_value");
    y = Setting.getString("/bat/isotope/graph/" + type + "/y_value");
    dataType = Setting.getString("/bat/isotope/graph/" + type + "/data");
    try {
      x_multi =
          Setting.getElement("/bat/isotope/graph/" + type + "/x_value")
              .getAttribute("multi")
              .getIntValue();
      y_multi =
          Setting.getElement("/bat/isotope/graph/" + type + "/y_value")
              .getAttribute("multi")
              .getIntValue();
    } catch (DataConversionException e) {
      x_multi = 1;
      y_multi = 1;
    }

    JLabel textLabel = new JLabel("Isobar correction on radioisotope:", JLabel.LEFT);
    textLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);

    JLabel textLabel2 =
        new JLabel(Setting.getString("/bat/isotope/graph/" + type + "/unit"), JLabel.LEFT);
    textLabel2.setAlignmentX(Component.RIGHT_ALIGNMENT);

    nf.setOverwriteMode(false);
    nf.setMinimum(0.000);
    textField = new JFormattedTextField(nf);
    try {
      textField.setValue(data.corrList.get(0).isoFact);
    } catch (IndexOutOfBoundsException e) {
      log.debug("Could not set isobar factor.");
    }
    textField.setColumns(5); // get some space

    textField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    textField
        .getActionMap()
        .put(
            "check",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                if (!textField.isEditValid()) { // The text is invalid.
                  Toolkit.getDefaultToolkit().beep();
                  textField.selectAll();
                } else
                  try { // The text is valid,
                    textField.commitEdit(); // so use it.
                    fieldChange();
                  } catch (java.text.ParseException exc) {
                  }
              }
            });

    textField2 = new JFormattedTextField(nf);
    textField2.setValue(data.corrList.get(0).isoErr);
    textField2.setColumns(5); // get some space

    textField2.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    textField2
        .getActionMap()
        .put(
            "check",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                if (!textField2.isEditValid()) { // The text is invalid.
                  Toolkit.getDefaultToolkit().beep();
                  textField2.selectAll();
                } else
                  try { // The text is valid,
                    textField2.commitEdit(); // so use it.
                    fieldChange2();
                  } catch (java.text.ParseException exc) {
                  }
              }
            });

    JPanel labelAndText = new JPanel();
    labelAndText.add(textLabel);
    labelAndText.add(textField);
    labelAndText.add(new JLabel("±"));
    labelAndText.add(textField2);
    labelAndText.add(textLabel2);

    JPanel regPane = new JPanel();
    regPane.add(new JLabel("slope: "));
    NumberFormatter nf = new NumberFormatter(new DecimalFormat("0.00E00"));
    slopeField = new JFormattedTextField(nf);
    slopeField.setPreferredSize(new Dimension(80, 20));
    slopeField.setEditable(false);
    regPane.add(slopeField);
    slopeErrField = new JFormattedTextField(nf);
    slopeErrField.setPreferredSize(new Dimension(80, 20));
    slopeErrField.setEditable(false);
    regPane.add(slopeErrField);
    regPane.add(new JLabel("R^2: "));
    nf = new NumberFormatter(new DecimalFormat("0.00E0"));
    rField = new JFormattedTextField(nf);
    rField.setPreferredSize(new Dimension(60, 20));
    rField.setEditable(false);
    regPane.add(rField);
    this.makeReg();

    JPanel regTextPanel = new JPanel(new GridLayout(1, 2));
    regTextPanel.add(labelAndText);
    regTextPanel.add(regPane);

    JPanel controlPanel = new JPanel(new GridLayout(1, 1));
    controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.PAGE_AXIS));
    controlPanel.setBorder(BorderFactory.createEmptyBorder(30, 10, 5, 10));
    controlPanel.add(regTextPanel);

    JDialog frame = new JDialog();
    frame.setModal(true);
    frame.setTitle("Correction");
    frame.setPreferredSize(
        new Dimension(
            Setting.getInt("/bat/general/frame/correction/width"),
            Setting.getInt("/bat/general/frame/correction/height")));
    frame.add(controlPanel, BorderLayout.SOUTH);
    dataSet = Func.getXY(data.get(dataType), null, x, y, x_multi, y_multi);
    chart = createChart(dataSet);
    frame.add(new ChartPanel(chart));
    frame.addWindowListener(this);
    frame.pack();
    frame.setVisible(true);
  }
Ejemplo n.º 18
0
 /**
  * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR
  * call it in your code!
  *
  * @noinspection ALL
  */
 private void $$$setupUI$$$() {
   panelMain = new JPanel();
   panelMain.setLayout(
       new com.intellij.uiDesigner.core.GridLayoutManager(1, 5, new Insets(0, 5, 0, 5), -1, -1));
   checkboxMonitor = new JCheckBox();
   checkboxMonitor.setText("");
   panelMain.add(
       checkboxMonitor,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           0,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_NONE,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
               | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   textfieldName = new JTextField();
   panelMain.add(
       textfieldName,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           1,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   comboboxType = new JComboBox();
   panelMain.add(
       comboboxType,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           2,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK
               | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label1 = new JLabel();
   label1.setText("+/-");
   panelMain.add(
       label1,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           3,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_NONE,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   textfieldTare = new JFormattedTextField();
   textfieldTare.setColumns(4);
   panelMain.add(
       textfieldTare,
       new com.intellij.uiDesigner.core.GridConstraints(
           0,
           4,
           1,
           1,
           com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST,
           com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW,
           com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
 }
Ejemplo n.º 19
0
  public diaAddRirView(Frame arg0, String arg1, boolean arg2) throws ParseException {
    super(arg0, arg1, arg2);
    // TODO Auto-generated constructor stub

    this.setSize(800, 640);
    this.setLocationRelativeTo(arg0);
    getContentPane().setLayout(new BorderLayout(0, 0));

    m_tabbed = new JTabbedPane(JTabbedPane.TOP);
    getContentPane().add(m_tabbed, BorderLayout.CENTER);

    m_panelMetaData = new JPanel();
    m_panelMetaData.setBorder(
        new TitledBorder(
            null,
            "Meta Donn\u00E9es et Import Pdf",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));

    JPanel m_pInfo = new JPanel();

    m_panelRirInfo = new JPanel();
    m_panelRirInfo.setToolTipText("");
    m_tabbed.addTab("Informations (Partie 01)", null, m_panelRirInfo, null);
    m_panelRirInfo.setLayout(new BorderLayout(0, 0));
    m_panelRirInfo02 = new JPanel();
    m_tabbed.addTab("Informations (Partie 02)", null, m_panelRirInfo02, null);
    m_panelRirInfo02.setLayout(null);

    m_pMtp = new JPanel();
    m_pMtp.setLayout(null);
    m_pMtp.setBorder(
        new TitledBorder(
            UIManager.getBorder("TitledBorder.border"),
            "Mtp",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(0, 0, 0)));
    m_pMtp.setBounds(10, 11, 759, 123);
    m_panelRirInfo02.add(m_pMtp);

    m_lMarque = new JLabel("Marque:");
    m_lMarque.setBounds(10, 17, 110, 14);
    m_pMtp.add(m_lMarque);

    m_lImmatriculation = new JLabel("Immatriculation:");
    m_lImmatriculation.setBounds(10, 42, 110, 14);
    m_pMtp.add(m_lImmatriculation);

    m_lCouleur = new JLabel("Couleur:");
    m_lCouleur.setBounds(10, 98, 110, 14);
    m_pMtp.add(m_lCouleur);

    m_tMarque = new JTextField();
    m_tMarque.setColumns(10);
    m_tMarque.setBounds(120, 14, 110, 20);
    m_pMtp.add(m_tMarque);

    m_tImmatriculation = new JTextField();
    m_tImmatriculation.setColumns(10);
    m_tImmatriculation.setBounds(120, 39, 110, 20);
    m_pMtp.add(m_tImmatriculation);

    m_bAddMtp = new JButton("");
    m_bAddMtp.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png")));
    m_bAddMtp.setAlignmentX(0.5f);
    m_bAddMtp.setBounds(250, 31, 65, 50);
    m_pMtp.add(m_bAddMtp);

    m_listMtp = new JList();
    DefaultListModel mmtp = new DefaultListModel();
    m_listMtp.setModel(mmtp);
    scrollPane_4 = new JScrollPane(m_listMtp);
    scrollPane_4.setBounds(379, 28, 370, 50);
    m_pMtp.add(scrollPane_4);

    m_cCouleurs = new comboCouleur();
    m_cCouleurs.setBounds(120, 95, 110, 20);
    m_pMtp.add(m_cCouleurs);

    JLabel m_lType = new JLabel("Type:");
    m_lType.setBounds(10, 73, 80, 14);
    m_pMtp.add(m_lType);

    m_cTypeMtp = new comboTypeMtp();
    m_cTypeMtp.setBounds(120, 67, 110, 20);
    m_pMtp.add(m_cTypeMtp);

    JPanel m_pContact = new JPanel();
    m_pContact.setBorder(
        new TitledBorder(
            null, "Contact", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
    m_pContact.setBounds(10, 145, 759, 85);
    m_panelRirInfo02.add(m_pContact);
    m_pContact.setLayout(null);

    m_tContact = new JTextField();
    m_tContact.setBounds(47, 35, 160, 20);
    m_pContact.add(m_tContact);
    m_tContact.setColumns(10);

    m_bAddContact = new JButton("");
    m_bAddContact.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png")));
    m_bAddContact.setAlignmentX(0.5f);
    m_bAddContact.setBounds(250, 21, 65, 50);
    m_pContact.add(m_bAddContact);

    m_listContact = new JList();
    DefaultListModel mc = new DefaultListModel();
    m_listContact.setModel(mc);
    JScrollPane scrollPane_5 = new JScrollPane(m_listContact);
    scrollPane_5.setBounds(379, 21, 370, 50);
    m_pContact.add(scrollPane_5);

    m_tabbed.addTab("Données à ajouter", null, m_panelMetaData, null);
    m_panelMetaData.setLayout(new BorderLayout(0, 0));

    m_pMeta = new JPanel();
    m_panelMetaData.add(m_pMeta, BorderLayout.CENTER);
    m_pMeta.setLayout(new BorderLayout(0, 0));

    m_editorMeta = new JEditorPane();
    scrollPane_6 = new JScrollPane(m_editorMeta);
    m_pMeta.add(scrollPane_6, BorderLayout.CENTER);

    m_pPdf = new JPanel();
    m_pPdf.setBorder(
        new TitledBorder(null, "Doc Pdf", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    m_panelMetaData.add(m_pPdf, BorderLayout.SOUTH);
    GridBagLayout gbl_m_pPdf = new GridBagLayout();
    gbl_m_pPdf.columnWidths = new int[] {171, 0, 0};
    gbl_m_pPdf.rowHeights = new int[] {23, 0};
    gbl_m_pPdf.columnWeights = new double[] {0.0, 0.0, Double.MIN_VALUE};
    gbl_m_pPdf.rowWeights = new double[] {0.0, Double.MIN_VALUE};
    m_pPdf.setLayout(gbl_m_pPdf);

    m_bLoadPdf = new JButton("Pdf");
    GridBagConstraints gbc_m_bLoadPdf = new GridBagConstraints();
    gbc_m_bLoadPdf.insets = new Insets(0, 0, 0, 5);
    gbc_m_bLoadPdf.fill = GridBagConstraints.BOTH;
    gbc_m_bLoadPdf.gridx = 0;
    gbc_m_bLoadPdf.gridy = 0;
    m_pPdf.add(m_bLoadPdf, gbc_m_bLoadPdf);

    m_lPdf = new JLabel("");
    GridBagConstraints gbc_m_lPdf = new GridBagConstraints();
    gbc_m_lPdf.gridx = 1;
    gbc_m_lPdf.gridy = 0;
    m_pPdf.add(m_lPdf, gbc_m_lPdf);

    m_pInfo.setBackground(Color.GRAY);
    m_pInfo.setBorder(
        new TitledBorder(null, "Information", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    m_panelRirInfo.add(m_pInfo, BorderLayout.NORTH);
    GridBagLayout gbl_m_pInfo = new GridBagLayout();
    gbl_m_pInfo.columnWidths = new int[] {122, 151, 0, 0, 202, 0};
    gbl_m_pInfo.rowHeights = new int[] {0, 0, 0};
    gbl_m_pInfo.columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    gbl_m_pInfo.rowWeights = new double[] {0.0, 0.0, Double.MIN_VALUE};
    m_pInfo.setLayout(gbl_m_pInfo);

    JLabel m_lNumero = new JLabel("Num\u00E9ro:");
    GridBagConstraints gbc_m_lNumero = new GridBagConstraints();
    gbc_m_lNumero.anchor = GridBagConstraints.WEST;
    gbc_m_lNumero.insets = new Insets(0, 0, 5, 5);
    gbc_m_lNumero.gridx = 0;
    gbc_m_lNumero.gridy = 0;
    m_pInfo.add(m_lNumero, gbc_m_lNumero);

    m_tNumero = new JFormattedTextField(new MaskFormatter("  ######/####"));
    m_tNumero.setFont(new Font("Tahoma", Font.BOLD, 12));
    GridBagConstraints gbc_m_tNumero = new GridBagConstraints();
    gbc_m_tNumero.fill = GridBagConstraints.HORIZONTAL;
    gbc_m_tNumero.insets = new Insets(0, 0, 5, 5);
    gbc_m_tNumero.gridx = 1;
    gbc_m_tNumero.gridy = 0;
    m_pInfo.add(m_tNumero, gbc_m_tNumero);
    m_tNumero.setColumns(10);

    JLabel m_lSource = new JLabel("Source:");
    GridBagConstraints gbc_m_lSource = new GridBagConstraints();
    gbc_m_lSource.anchor = GridBagConstraints.WEST;
    gbc_m_lSource.insets = new Insets(0, 0, 5, 5);
    gbc_m_lSource.gridx = 2;
    gbc_m_lSource.gridy = 0;
    m_pInfo.add(m_lSource, gbc_m_lSource);

    m_cSource = new comboSources();
    GridBagConstraints gbc_m_cSource = new GridBagConstraints();
    gbc_m_cSource.insets = new Insets(0, 0, 5, 0);
    gbc_m_cSource.fill = GridBagConstraints.HORIZONTAL;
    gbc_m_cSource.gridx = 4;
    gbc_m_cSource.gridy = 0;
    m_pInfo.add(m_cSource, gbc_m_cSource);

    JLabel m_lDate = new JLabel("Date:");
    GridBagConstraints gbc_m_lDate = new GridBagConstraints();
    gbc_m_lDate.anchor = GridBagConstraints.WEST;
    gbc_m_lDate.insets = new Insets(0, 0, 0, 5);
    gbc_m_lDate.gridx = 0;
    gbc_m_lDate.gridy = 1;
    m_pInfo.add(m_lDate, gbc_m_lDate);

    m_tDateRir = new JFormattedTextField(new MaskFormatter("  ##/##/####"));
    m_tDateRir.setFont(new Font("Tahoma", Font.BOLD, 12));
    GridBagConstraints gbc_m_tDateRir = new GridBagConstraints();
    gbc_m_tDateRir.insets = new Insets(0, 0, 0, 5);
    gbc_m_tDateRir.fill = GridBagConstraints.HORIZONTAL;
    gbc_m_tDateRir.gridx = 1;
    gbc_m_tDateRir.gridy = 1;
    m_pInfo.add(m_tDateRir, gbc_m_tDateRir);
    m_tDateRir.setColumns(10);

    JPanel m_pData = new JPanel();
    m_panelRirInfo.add(m_pData, BorderLayout.CENTER);
    m_pData.setLayout(null);

    JPanel m_pQuartier = new JPanel();
    m_pQuartier.setBorder(
        new TitledBorder(
            UIManager.getBorder("TitledBorder.border"),
            "Quartier",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(0, 0, 0)));
    m_pQuartier.setBounds(10, 11, 759, 72);
    m_pData.add(m_pQuartier);
    m_pQuartier.setLayout(null);

    m_bAddQuartier = new JButton("");
    m_bAddQuartier.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png")));
    m_bAddQuartier.setBounds(250, 11, 65, 50);
    m_bAddQuartier.setAlignmentX(Component.CENTER_ALIGNMENT);
    m_pQuartier.add(m_bAddQuartier);

    m_listQuartier = new JList();
    DefaultListModel ml = new DefaultListModel();
    m_listQuartier.setModel(ml);
    JScrollPane scrollPane = new JScrollPane(m_listQuartier);
    scrollPane.setBounds(379, 11, 370, 50);
    m_pQuartier.add(scrollPane);

    m_comboQuartiers = new comboQuartiers();
    m_comboQuartiers.setBounds(10, 24, 183, 20);
    m_pQuartier.add(m_comboQuartiers);

    m_pDrogue = new JPanel();
    m_pDrogue.setBorder(
        new TitledBorder(null, "Drogue", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    m_pDrogue.setBounds(10, 97, 759, 72);
    m_pData.add(m_pDrogue);
    m_pDrogue.setLayout(null);

    m_comboDrogues = new comboDrogues();
    m_comboDrogues.setBounds(10, 26, 183, 20);
    m_pDrogue.add(m_comboDrogues);

    m_bAddDrogue = new JButton("");
    m_bAddDrogue.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png")));
    m_bAddDrogue.setAlignmentX(0.5f);
    m_bAddDrogue.setBounds(250, 11, 65, 50);
    m_pDrogue.add(m_bAddDrogue);

    m_listDrogue = new JList();
    DefaultListModel dl = new DefaultListModel();
    m_listDrogue.setModel(dl);
    JScrollPane scrollPane_1 = new JScrollPane(m_listDrogue);
    scrollPane_1.setBounds(379, 11, 370, 50);
    m_pDrogue.add(scrollPane_1);

    m_pMethode = new JPanel();
    m_pMethode.setLayout(null);
    m_pMethode.setBorder(
        new TitledBorder(
            UIManager.getBorder("TitledBorder.border"),
            "Methode",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(0, 0, 0)));
    m_pMethode.setBounds(10, 180, 759, 72);
    m_pData.add(m_pMethode);

    m_bAddMethode = new JButton("");
    m_bAddMethode.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png")));
    m_bAddMethode.setSelectedIcon(
        new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png")));
    m_bAddMethode.setAlignmentX(0.5f);
    m_bAddMethode.setBounds(250, 11, 65, 50);
    m_pMethode.add(m_bAddMethode);

    m_listMethode = new JList();
    DefaultListModel dlm = new DefaultListModel();
    m_listMethode.setModel(dlm);
    scrollPane_2 = new JScrollPane(m_listMethode);
    scrollPane_2.setBounds(379, 11, 370, 50);
    m_pMethode.add(scrollPane_2);

    m_comboMethodes = new comboMethodes();
    m_comboMethodes.setBounds(10, 27, 183, 20);
    m_pMethode.add(m_comboMethodes);

    m_pPersonne = new JPanel();
    m_pPersonne.setBorder(
        new TitledBorder(null, "Personne", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    m_pPersonne.setBounds(10, 263, 759, 123);
    m_pData.add(m_pPersonne);
    m_pPersonne.setLayout(null);

    JLabel m_lNom = new JLabel("Nom:");
    m_lNom.setBounds(10, 17, 110, 14);
    m_pPersonne.add(m_lNom);

    JLabel m_lPrenom = new JLabel("Prenom:");
    m_lPrenom.setBounds(10, 42, 110, 14);
    m_pPersonne.add(m_lPrenom);

    JLabel m_lSurnom = new JLabel("Surnom:");
    m_lSurnom.setBounds(10, 67, 110, 14);
    m_pPersonne.add(m_lSurnom);

    JLabel m_lDateNaissance = new JLabel("Date de naissance:");
    m_lDateNaissance.setBounds(10, 92, 110, 14);
    m_pPersonne.add(m_lDateNaissance);

    m_tNom = new JTextField();
    m_tNom.setBounds(130, 17, 110, 20);
    m_pPersonne.add(m_tNom);
    m_tNom.setColumns(10);

    m_tPrenom = new JTextField();
    m_tPrenom.setBounds(130, 42, 110, 20);
    m_pPersonne.add(m_tPrenom);
    m_tPrenom.setColumns(10);

    m_tSurnom = new JTextField();
    m_tSurnom.setBounds(130, 67, 110, 20);
    m_pPersonne.add(m_tSurnom);
    m_tSurnom.setColumns(10);

    m_tDateNaissance = new JFormattedTextField(new MaskFormatter(" ## / ## / ####"));
    m_tDateNaissance.setBounds(130, 95, 110, 20);
    m_pPersonne.add(m_tDateNaissance);
    m_tDateNaissance.setColumns(10);

    m_bAddPersonne = new JButton("");
    m_bAddPersonne.setIcon(new ImageIcon(diaAddRirView.class.getResource("/Textures/add.png")));
    m_bAddPersonne.setAlignmentX(0.5f);
    m_bAddPersonne.setBounds(250, 31, 65, 50);
    m_pPersonne.add(m_bAddPersonne);

    m_listPersonne = new JList();
    DefaultListModel dlp = new DefaultListModel();
    m_listPersonne.setModel(dlp);
    JScrollPane scrollPane_3 = new JScrollPane(m_listPersonne);
    scrollPane_3.setBounds(379, 28, 370, 50);
    m_pPersonne.add(scrollPane_3);

    m_pButton = new JPanel();
    getContentPane().add(m_pButton, BorderLayout.SOUTH);
    m_pButton.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));

    m_bWriteRir = new JButton("Enregistrer");
    m_bWriteRir.setBackground(Color.GREEN);
    m_pButton.add(m_bWriteRir);

    m_bAnnuler = new JButton("Annuler");
    m_bAnnuler.setBackground(Color.CYAN);
    m_pButton.add(m_bAnnuler);

    // model
    try {
      model = new diaAddRirModel();
      controller = new diaAddRirControl();
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  /** Create the panel. */
  public TelaEnderecoEntregaPedido() {
    super();
    setBorder(
        new TitledBorder(
            null, "Endere\u00E7o de Entrega", TitledBorder.LEADING, TitledBorder.TOP, this.fonte));
    panel = this;

    setLayout(new MigLayout("", "[45.00][222.00,grow][63.00][grow]", "[][][][][][grow,bottom]"));

    try {
      mascaraCEP = new MaskFormatter("#####-###");
      mascaraCEP.setPlaceholderCharacter('_');
    } catch (ParseException e2) {
      showMensagemErro();
    }

    lblRua = new JLabel("Rua:");
    add(lblRua, "cell 0 0,alignx trailing");

    textFieldRua = new JTextField();
    add(textFieldRua, "cell 1 0,growx");
    textFieldRua.setColumns(10);

    lblNumero = new JLabel("N\u00FAmero:");
    add(lblNumero, "cell 2 0,alignx trailing");

    textFieldNumero = new JTextField();
    add(textFieldNumero, "cell 3 0,growx");
    textFieldNumero.setColumns(10);

    lblBairro = new JLabel("Bairro:");
    add(lblBairro, "cell 0 1,alignx trailing");

    textFieldBairro = new JTextField();
    add(textFieldBairro, "cell 1 1,growx");
    textFieldBairro.setColumns(10);

    lblCidade = new JLabel("Cidade:");
    add(lblCidade, "cell 0 2,alignx trailing");

    textFieldCidade = new JTextField();
    add(textFieldCidade, "cell 1 2,growx");
    textFieldCidade.setColumns(10);

    lblEstado = new JLabel("Estado:");
    add(lblEstado, "cell 2 2,alignx trailing");

    comboBoxEstado = new JComboBox<String>(this.estados);
    comboBoxEstado.setEnabled(true);
    add(comboBoxEstado, "cell 3 2,growx");

    lblPas = new JLabel("Pa\u00EDs:");
    add(lblPas, "cell 0 3,alignx trailing");

    textFieldPais = new JTextField();
    add(textFieldPais, "cell 1 3,growx");
    textFieldPais.setColumns(10);

    lblComplemento = new JLabel("Complemento:");
    add(lblComplemento, "cell 0 4,alignx trailing");

    textFieldComplemento = new JTextField();
    add(textFieldComplemento, "cell 1 4,growx");
    textFieldComplemento.setColumns(10);

    lblCep = new JLabel("CEP:");
    add(lblCep, "cell 2 4,alignx trailing");

    textFieldCep = new JFormattedTextField(mascaraCEP);
    add(textFieldCep, "cell 3 4,growx");
    textFieldCep.setColumns(10);

    btnOk = new JButton("OK");
    btnOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            String rua = textFieldRua.getText();
            String numero = textFieldNumero.getText();
            String bairro = textFieldBairro.getText();
            String complemento = textFieldComplemento.getText();
            String cidade = textFieldCidade.getText();
            String estado = (String) comboBoxEstado.getSelectedItem();
            String pais = textFieldPais.getText();
            String cep = (String) textFieldCep.getValue();
            try {
              e = new Endereco(rua, bairro, complemento, numero, cep, cidade, estado, pais);
              Container parent = panel.getParent();
              CardLayout cl = (CardLayout) parent.getLayout();
              cl.show(parent, "CadastrarPedido");
            } catch (ParametroException e1) {
              showMensagemErro(e1.getMessage());
            }
          }
        });
    add(btnOk, "cell 0 5 4 1,alignx right");
  }
Ejemplo n.º 21
0
 EditorPane(QueryExecutorCreator queryExecutorCreator) {
   super(new BorderLayout());
   this.queryExecutorCreator = queryExecutorCreator;
   setOpaque(false);
   JPanel northPanel = new JPanel(new BorderLayout());
   northPanel.setOpaque(false);
   JToolBar northWestPanel = new JToolBar();
   northWestPanel.setOpaque(false);
   northWestPanel.setFloatable(false);
   startButton =
       new JButton(
           new ImageIcon(getClass().getResource("/org/jooq/debug/console/resources/Play16.png")));
   startButton.setOpaque(false);
   startButton.setFocusable(false);
   //        startButton.setMargin(new Insets(2, 2, 2, 2));
   startButton.setToolTipText("Run the (selected) text (F5)");
   startButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           evaluateInternal();
         }
       });
   northWestPanel.add(startButton);
   stopButton =
       new JButton(
           new ImageIcon(getClass().getResource("/org/jooq/debug/console/resources/Stop16.png")));
   stopButton.setVisible(false);
   stopButton.setOpaque(false);
   stopButton.setFocusable(false);
   //        stopButton.setMargin(new Insets(2, 2, 2, 2));
   stopButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           closeLastExecution();
         }
       });
   northWestPanel.add(stopButton);
   northPanel.add(northWestPanel, BorderLayout.WEST);
   JPanel northEastPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 2));
   northEastPanel.setOpaque(false);
   JCheckBox limitCheckBox = new JCheckBox("Parse 10000 rows max", isUsingMaxRowCount);
   limitCheckBox.addItemListener(
       new ItemListener() {
         @Override
         public void itemStateChanged(ItemEvent e) {
           isUsingMaxRowCount = e.getStateChange() == ItemEvent.SELECTED;
         }
       });
   limitCheckBox.setOpaque(false);
   northEastPanel.add(limitCheckBox);
   northEastPanel.add(Box.createHorizontalStrut(5));
   northEastPanel.add(new JLabel("No display when rows >"));
   NumberFormat numberFormat = NumberFormat.getIntegerInstance();
   displayedRowCountField = new JFormattedTextField(numberFormat);
   displayedRowCountField.setHorizontalAlignment(JFormattedTextField.RIGHT);
   displayedRowCountField.setValue(100000);
   displayedRowCountField.setColumns(7);
   northEastPanel.add(displayedRowCountField);
   northPanel.add(northEastPanel, BorderLayout.CENTER);
   add(northPanel, BorderLayout.NORTH);
   editorTextArea = new SqlTextArea();
   editorTextArea.addKeyListener(
       new KeyAdapter() {
         @Override
         public void keyPressed(KeyEvent e) {
           boolean isControlDown = e.isControlDown();
           switch (e.getKeyCode()) {
             case KeyEvent.VK_SPACE:
               if (isControlDown) {
                 showCompletion();
               }
               break;
             case KeyEvent.VK_F5:
               if (startButton.isVisible()) {
                 evaluateInternal();
               }
               break;
             case KeyEvent.VK_ESCAPE:
               new Thread("SQLConsole - Interruption") {
                 @Override
                 public void run() {
                   closeLastExecution();
                 }
               }.start();
               break;
           }
         }
       });
   RTextScrollPane editorTextAreaScrollPane = new RTextScrollPane(editorTextArea);
   southPanel = new JPanel(new BorderLayout());
   southPanel.setOpaque(false);
   JSplitPane verticalSplitPane =
       new InvisibleSplitPane(
           JSplitPane.VERTICAL_SPLIT, true, editorTextAreaScrollPane, southPanel);
   verticalSplitPane.setOpaque(false);
   add(verticalSplitPane, BorderLayout.CENTER);
   verticalSplitPane.setDividerLocation(150);
 }
Ejemplo n.º 22
0
  protected void initSizePane() {
    sizepn = new JPanel();

    int size = getParticlePicker().getSize();
    sizepn.add(new JLabel("Size:"));
    sizesl = new JSlider(10, ParticlePicker.sizemax, size);
    sizesl.setPaintTicks(true);
    sizesl.setMajorTickSpacing(100);
    int height = (int) sizesl.getPreferredSize().getHeight();
    sizesl.setPreferredSize(new Dimension(50, height));
    sizepn.add(sizesl);
    sizetf = new JFormattedTextField(NumberFormat.getIntegerInstance());
    sizetf.setColumns(3);
    sizetf.setValue(size);
    sizepn.add(sizetf);
    sizetf.addFocusListener(
        new FocusListener() {

          @Override
          public void focusGained(FocusEvent fe) {}

          @Override
          public void focusLost(FocusEvent fe) {
            // event from sizes
            try {
              if (!fe.isTemporary()) {

                sizetf.commitEdit();
                readSizeFromTextField();
              }
            } catch (Exception ex) {
              XmippDialog.showError(
                  ParticlePickerJFrame.this,
                  XmippMessage.getIllegalValueMsg("size", sizetf.getText()));
              Logger.getLogger(ParticlePickerJFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        });
    sizetf.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // event from sizes
            readSizeFromTextField();
          }
        });

    sizesl.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            if (sizesl.getValueIsAdjusting()) return;
            int size = sizesl.getValue();
            if (size == getParticlePicker().getSize()) return;

            if (!getParticlePicker().isValidSize(ParticlePickerJFrame.this, size)) {
              sizesl.dispatchEvent( // trick to repaint slider after changing value
                  new MouseEvent(sizesl, MouseEvent.MOUSE_RELEASED, 0, 0, 0, 0, 1, false));
              int prevsize = getParticlePicker().getSize();
              sizesl.setValue(prevsize);
              return;
            }
            updateSize(size);
          }
        });
  }
Ejemplo n.º 23
0
  ConversionPanel(
      Converter myController, String myTitle, Unit[] myUnits, ConverterRangeModel myModel) {
    if (MULTICOLORED) {
      setOpaque(true);
      setBackground(new Color(0, 255, 255));
    }
    setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(myTitle),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Save arguments in instance variables.
    controller = myController;
    units = myUnits;
    title = myTitle;
    sliderModel = myModel;

    // Create the text field format, and then the text field.
    numberFormat = NumberFormat.getNumberInstance();
    numberFormat.setMaximumFractionDigits(2);
    NumberFormatter formatter = new NumberFormatter(numberFormat);
    formatter.setAllowsInvalid(false);
    formatter.setCommitsOnValidEdit(true); // seems to be a no-op --
    // aha -- it changes the value property but doesn't cause the result to
    // be parsed (that happens on focus loss/return, I think).
    //
    textField = new JFormattedTextField(formatter);
    textField.setColumns(10);
    textField.setValue(new Double(sliderModel.getDoubleValue()));
    textField.addPropertyChangeListener(this);

    // Add the combo box.
    unitChooser = new JComboBox();
    for (int i = 0; i < units.length; i++) { // Populate it.
      unitChooser.addItem(units[i].description);
    }
    unitChooser.setSelectedIndex(0);
    sliderModel.setMultiplier(units[0].multiplier);
    unitChooser.addActionListener(this);

    // Add the slider.
    slider = new JSlider(sliderModel);
    sliderModel.addChangeListener(this);

    // Make the text field/slider group a fixed size
    // to make stacked ConversionPanels nicely aligned.
    JPanel unitGroup =
        new JPanel() {
          public Dimension getMinimumSize() {
            return getPreferredSize();
          }

          public Dimension getPreferredSize() {
            return new Dimension(150, super.getPreferredSize().height);
          }

          public Dimension getMaximumSize() {
            return getPreferredSize();
          }
        };
    unitGroup.setLayout(new BoxLayout(unitGroup, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
      unitGroup.setOpaque(true);
      unitGroup.setBackground(new Color(0, 0, 255));
    }
    unitGroup.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    unitGroup.add(textField);
    unitGroup.add(slider);

    // Create a subpanel so the combo box isn't too tall
    // and is sufficiently wide.
    JPanel chooserPanel = new JPanel();
    chooserPanel.setLayout(new BoxLayout(chooserPanel, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
      chooserPanel.setOpaque(true);
      chooserPanel.setBackground(new Color(255, 0, 255));
    }
    chooserPanel.add(unitChooser);
    chooserPanel.add(Box.createHorizontalStrut(100));

    // Put everything together.
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    add(unitGroup);
    add(chooserPanel);
    unitGroup.setAlignmentY(TOP_ALIGNMENT);
    chooserPanel.setAlignmentY(TOP_ALIGNMENT);
  }
Ejemplo n.º 24
0
  public CadFornecedor() throws DaoException {
    setResizable(false);
    setIconImage(
        Toolkit.getDefaultToolkit()
            .getImage(CadFornecedor.class.getResource("/br/com/images/logo_sys.png")));
    setTitle("Cadastro de Fornecedores");
    // setIconImage(Toolkit.getDefaultToolkit().getImage(CadFuncionario.class.getResource("/br/com/images/cadForm.jpg")));
    int width = 800;
    int height = 600;
    setModal(true);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - width) / 2;
    int y = (screen.height - height) / 3;
    setBounds(x, y, 821, 600);
    getContentPane().setLayout(null);

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setBackground(UIManager.getColor("Button.background"));
    buttonPanel.setBounds(0, 0, 152, 562);
    getContentPane().add(buttonPanel);
    buttonPanel.setLayout(null);

    JLabel lblPesquisar = new JLabel("Pesquisar");
    lblPesquisar.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 13));
    lblPesquisar.setBounds(40, 66, 75, 14);
    buttonPanel.add(lblPesquisar);

    txtPesq = new JXSearchField();
    txtPesq.addKeyListener(this);
    txtPesq.setFont(new Font("Tahoma", Font.PLAIN, 11));
    txtPesq.setPrompt("Nome do fornecedor");
    txtPesq.setToolTipText("Digite o nome do fornecedor");
    txtPesq.setBounds(0, 84, 152, 20);
    buttonPanel.add(txtPesq);
    txtPesq.setColumns(10);

    formulario.setBounds(152, 0, 632, 562);
    getContentPane().add(formulario);
    formulario.setLayout(null);

    JPanel panel = new JPanel();
    panel.setBorder(
        new TitledBorder(
            new TitledBorder(
                new LineBorder(new Color(0, 0, 0)),
                "",
                TitledBorder.LEADING,
                TitledBorder.TOP,
                null,
                null),
            "Dados pessoais",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(0, 0, 0)));
    panel.setLayout(null);
    panel.setBounds(21, 35, 590, 288);
    formulario.add(panel);

    JLabel lblnome = new JLabel("*Nome:");
    lblnome.setHorizontalAlignment(SwingConstants.RIGHT);
    lblnome.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblnome.setBounds(12, 31, 70, 18);
    panel.add(lblnome);

    JLabel lbltelefone = new JLabel("*Telefone:");
    lbltelefone.setHorizontalAlignment(SwingConstants.RIGHT);
    lbltelefone.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lbltelefone.setBounds(12, 60, 70, 18);
    panel.add(lbltelefone);

    JLabel lblrua = new JLabel("*Rua:");
    lblrua.setHorizontalAlignment(SwingConstants.RIGHT);
    lblrua.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblrua.setBounds(12, 89, 70, 18);
    panel.add(lblrua);

    JLabel lbln = new JLabel("*N\u00BA:");
    lbln.setHorizontalAlignment(SwingConstants.RIGHT);
    lbln.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lbln.setBounds(356, 89, 50, 18);
    panel.add(lbln);

    JLabel lblbairro = new JLabel("*Bairro:");
    lblbairro.setHorizontalAlignment(SwingConstants.RIGHT);
    lblbairro.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblbairro.setBounds(12, 147, 70, 18);
    panel.add(lblbairro);

    JLabel lblcidade = new JLabel("*Cidade:");
    lblcidade.setHorizontalAlignment(SwingConstants.RIGHT);
    lblcidade.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblcidade.setBounds(12, 176, 70, 18);
    panel.add(lblcidade);

    JLabel lblcep = new JLabel("*CEP:");
    lblcep.setHorizontalAlignment(SwingConstants.RIGHT);
    lblcep.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblcep.setBounds(12, 205, 70, 18);
    panel.add(lblcep);

    JButton button = new JButton("");
    button.setToolTipText("Salvar Alt+S");
    button.setMnemonic(KeyEvent.VK_S);
    button.setIcon(new ImageIcon(CadFornecedor.class.getResource("/br/com/images/salvar.png")));
    button.setBounds(491, 242, 63, 35);
    panel.add(button);

    button.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {

            if (validarFormulário()) {
              Fornecedor obj = new Fornecedor();

              obj.setTelFornec(textField_2.getText());
              obj.setRuaFornec(textField_4.getText());
              obj.setNumEndFornec(textField_6.getText());
              obj.setBairroFornec(textField_7.getText());
              obj.setCidadeFornec(textField_8.getText());
              obj.setNomeFornec(textField.getText());
              obj.setCepFornec(textField_3.getText());
              obj.setComplFornec(textField_9.getText());

              FornecedorDao objDAO = new FornecedorDao();
              try {

                if (textField_5.getText().equals("")) {
                  objDAO.inserirFornecedores(obj);
                  JOptionPane.showMessageDialog(formulario, "Dados salvos com sucesso!");
                  limpaFormulario();
                } else {
                  Integer matr = Integer.parseInt(textField_5.getText());
                  obj.setNumFornec(matr);
                  objDAO.atualizarFornecedor(obj);
                  JOptionPane.showMessageDialog(formulario, "Dados atualizados com sucesso!");
                }
                atualizaLista(table, "");
              } catch (DaoException e) {
                e.printStackTrace();
              }
            }
          }
        });

    JButton button_1 = new JButton("");
    button_1.setIcon(new ImageIcon(CadFornecedor.class.getResource("/br/com/images/limpar.png")));
    button_1.setMnemonic(KeyEvent.VK_L);
    button_1.setToolTipText("Limpar Alt+L");
    button_1.setBounds(418, 242, 63, 35);
    panel.add(button_1);
    button_1.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            limpaFormulario();
          }
        });

    textField = new JTextField();
    textField.setBounds(92, 31, 389, 20);
    panel.add(textField);
    textField.setColumns(10);
    try {
      textField_2 = new JFormattedTextField(MascaraUtil.setMaskTelefoneInTf(textField_2));
    } catch (ParseException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    textField_2.setBounds(92, 60, 127, 20);
    panel.add(textField_2);
    textField_2.setColumns(10);
    try {
      textField_3 = new JFormattedTextField(MascaraUtil.setMaskCepInTf(textField_3));
    } catch (ParseException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    textField_3.setBounds(92, 205, 127, 20);
    panel.add(textField_3);
    textField_3.setColumns(10);

    textField_4 = new JTextField();
    textField_4.setBounds(92, 89, 254, 20);
    panel.add(textField_4);
    textField_4.setColumns(10);

    textField_6 = new JTextField();
    textField_6.setBounds(411, 89, 70, 20);
    panel.add(textField_6);
    textField_6.setColumns(10);

    textField_7 = new JTextField();
    textField_7.setBounds(92, 147, 254, 20);
    panel.add(textField_7);
    textField_7.setColumns(10);

    textField_8 = new JTextField();
    textField_8.setBounds(92, 176, 254, 20);
    panel.add(textField_8);
    textField_8.setColumns(10);

    textField_5 = new JTextField();
    textField_5.setVisible(false);
    textField_5.setText("");
    panel.add(textField_5);

    JLabel lblTodosOsCampos = new JLabel("*Campos obrigat\u00F3rios!");
    lblTodosOsCampos.setForeground(new Color(255, 0, 0));
    lblTodosOsCampos.setFont(new Font("Tahoma", Font.PLAIN, 12));
    lblTodosOsCampos.setBounds(122, 257, 206, 14);
    panel.add(lblTodosOsCampos);

    JLabel lblComplemento = new JLabel("Compl.:");
    lblComplemento.setHorizontalAlignment(SwingConstants.RIGHT);
    lblComplemento.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblComplemento.setBounds(12, 118, 70, 18);
    panel.add(lblComplemento);

    textField_9 = new JTextField();
    textField_9.setBounds(91, 116, 255, 20);
    panel.add(textField_9);
    textField_9.setColumns(10);

    JButton btnVoltar = new JButton("");
    btnVoltar.setIcon(new ImageIcon(CadFornecedor.class.getResource("/br/com/images/voltar.png")));
    btnVoltar.setToolTipText("Voltar");
    btnVoltar.setBounds(21, 340, 89, 23);
    formulario.add(btnVoltar);

    lista.setBounds(152, 0, 656, 562);
    getContentPane().add(lista);
    lista.setLayout(null);

    JLabel lblFuncionriosCadastrados = new JLabel("Fornecedores Cadastrados");
    lblFuncionriosCadastrados.setFont(new Font("Kalinga", Font.BOLD, 16));
    lblFuncionriosCadastrados.setHorizontalAlignment(SwingConstants.CENTER);
    lblFuncionriosCadastrados.setBackground(Color.WHITE);
    lblFuncionriosCadastrados.setBounds(10, 11, 612, 29);
    lista.add(lblFuncionriosCadastrados);

    Button Novo = new Button("Adicionar");
    Novo.setBounds(10, 530, 70, 22);
    lista.add(Novo);
    lista.setVisible(true);
    table = new JTable();

    table.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseReleased(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mousePressed(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseExited(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseEntered(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseClicked(MouseEvent arg0) {
            int linha = table.getSelectedRow();
            int coluna = table.getSelectedColumn();
            String matricula = (String) table.getValueAt(linha, 0);
            Integer mat = Integer.parseInt(matricula);
            if (coluna == 4) {
              int opcao;
              opcao =
                  JOptionPane.showConfirmDialog(
                      null,
                      "Deseja excluir o fornecedor de matricula: " + matricula,
                      "Cuidado!!",
                      JOptionPane.YES_NO_OPTION);
              if (opcao == JOptionPane.YES_OPTION) {
                try {
                  fornecDao.excluirFornecedores(mat);
                  atualizaLista(table, "");
                } catch (DaoException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
                JOptionPane.showMessageDialog(null, "Dados excluídos com sucesso!");
              }
            }
            if (coluna == 3) {
              Fornecedor objFornec = new Fornecedor();

              try {
                objFornec = fornecDao.consultarFornecedorID(mat);
                atualizaFormulario(objFornec);
                buttonPanel.setVisible(false);
              } catch (DaoException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
            }
          }
        });

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setModel(
        new DefaultTableModel(
            new Object[][] {}, new String[] {"Número", "Nome", "Telefone", "Editar", "Excluir"}) {

          private static final long serialVersionUID = 1L;

          @Override
          public boolean isCellEditable(int row, int col) {
            return false;
          }
        });
    table.getColumnModel().getColumn(0).setPreferredWidth(55);
    table.getColumnModel().getColumn(0).setMinWidth(55);
    table.getColumnModel().getColumn(1).setPreferredWidth(220);
    table.getColumnModel().getColumn(1).setMinWidth(220);
    table.getColumnModel().getColumn(2).setPreferredWidth(80);
    table.getColumnModel().getColumn(2).setMinWidth(80);
    table.getColumnModel().getColumn(3).setPreferredWidth(70);
    table.getColumnModel().getColumn(3).setMinWidth(70);
    table.getColumnModel().getColumn(4).setPreferredWidth(60);
    table.getColumnModel().getColumn(4).setMinWidth(60);
    table.setBounds(39, 175, 530, 232);

    atualizaLista(table, "");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 51, 636, 473);
    lista.add(scrollPane);

    scrollPane.setViewportView(table);

    Novo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            lista.setVisible(false);
            formulario.setVisible(true);
            buttonPanel.setVisible(false);
            limpaFormulario();
            try {
              atualizaLista(table, "");
            } catch (DaoException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });
    formulario.setVisible(false);

    btnVoltar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            lista.setVisible(true);
            formulario.setVisible(false);
            buttonPanel.setVisible(true);
          }
        });
  }
Ejemplo n.º 25
0
  public MakeReservation() {
    new BorderLayout();

    standardRoom.setMnemonic(KeyEvent.VK_K);
    standardRoom.setActionCommand("Standard Room");
    standardRoom.setSelected(true);

    familyRoom.setMnemonic(KeyEvent.VK_F);
    familyRoom.setActionCommand("Family Room");

    suiteRoom.setMnemonic(KeyEvent.VK_S);
    suiteRoom.setActionCommand("Suite");

    // Add Booking Button
    ImageIcon bookRoomIcon = createImageIcon("images/book.png");
    bookRoom = new JButton("Book Room", bookRoomIcon);
    bookRoom.setVerticalTextPosition(AbstractButton.BOTTOM);
    bookRoom.setHorizontalTextPosition(AbstractButton.CENTER);
    bookRoom.setMnemonic(KeyEvent.VK_M);
    bookRoom.addActionListener(this);
    bookRoom.setActionCommand("book");

    // Group the radio buttons.
    group.add(standardRoom);
    group.add(familyRoom);
    group.add(suiteRoom);

    // Create the labels.
    nameLabel = new JLabel("Name: ");
    amountroomsLabel = new JLabel("How many rooms? ");
    checkoutdateLabel = new JLabel("Check-Out Date: ");
    checkindateLabel = new JLabel("Check-In Date: ");

    // Create the text fields and set them up.
    nameField = new JFormattedTextField();
    nameField.setColumns(10);

    amountroomsField = new JFormattedTextField(new Integer(1));
    amountroomsField.setValue(new Integer(1));
    amountroomsField.setColumns(10);

    // java.util.Date dt_checkin = new java.util.Date();
    LocalDate today = LocalDate.now();
    // java.text.SimpleDateFormat sdf_checkin = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkin = today.toString();
    checkindateField = new JFormattedTextField(currentDate_checkin);
    checkindateField.setColumns(10);

    // java.util.Date dt_checkout = new java.util.Date();
    LocalDate tomorrow = today.plus(1, ChronoUnit.DAYS);
    // java.text.SimpleDateFormat sdf_checkout = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkout = tomorrow.toString();
    checkoutdateField = new JFormattedTextField(currentDate_checkout);
    checkoutdateField.setColumns(10);

    // Tell accessibility tools about label/textfield pairs.
    nameLabel.setLabelFor(nameField);
    amountroomsLabel.setLabelFor(amountroomsField);
    checkoutdateLabel.setLabelFor(checkoutdateField);
    checkindateLabel.setLabelFor(checkindateField);

    // Lay out the labels in a panel.
    JPanel labelPane1 = new JPanel(new GridLayout(0, 1));

    labelPane1.add(amountroomsLabel);

    JPanel labelPane3 = new JPanel(new GridLayout(0, 1));
    labelPane3.add(checkindateLabel);

    JPanel labelPane2 = new JPanel(new GridLayout(0, 1));
    labelPane2.add(checkoutdateLabel);

    JPanel labelPane4 = new JPanel(new GridLayout(0, 1));
    labelPane4.add(nameLabel);

    // Layout the text fields in a panel.
    JPanel fieldPane1 = new JPanel(new GridLayout(0, 1));
    fieldPane1.add(amountroomsField);

    JPanel fieldPane3 = new JPanel(new GridLayout(0, 1));
    fieldPane3.add(checkindateField);

    JPanel fieldPane2 = new JPanel(new GridLayout(0, 1));
    fieldPane2.add(checkoutdateField);

    JPanel fieldPane4 = new JPanel(new GridLayout(0, 1));
    fieldPane4.add(nameField);

    // Put the radio buttons in a column in a panel.
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(standardRoom);
    radioPanel.add(familyRoom);
    radioPanel.add(suiteRoom);

    // Put the panels in this panel, labels on left,
    // text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane1, BorderLayout.LINE_START);
    add(fieldPane1, BorderLayout.LINE_END);
    add(labelPane3, BorderLayout.LINE_START);
    add(fieldPane3, BorderLayout.LINE_END);
    add(labelPane2, BorderLayout.LINE_START);
    add(fieldPane2, BorderLayout.LINE_END);
    add(labelPane4, BorderLayout.LINE_START);
    add(fieldPane4, BorderLayout.LINE_END);

    add(radioPanel, BorderLayout.LINE_END);
    add(bookRoom);
  }
Ejemplo n.º 26
0
  public TelaFolhadePagamento() throws DaoException {
    setResizable(false);
    setIconImage(
        Toolkit.getDefaultToolkit()
            .getImage(TelaFolhadePagamento.class.getResource("/br/com/images/logo_transp.png")));
    setTitle("Folha de Pagamento");
    int width = 800;
    int height = 600;
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - width) / 2;
    int y = (screen.height - height) / 3;
    setBounds(x, y, 821, 600);
    getContentPane().setLayout(null);

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setBackground(UIManager.getColor("Button.background"));
    buttonPanel.setBounds(0, 0, 152, 562);
    getContentPane().add(buttonPanel);
    buttonPanel.setLayout(null);

    txtPesq = new JXSearchField();
    txtPesq.addKeyListener(this);
    txtPesq.setPrompt("Nome funcionário");
    txtPesq.setToolTipText("Digite o nome do funcionário para pesquisar");
    txtPesq.setBounds(10, 76, 132, 20);
    buttonPanel.add(txtPesq);
    txtPesq.setColumns(10);

    JLabel lblPesquisar = new JLabel("Pesquisar");
    lblPesquisar.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 13));
    lblPesquisar.setBounds(40, 58, 79, 14);
    buttonPanel.add(lblPesquisar);

    formulario.setBounds(152, 0, 632, 562);
    getContentPane().add(formulario);
    formulario.setLayout(null);

    JPanel panel = new JPanel();
    panel.setBorder(
        new TitledBorder(
            new TitledBorder(
                new LineBorder(new Color(0, 0, 0)),
                "",
                TitledBorder.LEADING,
                TitledBorder.TOP,
                null,
                null),
            "Pagamento",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(0, 0, 0)));
    panel.setLayout(null);
    panel.setBounds(21, 33, 590, 290);
    formulario.add(panel);

    JPopupMenu popupMenu = new JPopupMenu();
    addPopup(panel, popupMenu);

    JMenuItem mntmPesquisarFuncionrio = new JMenuItem("Pesquisar Funcion\u00E1rio");
    mntmPesquisarFuncionrio.setIcon(
        new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/search.png")));
    mntmPesquisarFuncionrio.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            new ViewSelecionaFuncionario(1);
          }
        });
    popupMenu.add(mntmPesquisarFuncionrio);

    JLabel lblNome = new JLabel("Nome:");
    lblNome.setHorizontalAlignment(SwingConstants.RIGHT);
    lblNome.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblNome.setBounds(0, 89, 70, 18);
    panel.add(lblNome);

    JLabel lblSalrio = new JLabel("Sal\u00E1rio:");
    lblSalrio.setHorizontalAlignment(SwingConstants.RIGHT);
    lblSalrio.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblSalrio.setBounds(0, 171, 70, 18);
    panel.add(lblSalrio);

    JLabel lblProfisso = new JLabel("Profiss\u00E3o:");
    lblProfisso.setHorizontalAlignment(SwingConstants.RIGHT);
    lblProfisso.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblProfisso.setBounds(0, 129, 70, 18);
    panel.add(lblProfisso);

    JLabel lbln = new JLabel("N\u00BA:");
    lbln.setHorizontalAlignment(SwingConstants.RIGHT);
    lbln.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lbln.setBounds(10, 45, 56, 18);
    panel.add(lbln);

    JButton btnSalvar = new JButton("");
    btnSalvar.setIcon(
        new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/salvar.png")));
    btnSalvar.setToolTipText("Salvar Alt+S");
    btnSalvar.setMnemonic(KeyEvent.VK_S);
    btnSalvar.setBounds(504, 244, 56, 33);
    panel.add(btnSalvar);

    btnSalvar.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {

            if (validarFormulário()) {
              FolhaPagamento obj = new FolhaPagamento();

              // obj.setSalarioFunc(Double.parseDouble(MascaraUtil.hideMascaraMoeda(textField_3)));
              obj.setSalarioFunc(Double.parseDouble(textField_3.getText()));
              obj.setComissaoFuncTotal(Double.parseDouble(textField_2.getText()));
              // obj.setBonusFunc(Double.parseDouble(MascaraUtil.hideMascaraMoeda(textField_4)));
              obj.setBonusFunc(Double.parseDouble(textField_4.getText()));
              //	obj.setTotalFunc(Double.parseDouble(MascaraUtil.hideMascaraMoeda(textField_6)));
              obj.setTotalFunc(Double.parseDouble(textField_6.getText()));
              obj.setNomeFunc(textField_9.getText());
              obj.setNumFunc(Integer.parseInt(textField.getText()));
              obj.setProfissaoFunc(textField_1.getText());

              SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");

              try {
                obj.setDataInicio(df.parse(dateInicio.getEditor().getText()));
                obj.setDataFim(df.parse(dateFim.getEditor().getText()));
              } catch (ParseException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }

              FolhadePagamentoDao objDAO = new FolhadePagamentoDao();
              try {

                if (textField_5.getText().equals("")) {
                  objDAO.inserirPagamento(obj);
                  JOptionPane.showMessageDialog(formulario, "Dados salvos com sucesso!");
                  limpaFormulario();
                } else {
                  Integer matr = Integer.parseInt(textField_5.getText());
                  obj.setCodDep(matr);
                  objDAO.atualizarPagamento(obj);
                  JOptionPane.showMessageDialog(formulario, "Dados atualizados com sucesso!");
                }
                atualizaLista(table, "");
              } catch (DaoException e) {
                e.printStackTrace();
              }
            }
          }
        });

    JButton btnLimpar = new JButton("");
    btnLimpar.setIcon(
        new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/limpar.png")));
    btnLimpar.setToolTipText("Limpar Alt+L");
    btnLimpar.setMnemonic(KeyEvent.VK_L);
    btnLimpar.setBounds(438, 244, 56, 33);
    panel.add(btnLimpar);
    btnLimpar.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            limpaFormulario();
          }
        });

    textField = new JTextField();
    textField.setBounds(80, 45, 127, 20);
    panel.add(textField);
    textField.setColumns(10);

    textField_1 = new JTextField();
    textField_1.setBounds(80, 129, 335, 20);
    panel.add(textField_1);
    textField_1.setColumns(10);

    // textField_3 = new JFormattedTextField(MascaraUtil.setMascara("R$####,##"));
    textField_3 = new JFormattedTextField();
    //  textField_3.setDocument(new Moeda());
    textField_3.setBounds(80, 171, 70, 20);
    panel.add(textField_3);
    textField_3.setColumns(10);

    textField_5 = new JTextField();
    textField_5.setVisible(false);
    textField_5.setText("");
    panel.add(textField_5);

    textField_9 = new JTextField();
    textField_9.setBounds(80, 89, 335, 20);
    panel.add(textField_9);
    textField_9.setColumns(10);

    dateInicio = new JXDatePicker();
    dateInicio.getEditor().setToolTipText("Data ínicial para calcular a comissão!");
    dateInicio.getEditor();
    dateInicio.setFormats(new String[] {"dd/MM/yyyy"});
    dateInicio.setBounds(258, 171, 97, 20);
    panel.add(dateInicio);

    dateFim = new JXDatePicker();
    dateFim.getEditor().setToolTipText("Data final para calcular a comissão!");
    dateFim.getEditor();
    dateFim.setFormats(new String[] {"dd/MM/yyyy"});
    dateFim.setBounds(392, 171, 97, 20); //
    panel.add(dateFim);

    JButton btnOk = new JButton("");
    btnOk.setToolTipText("Procurar funcion\u00E1rio");
    btnOk.setIcon(
        new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/pesquisar.png")));
    btnOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // PESQUISAR NO BANCO DE DADOS O NÚMERO DO FUNCIONÁRIO
            String aux1;
            aux1 = textField.getText();
            //	if(aux.contains("^[a-Z]")){ //método para verificar se contém letras
            if (textField.getText().equals("")) {
              JOptionPane.showMessageDialog(null, "Digite um número!");
            } else if (aux1.matches("^[0-9]*$")) {
              chamaFuncionario(Integer.parseInt(textField.getText()));
            } else {
              JOptionPane.showMessageDialog(null, "Digite apenas número!");
            }
          }
        });
    btnOk.setBounds(217, 44, 56, 23);
    panel.add(btnOk);

    JLabel lblComisso = new JLabel("Comiss\u00E3o:");
    lblComisso.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblComisso.setBounds(0, 212, 80, 14);
    panel.add(lblComisso);

    JLabel lblBnus = new JLabel("B\u00F4nus:");
    lblBnus.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblBnus.setBounds(185, 212, 50, 14);
    panel.add(lblBnus);

    JLabel lblTotal = new JLabel("Total:");
    lblTotal.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblTotal.setBounds(24, 257, 46, 14);
    panel.add(lblTotal);

    textField_2 = new JTextField();
    textField_2.setToolTipText("Comiss\u00E3o calculada");
    textField_2.setBounds(80, 210, 70, 20);
    //   textField_2.setDocument(new Moeda());
    panel.add(textField_2);
    textField_2.setColumns(10);

    // textField_4 = new JFormattedTextField(MascaraUtil.setMascara("R$####,##"));
    textField_4 = new JTextField();
    //      textField_4.setDocument(new Moeda());
    textField_4.setBounds(245, 210, 80, 20);
    panel.add(textField_4);
    textField_4.setColumns(10);

    //  textField_6 = new JFormattedTextField(MascaraUtil.setMascara("R$####,##"));
    textField_6 = new JTextField();
    //     textField_6.setDocument(new Moeda());
    textField_6.setBounds(80, 255, 70, 20);
    panel.add(textField_6);
    textField_6.setColumns(10);

    JButton btnCalcular = new JButton("Somar tudo");
    btnCalcular.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Calcular quanto o funcionário irá receber
            //	bonus = 0.0;
            // textField 3(salario) e 4 (bonus) 2 (comissão)
            if (validarFormulárioCalculo()) {

              MonthDay inicio = new MonthDay(dateInicio.getDate());
              MonthDay fim = new MonthDay(dateFim.getDate());
              int mes = Months.monthsBetween(inicio, fim).getMonths();
              if (mes >= 2) {
                salario = Double.parseDouble(textField_3.getText()) * mes;
              } else {

                //		String aux = textField_4.getText().replace(",", ".").trim();
                //	bonus = Double.parseDouble(aux);
                bonus = Double.parseDouble(textField_4.getText());

                salario = Double.parseDouble(textField_3.getText());
                totalCom = Double.parseDouble(textField_2.getText());

                salarioTotal = totalCom + bonus + salario;

                textField_6.setText(String.valueOf(salarioTotal));
                textField_6.setEditable(false);
              }
            }
          }
        });
    btnCalcular.setBounds(343, 209, 89, 23);
    panel.add(btnCalcular);

    JLabel lblIncioDoMs = new JLabel("In\u00EDcio do m\u00EAs:");
    lblIncioDoMs.setFont(new Font("Arial Black", Font.PLAIN, 11));
    lblIncioDoMs.setBounds(160, 174, 95, 14);
    panel.add(lblIncioDoMs);

    JLabel lblAt = new JLabel("at\u00E9");
    lblAt.setFont(new Font("Arial Black", Font.PLAIN, 11));
    lblAt.setBounds(365, 173, 28, 14);
    panel.add(lblAt);

    JButton btnCalcular_Com = new JButton("Calcular");
    btnCalcular_Com.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              calcularComissao();
            } catch (ParseException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            }
          }
        });
    btnCalcular_Com.setToolTipText("Calcular comiss\u00E3o");
    btnCalcular_Com.setBounds(491, 170, 89, 23);
    panel.add(btnCalcular_Com);

    JLabel lblTodosOsCampos = new JLabel("Todos os campos s\u00E3o obrigat\u00F3rios!");
    lblTodosOsCampos.setForeground(Color.RED);
    lblTodosOsCampos.setFont(new Font("Tahoma", Font.PLAIN, 12));
    lblTodosOsCampos.setBounds(201, 263, 192, 14);
    panel.add(lblTodosOsCampos);

    JButton btnVoltar = new JButton("");
    btnVoltar.setIcon(
        new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/voltar.png")));
    btnVoltar.setToolTipText("Voltar");
    btnVoltar.setBounds(21, 340, 89, 23);
    formulario.add(btnVoltar);
    formulario.setVisible(false);

    btnVoltar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            lista.setVisible(true);
            buttonPanel.setVisible(true);
            formulario.setVisible(false);
          }
        });

    lista.setBounds(152, 0, 656, 562);
    getContentPane().add(lista);
    lista.setLayout(null);

    JLabel lblFuncionriosCadastrados = new JLabel("Pagamentos Efetuados");
    lblFuncionriosCadastrados.setFont(new Font("Kalinga", Font.BOLD, 16));
    lblFuncionriosCadastrados.setHorizontalAlignment(SwingConstants.CENTER);
    lblFuncionriosCadastrados.setBackground(Color.WHITE);
    lblFuncionriosCadastrados.setBounds(10, 11, 612, 29);
    lista.add(lblFuncionriosCadastrados);

    Button Novo = new Button("Adicionar");
    Novo.setBounds(10, 530, 70, 22);
    lista.add(Novo);
    lista.setVisible(true);
    buttonPanel.setVisible(true);
    table = new JTable();
    table.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseReleased(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mousePressed(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseExited(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseEntered(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseClicked(MouseEvent arg0) {
            int linha = table.getSelectedRow();
            int coluna = table.getSelectedColumn();
            String matricula = (String) table.getValueAt(linha, 0);
            Integer mat = Integer.parseInt(matricula);
            if (coluna == 7) {
              int opcao;
              opcao =
                  JOptionPane.showConfirmDialog(
                      null,
                      "Deseja excluir o registro de matricula: " + matricula,
                      "Cuidado!!",
                      JOptionPane.YES_NO_OPTION);
              if (opcao == JOptionPane.YES_OPTION) {
                try {
                  folhaDao.excluirPagamento(mat);
                  atualizaLista(table, "");
                } catch (DaoException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
                JOptionPane.showMessageDialog(null, "Dados excluidos com sucesso!");
              }
            }
            if (coluna == 5) {
              FolhaPagamento objFolha = new FolhaPagamento();

              try {
                objFolha = folhaDao.consultarPagamentoID(mat);
                atualizaFormulario(objFolha);
                buttonPanel.setVisible(false);
              } catch (DaoException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
            }
            // Gera a folha pra imprimir
            if (coluna == 6) {
              FolhaControle controle = new FolhaControle();
              Funcionario objFunc = new Funcionario();
              FolhaPagamento objFolha = new FolhaPagamento();

              Integer qntd;

              String nome = (String) table.getValueAt(linha, 1);
              try {
                objFunc = funcDao.procurarFuncionarioNome(nome);
                objFolha = folhaDao.procurarDataPag(mat);
                qntd = folhaDao.quantidadePedido(objFunc.getNumFunc());
                if (qntd == 0) {
                  controle.gerarRelatorioFolhaSimples(
                      objFunc.getNumFunc(), objFolha.getDataInicio(), objFolha.getDataFim());
                } else
                  controle.gerarRelatorioFolha(
                      objFunc.getNumFunc(), objFolha.getDataInicio(), objFolha.getDataFim());
              } catch (DaoException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
            }
          }
        });

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setModel(
        new DefaultTableModel(
            new Object[][] {},
            new String[] {
              "Nº",
              "Nome",
              "Profissão",
              "Salário",
              "Data Pagamento",
              "Editar",
              "Relatório",
              "Excluir"
            }) {
          private static final long serialVersionUID = 1L;

          @Override
          public boolean isCellEditable(int row, int col) {
            return false;
          }
        });
    table.getColumnModel().getColumn(0).setPreferredWidth(35);
    table.getColumnModel().getColumn(0).setMinWidth(35);
    table.getColumnModel().getColumn(1).setPreferredWidth(170);
    table.getColumnModel().getColumn(1).setMinWidth(170);
    table.getColumnModel().getColumn(2).setPreferredWidth(80);
    table.getColumnModel().getColumn(2).setMinWidth(80);
    table.getColumnModel().getColumn(3).setPreferredWidth(50);
    table.getColumnModel().getColumn(3).setMinWidth(50);

    table.getColumnModel().getColumn(4).setPreferredWidth(100);
    table.getColumnModel().getColumn(4).setMinWidth(100);
    table.getColumnModel().getColumn(5).setPreferredWidth(40);
    table.getColumnModel().getColumn(5).setMinWidth(40);
    table.getColumnModel().getColumn(6).setPreferredWidth(50);
    table.getColumnModel().getColumn(6).setMinWidth(50);

    table.getColumnModel().getColumn(7).setPreferredWidth(40);
    table.getColumnModel().getColumn(7).setMinWidth(40);
    table.setBounds(39, 175, 530, 232);
    atualizaLista(table, "");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 51, 636, 473);
    lista.add(scrollPane);

    scrollPane.setViewportView(table);

    Novo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            lista.setVisible(false);
            formulario.setVisible(true);
            buttonPanel.setVisible(false);
            limpaFormulario();
            try {
              atualizaLista(table, "");
            } catch (DaoException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });
  }
Ejemplo n.º 27
0
  private void initComponents() {
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setTitle("Kreator pizzeriów");
    setPreferredSize(new Dimension(450, 300));
    setLocation(100, 100);
    setMinimumSize(new Dimension(450, 300));
    getContentPane().setLayout(new GridLayout(1, 0, 0, 0));

    mainPanel = new JPanel();
    getContentPane().add(mainPanel);
    cl_mainPanel = new CardLayout(0, 0);
    mainPanel.setLayout(cl_mainPanel);

    basicsCard = new JPanel();
    mainPanel.add(basicsCard, "name_5161336780321");
    basicsCard.setLayout(new MigLayout("", "[][grow][]", "[75][25px,grow][grow][]"));

    titleLabel1 = new JLabel("Kreator pizzeriów");
    titleLabel1.setFont(new Font("Dialog", Font.BOLD, 24));
    titleLabel1.setHorizontalAlignment(SwingConstants.CENTER);
    basicsCard.add(titleLabel1, "cell 0 0 3 1,grow");

    nameLabel = new JLabel("Nazwa");
    nameLabel.setFont(new Font("Dialog", Font.BOLD, 16));
    nameLabel.setHorizontalAlignment(SwingConstants.CENTER);
    basicsCard.add(nameLabel, "cell 0 1,alignx right,aligny center");

    nextButton1 = new JButton("Dalej");

    nameField = new JTextField();
    basicsCard.add(nameField, "cell 1 1,growx,aligny center");
    nameField.setColumns(10);

    addressLabel = new JLabel("Adres");
    addressLabel.setFont(new Font("Dialog", Font.BOLD, 16));
    basicsCard.add(addressLabel, "cell 0 2,alignx trailing");

    addressField = new JTextField();
    basicsCard.add(addressField, "cell 1 2,growx");
    addressField.setColumns(10);
    basicsCard.add(nextButton1, "cell 2 3,alignx right,aligny bottom");

    hoursCard = new JPanel();
    mainPanel.add(hoursCard, "name_6314720138332");
    hoursCard.setLayout(new MigLayout("", "[][grow][][]", "[75][grow][grow][grow][grow][]"));

    titleLabel2 = new JLabel("Kreator pizzeriów");
    titleLabel2.setFont(new Font("Dialog", Font.BOLD, 24));
    hoursCard.add(titleLabel2, "cell 0 0 4 1,alignx center,aligny center");

    openingHoursLabel = new JLabel("Godziny otwarcia");
    openingHoursLabel.setFont(new Font("Dialog", Font.BOLD, 16));
    hoursCard.add(openingHoursLabel, "cell 0 1");

    openingHoursCheckbox = new JCheckBox("Te same godziny codziennie");
    openingHoursCheckbox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dayComboBox.setEnabled(!openingHoursCheckbox.isSelected());
          }
        });
    hoursCard.add(openingHoursCheckbox, "cell 1 1 3 1");

    dayLabel = new JLabel("Dzień");
    dayLabel.setFont(new Font("Dialog", Font.BOLD, 16));
    hoursCard.add(dayLabel, "cell 0 2,alignx left");

    dayComboBox = new JComboBox();

    hoursCard.add(dayComboBox, "cell 1 2,growx");
    dayComboBox.setModel(new DefaultComboBoxModel(days));

    fromLabel = new JLabel("Od");
    fromLabel.setFont(new Font("Dialog", Font.BOLD, 16));
    hoursCard.add(fromLabel, "cell 0 3,alignx left");

    fromField = new JFormattedTextField(new SimpleDateFormat("HH:mm"));

    hoursCard.add(fromField, "cell 1 3,growx");
    fromField.setColumns(10);

    toLabel = new JLabel("Do");
    toLabel.setFont(new Font("Dialog", Font.BOLD, 16));
    hoursCard.add(toLabel, "cell 0 4,alignx left");

    toField = new JFormattedTextField(new SimpleDateFormat("HH:mm"));

    hoursCard.add(toField, "cell 1 4,growx");
    toField.setColumns(10);

    previousButton2 = new JButton("Cofnij");
    previousButton2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cl_mainPanel.previous(mainPanel);
          }
        });
    hoursCard.add(previousButton2, "cell 2 5");

    nextButton2 = new JButton("Dalej");
    nextButton2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            cl_mainPanel.next(mainPanel);
          }
        });
    hoursCard.add(nextButton2, "cell 3 5,alignx right,aligny bottom");

    contactCard = new JPanel();
    mainPanel.add(contactCard, "name_7774263886040");
    contactCard.setLayout(new MigLayout("", "[][grow][][]", "[75][grow][grow][]"));

    titleLabel3 = new JLabel("Kreator pizzeriów");
    titleLabel3.setFont(new Font("Dialog", Font.BOLD, 24));
    contactCard.add(titleLabel3, "cell 0 0 4 1,alignx center,aligny center");

    siteLabel = new JLabel("Strona");
    siteLabel.setFont(new Font("Dialog", Font.BOLD, 16));
    contactCard.add(siteLabel, "cell 0 1,alignx trailing");

    siteField = new JTextField();
    contactCard.add(siteField, "cell 1 1,growx,aligny center");
    siteField.setColumns(10);

    phoneLabel = new JLabel("Telefon");
    phoneLabel.setFont(new Font("Dialog", Font.BOLD, 16));
    contactCard.add(phoneLabel, "cell 0 2,alignx trailing");

    phoneField = new JTextField();
    contactCard.add(phoneField, "cell 1 2,growx,aligny center");
    phoneField.setColumns(10);

    previousButton3 = new JButton("Cofnij");
    previousButton3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cl_mainPanel.previous(mainPanel);
          }
        });
    contactCard.add(previousButton3, "cell 2 3,aligny bottom");

    endButton = new JButton("Koniec");
    contactCard.add(endButton, "cell 3 3,alignx right,aligny bottom");
  }
Ejemplo n.º 28
0
  /** make the view for this face */
  protected Component makeView() {
    final Box mainBox = new Box(BoxLayout.Y_AXIS);

    final JTable bpmTable = new JTable(BPM_TABLE_MODEL);

    final JSplitPane mainSplitPane =
        new JSplitPane(
            JSplitPane.VERTICAL_SPLIT, new JScrollPane(bpmTable), TARGET_PLOT.getPlotPanel());
    final Box mainSplitBox = new Box(BoxLayout.X_AXIS);
    mainSplitBox.add(mainSplitPane);
    mainBox.add(mainSplitBox);
    mainSplitPane.setOneTouchExpandable(true);
    mainSplitPane.addAncestorListener(
        new AncestorListener() {
          public void ancestorAdded(final AncestorEvent event) {
            // only set the divider location the first time it becomes visible
            if (mainSplitPane.getClientProperty("initialized") == null) {
              mainSplitPane.setDividerLocation(0.4);
              mainSplitPane.putClientProperty("initialized", true);
            }
          }

          public void ancestorRemoved(final AncestorEvent event) {}

          public void ancestorMoved(final AncestorEvent event) {}
        });

    final Box targetBox = new Box(BoxLayout.X_AXIS);
    mainBox.add(targetBox);
    targetBox.setBorder(BorderFactory.createTitledBorder("Target Beam Position"));

    final java.text.NumberFormat TARGET_NUMBER_FORMAT = new DecimalFormat("#,##0.0");
    final int NUMBER_WIDTH = 6;

    targetBox.add(new JLabel("X (mm):"));
    final JFormattedTextField xTargetField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    xTargetField.setToolTipText("Matching Target horizontal beam position");
    xTargetField.setEditable(false);
    xTargetField.setHorizontalAlignment(JTextField.RIGHT);
    xTargetField.setColumns(NUMBER_WIDTH);
    xTargetField.setMaximumSize(xTargetField.getPreferredSize());
    targetBox.add(xTargetField);

    targetBox.add(new JLabel("+/-"));
    final JFormattedTextField xTargetErrorField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    xTargetErrorField.setToolTipText("Estimated horizontal target beam position error.");
    xTargetErrorField.setEditable(false);
    xTargetErrorField.setHorizontalAlignment(JTextField.RIGHT);
    xTargetErrorField.setColumns(NUMBER_WIDTH);
    xTargetErrorField.setMaximumSize(xTargetErrorField.getPreferredSize());
    targetBox.add(xTargetErrorField);
    targetBox.add(Box.createHorizontalGlue());

    targetBox.add(new JLabel("Y (mm):"));
    final JFormattedTextField yTargetField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    yTargetField.setToolTipText("Matching Target vertical beam position");
    yTargetField.setEditable(false);
    yTargetField.setHorizontalAlignment(JTextField.RIGHT);
    yTargetField.setColumns(NUMBER_WIDTH);
    yTargetField.setMaximumSize(yTargetField.getPreferredSize());
    targetBox.add(yTargetField);

    targetBox.add(new JLabel("+/-"));
    final JFormattedTextField yTargetErrorField = new JFormattedTextField(TARGET_NUMBER_FORMAT);
    yTargetErrorField.setToolTipText("Estimated vertical target beam position error.");
    yTargetErrorField.setEditable(false);
    yTargetErrorField.setHorizontalAlignment(JTextField.RIGHT);
    yTargetErrorField.setColumns(NUMBER_WIDTH);
    yTargetErrorField.setMaximumSize(yTargetErrorField.getPreferredSize());
    targetBox.add(yTargetErrorField);
    targetBox.add(Box.createHorizontalGlue());

    final JButton clearButton = new JButton("Clear");
    clearButton.setToolTipText("Clear results and running average BPM statistics.");
    targetBox.add(clearButton);
    clearButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            TARGET_PLOT.clear();
            clearBeamPositionRunningAverage();
            xTargetField.setValue(null);
            xTargetErrorField.setValue(null);
            yTargetField.setValue(null);
            yTargetErrorField.setValue(null);
          }
        });

    final JButton startButton = new JButton("Start");
    startButton.setToolTipText("Start Beam Position Running Average after clearing it.");
    targetBox.add(startButton);
    startButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            for (final BpmAgent bpmAgent : BPM_AGENTS) {
              bpmAgent.startAveraging(); // automatically clears the running average each time
            }
          }
        });

    final JButton stopButton = new JButton("Stop");
    stopButton.setToolTipText("Stop Beam Position Running Average.");
    targetBox.add(stopButton);
    stopButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            stopRunningAverage();
          }
        });

    final JButton targetMatchButton = new JButton("Match");
    targetMatchButton.setToolTipText(
        "<html><body>Stop averaging the BPM beam position.<br>Match the target position to the BPM beam position data.</body></html>");
    targetBox.add(targetMatchButton);
    targetMatchButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            try {
              stopButton.doClick();

              final List<BpmAgent> enabledBpmAgents = BPM_TABLE_MODEL.getEnabledBpmAgents();
              final List<BpmAgent> xBpmAgents = new ArrayList<BpmAgent>(enabledBpmAgents.size());
              final List<BpmAgent> yBpmAgents = new ArrayList<BpmAgent>(enabledBpmAgents.size());
              final StringBuffer warningsBuffer = new StringBuffer("");

              if (enabledBpmAgents.size() < 2) {
                warningsBuffer.append(
                    "Only " + enabledBpmAgents.size() + " are enabled for matching.\n");
              }

              // only include BPM agents with running average samples for at least one valid channel
              for (final BpmAgent bpmAgent : enabledBpmAgents) {
                if (bpmAgent.hasRunningAverageSamplesInValidPlanes()) {
                  if (bpmAgent.isXAvgChannelValid()) {
                    xBpmAgents.add(bpmAgent);
                  } else {
                    warningsBuffer.append(
                        "Warning: Enabled BPM, "
                            + bpmAgent.name()
                            + " has an invalid X Avg channel, "
                            + bpmAgent.getXAvgChannel().channelName()
                            + " which will be exluded from analysis.\n");
                  }

                  if (bpmAgent.isYAvgChannelValid()) {
                    yBpmAgents.add(bpmAgent);
                  } else {
                    warningsBuffer.append(
                        "Warning: Enabled BPM, "
                            + bpmAgent.name()
                            + " has an invalid Y Avg channel, "
                            + bpmAgent.getYAvgChannel().channelName()
                            + " which will be exluded from analysis.\n");
                  }
                } else if (!bpmAgent.hasValidPlane()) {
                  warningsBuffer.append(
                      "Warning: Ignoring BPM, "
                          + bpmAgent.name()
                          + " because it has no valid X or Y channel.\n");
                } else {
                  warningsBuffer.append(
                      "Warning: Ignoring BPM, "
                          + bpmAgent.name()
                          + " because it has no samples in a valid channel.\n");
                }
              }

              // always post warnings to the console
              final String warningsMessage = warningsBuffer.toString();
              if (warningsMessage != null && warningsMessage.length() > 0) {
                System.out.print(warningsBuffer.toString());
              }

              // to match both X and Y, at least two BPMs must be valid for each of X and Y channels
              if (xBpmAgents.size() < 2 || yBpmAgents.size() < 2) {
                DOCUMENT.displayError(
                    "Matching Error",
                    "You must choose at least 2 BPMs that have valid channels for each plane.\n"
                        + warningsBuffer.toString());
                return;
              }

              if (_beamPositionMatcher == null) {
                _beamPositionMatcher = new TargetBeamPositionMatcher(RTBT_SEQUENCE);
              }
              final BeamPosition targetBeamPosition =
                  _beamPositionMatcher.getMatchingTargetBeamPosition(xBpmAgents, yBpmAgents);
              xTargetField.setValue(targetBeamPosition.X);
              xTargetErrorField.setValue(targetBeamPosition.X_RMS_ERROR);
              yTargetField.setValue(targetBeamPosition.Y);
              yTargetErrorField.setValue(targetBeamPosition.Y_RMS_ERROR);

              // update the main document so the values can be shared elsewhere
              DOCUMENT.xpos = targetBeamPosition.X;
              DOCUMENT.ypos = targetBeamPosition.Y;

              TARGET_PLOT.displayBeamPosition(
                  targetBeamPosition.X,
                  targetBeamPosition.Y,
                  targetBeamPosition.X_RMS_ERROR,
                  targetBeamPosition.Y_RMS_ERROR);
            } catch (Exception exception) {
              exception.printStackTrace();
              JOptionPane.showMessageDialog(
                  FACE_VIEW,
                  exception.getMessage(),
                  "Error matching target beam position.",
                  JOptionPane.ERROR_MESSAGE);
            }
          }
        });

    final JButton copyReportButton = new JButton("Report");
    copyReportButton.setToolTipText("Copy a report to the clipboard.");
    targetBox.add(copyReportButton);
    copyReportButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent event) {
            final StringBuffer reportBuffer = new StringBuffer("Target Beam Position Report\n");
            reportBuffer.append(
                "Date:\t" + new SimpleDateFormat("MMM dd, yyyy HH:mm:ss").format(new Date()));
            reportBuffer.append("\n");
            reportBuffer.append("BPM Data:\n");
            BPM_TABLE_MODEL.appendReport(reportBuffer);
            reportBuffer.append(
                "Matching Target X (mm):\t"
                    + xTargetField.getText()
                    + "\t+/-\t"
                    + xTargetErrorField.getText()
                    + "\n");
            reportBuffer.append(
                "Matching Target Y (mm):\t"
                    + yTargetField.getText()
                    + "\t+/-\t"
                    + yTargetErrorField.getText()
                    + "\n");

            final String report = reportBuffer.toString();
            final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            final StringSelection contents = new StringSelection(report);
            clipboard.setContents(contents, contents);
          }
        });

    return mainBox;
  }
Ejemplo n.º 29
0
  /** @param driver Needed for the Replicator-specific options */
  public PreferencesWindow(final MachineInterface machine) {
    super("Preferences");
    setResizable(true);

    Image icon = Base.getImage("images/icon.gif", this);
    setIconImage(icon);

    JTabbedPane prefTabs = new JTabbedPane();

    JPanel basic = new JPanel();

    //		Container content = this.getContentPane();
    Container content = basic;
    content.setLayout(new MigLayout("fill"));

    content.add(new JLabel("MainWindow font size: "), "split");
    fontSizeField = new JFormattedTextField(Base.getLocalFormat());
    fontSizeField.setColumns(4);
    content.add(fontSizeField);
    content.add(new JLabel("  (requires restart of ReplicatorG)"), "wrap");

    boolean checkTempDuringBuild = Base.preferences.getBoolean("build.monitor_temp", true);
    boolean displaySpeedWarning = Base.preferences.getBoolean("build.speed_warning", true);

    addCheckboxForPref(
        content, "Monitor temperature during builds", "build.monitor_temp", checkTempDuringBuild);
    addCheckboxForPref(
        content, "Display Accelerated Speed Warnings", "build.speed_warning", displaySpeedWarning);
    addCheckboxForPref(
        content, "Automatically connect to machine at startup", "replicatorg.autoconnect", true);
    addCheckboxForPref(
        content, "Show experimental machine profiles", "machine.showExperimental", false);
    addCheckboxForPref(
        content,
        "Review GCode for potential toolhead problems before building",
        "build.safetyChecks",
        true);
    addCheckboxForPref(
        content,
        "Break Z motion into separate moves (normally false)",
        "replicatorg.parser.breakzmoves",
        false);
    addCheckboxForPref(
        content, "Show starfield in model preview window", "ui.show_starfield", false);
    addCheckboxForPref(
        content, "Notifications in System tray", "ui.preferSystemTrayNotifications", false);
    addCheckboxForPref(
        content,
        "Automatically regenerate gcode when building from model view.",
        "build.autoGenerateGcode",
        true);
    addCheckboxForPref(
        content, "Use native avrdude for uploading code", "uploader.useNative", false);

    JPanel advanced = new JPanel();
    content = advanced;
    content.setLayout(new MigLayout("fill"));

    JButton modelColorButton;
    modelColorButton = new JButton("Choose model color");
    modelColorButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Note that this color is also defined in EditingModel.java
            Color modelColor = new Color(Base.preferences.getInt("ui.modelColor", -19635));
            modelColor = JColorChooser.showDialog(null, "Choose Model Color", modelColor);
            if (modelColor == null) return;

            Base.preferences.putInt("ui.modelColor", modelColor.getRGB());
            Base.getEditor().refreshPreviewPanel();
          }
        });
    modelColorButton.setVisible(true);
    content.add(modelColorButton, "split");

    JButton backgroundColorButton;
    backgroundColorButton = new JButton("Choose background color");
    backgroundColorButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Note that this color is also defined in EditingModel.java
            Color backgroundColor = new Color(Base.preferences.getInt("ui.backgroundColor", 0));
            backgroundColor =
                JColorChooser.showDialog(null, "Choose Background Color", backgroundColor);
            if (backgroundColor == null) return;

            Base.preferences.putInt("ui.backgroundColor", backgroundColor.getRGB());
            Base.getEditor().refreshPreviewPanel();
          }
        });
    backgroundColorButton.setVisible(true);
    content.add(backgroundColorButton, "wrap");

    content.add(new JLabel("Firmware update URL: "), "split");
    firmwareUpdateUrlField = new JTextField(34);
    content.add(firmwareUpdateUrlField, "growx, wrap");

    {
      JLabel arcResolutionLabel = new JLabel("Arc resolution (in mm): ");
      content.add(arcResolutionLabel, "split");
      double value = Base.preferences.getDouble("replicatorg.parser.curve_segment_mm", 1.0);
      JFormattedTextField arcResolutionField = new JFormattedTextField(Base.getLocalFormat());
      arcResolutionField.setValue(new Double(value));
      content.add(arcResolutionField);
      String arcResolutionHelp =
          "<html><small><em>"
              + "The arc resolution is the default segment length that the gcode parser will break arc codes <br>"
              + "like G2 and G3 into.  Drivers that natively handle arcs will ignore this setting."
              + "</em></small></html>";
      arcResolutionField.setToolTipText(arcResolutionHelp);
      arcResolutionLabel.setToolTipText(arcResolutionHelp);
      //			content.add(new JLabel(arcResolutionHelp),"growx,wrap");
      arcResolutionField.setColumns(10);
      arcResolutionField.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
              if (evt.getPropertyName() == "value") {
                try {
                  Double v = (Double) evt.getNewValue();
                  if (v == null) return;
                  Base.preferences.putDouble(
                      "replicatorg.parser.curve_segment_mm", v.doubleValue());
                } catch (ClassCastException cce) {
                  Base.logger.warning(
                      "Unexpected value type: " + evt.getNewValue().getClass().toString());
                }
              }
            }
          });
    }

    {
      JLabel sfTimeoutLabel = new JLabel("Skeinforge timeout: ");
      content.add(sfTimeoutLabel, "split, gap unrelated");
      int value = Base.preferences.getInt("replicatorg.skeinforge.timeout", -1);
      JFormattedTextField sfTimeoutField = new JFormattedTextField(Base.getLocalFormat());
      sfTimeoutField.setValue(new Integer(value));
      content.add(sfTimeoutField, "wrap 10px, growx");
      String sfTimeoutHelp =
          "<html><small><em>"
              + "The Skeinforge timeout is the number of seconds that replicatorg will wait while the<br>"
              + "Skeinforge preferences window is open. If you find that RepG freezes after editing profiles<br>"
              + "you can set this number greater than -1 (-1 means no timeout)."
              + "</em></small></html>";
      sfTimeoutField.setToolTipText(sfTimeoutHelp);
      sfTimeoutLabel.setToolTipText(sfTimeoutHelp);
      //			content.add(new JLabel(sfTimeoutHelp),"growx,wrap");
      sfTimeoutField.setColumns(10);
      sfTimeoutField.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
              if (evt.getPropertyName() == "value") {
                try {
                  Integer v = ((Number) evt.getNewValue()).intValue();
                  if (v == null) return;
                  Base.preferences.putInt("replicatorg.skeinforge.timeout", v.intValue());
                } catch (ClassCastException cce) {
                  Base.logger.warning(
                      "Unexpected value type: " + evt.getNewValue().getClass().toString());
                }
              }
            }
          });
    }

    {
      content.add(new JLabel("Debugging level (default INFO):"), "split");
      content.add(makeDebugLevelDropdown(), "wrap");

      final JCheckBox logCb = new JCheckBox("Log to file");
      logCb.setSelected(Base.preferences.getBoolean("replicatorg.useLogFile", false));
      content.add(logCb, "split");
      logCb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              Base.preferences.putBoolean("replicatorg.useLogFile", logCb.isSelected());
            }
          });

      final JLabel logPathLabel = new JLabel("Log file name: ");
      content.add(logPathLabel, "split");
      logPathField = new JTextField(34);
      content.add(logPathField, "growx, wrap 10px");
      logPathField.setEnabled(logCb.isSelected());
      logPathLabel.setEnabled(logCb.isSelected());

      logCb.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              JCheckBox box = (JCheckBox) e.getSource();
              logPathField.setEnabled(box.isSelected());
              logPathLabel.setEnabled(box.isSelected());
            }
          });
    }

    {
      final int defaultTemp = 75;
      final String tooltipGeneral =
          "When enabled, starting all builds heats components to this temperature";
      final String tooltipHead = "Set preheat temperature for the specified toolhead";
      final String tooltipPlatform = "Set preheat temperature for the build platfom";

      final JCheckBox preheatCb = new JCheckBox("Preheat builds");
      preheatCb.setToolTipText(tooltipGeneral);
      content.add(preheatCb, "split");

      preheatCb.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
              Base.preferences.putBoolean("build.doPreheat", preheatCb.isSelected());
            }
          });
      preheatCb.setSelected(Base.preferences.getBoolean("build.doPreheat", false));

      final JLabel t0Label = new JLabel("Toolhead Right: ");
      final JLabel t1Label = new JLabel("Toolhead Left: ");
      final JLabel pLabel = new JLabel("Platform: ");

      Integer t0Value = Base.preferences.getInt("build.preheatTool0", defaultTemp);
      Integer t1Value = Base.preferences.getInt("build.preheatTool1", defaultTemp);
      Integer pValue = Base.preferences.getInt("build.preheatPlatform", defaultTemp);

      final JFormattedTextField t0Field = new JFormattedTextField(Base.getLocalFormat());
      final JFormattedTextField t1Field = new JFormattedTextField(Base.getLocalFormat());
      final JFormattedTextField pField = new JFormattedTextField(Base.getLocalFormat());

      t0Field.setToolTipText(tooltipHead);
      t0Label.setToolTipText(tooltipHead);
      t1Field.setToolTipText(tooltipHead);
      t1Label.setToolTipText(tooltipHead);
      pField.setToolTipText(tooltipPlatform);
      pLabel.setToolTipText(tooltipPlatform);

      t0Field.setValue(t0Value);
      t1Field.setValue(t1Value);
      pField.setValue(pValue);

      // let's avoid creating too many Anon. inner Listeners, also is fewer lines (and just as
      // clear)!
      PropertyChangeListener p =
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
              if (evt.getPropertyName() == "value") {
                double target;
                if (evt.getSource() == t0Field) {
                  target = ((Number) t0Field.getValue()).doubleValue();
                  target = confirmTemperature(target, "temperature.acceptedLimit", 200.0);
                  if (target == Double.MIN_VALUE) {
                    t0Field.setValue(Base.preferences.getInt("build.preheatTool0", defaultTemp));
                    return;
                  }
                  Base.preferences.putInt("build.preheatTool0", (int) target);
                } else if (evt.getSource() == t1Field) {
                  target = ((Number) t1Field.getValue()).doubleValue();
                  target = confirmTemperature(target, "temperature.acceptedLimit", 200.0);
                  if (target == Double.MIN_VALUE) {
                    t0Field.setValue(Base.preferences.getInt("build.preheatTool1", defaultTemp));
                    return;
                  }
                  Base.preferences.putInt("build.preheatTool1", (int) target);
                } else if (evt.getSource() == pField) {
                  target = ((Number) pField.getValue()).doubleValue();
                  target = confirmTemperature(target, "temperature.acceptedLimit.bed", 110.0);
                  if (target == Double.MIN_VALUE) {
                    t0Field.setValue(Base.preferences.getInt("build.preheatPlatform", defaultTemp));
                    return;
                  }
                  Base.preferences.putInt("build.preheatPlatform", (int) target);
                }
              }
            }
          };

      t0Field.addPropertyChangeListener(p);
      t1Field.addPropertyChangeListener(p);
      pField.addPropertyChangeListener(p);

      content.add(t0Label, "split, gap 20px");
      content.add(t0Field, "split, growx");
      content.add(t1Label, "split, gap unrelated");
      content.add(t1Field, "split, growx");
      content.add(pLabel, "split, gap unrelated");
      content.add(pField, "split, growx, wrap 10px");
    }

    {
      JButton b = new JButton("Select Python interpreter...");
      content.add(b, "spanx,wrap 10px");
      b.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              SwingPythonSelector sps = new SwingPythonSelector(PreferencesWindow.this);
              String path = sps.selectFreeformPath();
              if (path != null) {
                PythonUtils.setPythonPath(path);
              }
            }
          });
    }

    addInitialFilePrefs(content);

    prefTabs.add(basic, "Basic");
    prefTabs.add(advanced, "Advanced");

    content = getContentPane();
    content.setLayout(new MigLayout());

    content.add(prefTabs, "wrap");

    JButton allPrefs = new JButton("View Preferences Table");
    content.add(allPrefs, "split");
    allPrefs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFrame advancedPrefs = new AdvancedPrefs();
            advancedPrefs.setVisible(true);
          }
        });

    // Also available as a menu item in the main gui.
    JButton delPrefs = new JButton("Reset all preferences");
    content.add(delPrefs);
    delPrefs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            editor.resetPreferences();
          }
        });

    JButton button;
    button = new JButton("Close");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            applyFrame();
            dispose();
          }
        });
    content.add(button, "tag ok");

    showCurrentSettings();

    // closing the window is same as hitting cancel button
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            dispose();
          }
        });

    ActionListener disposer =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            dispose();
          }
        };
    Base.registerWindowCloseKeys(getRootPane(), disposer);

    pack();
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation((screen.width - getWidth()) / 2, (screen.height - getHeight()) / 2);

    // handle window closing commands for ctrl/cmd-W or hitting ESC.

    getContentPane()
        .addKeyListener(
            new KeyAdapter() {
              public void keyPressed(KeyEvent e) {
                KeyStroke wc = MainWindow.WINDOW_CLOSE_KEYSTROKE;
                if ((e.getKeyCode() == KeyEvent.VK_ESCAPE)
                    || (KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
                  dispose();
                }
              }
            });
  }
Ejemplo n.º 30
0
  @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;
  }