Exemplo n.º 1
0
  private void initGUI() {
    setLayout(new BorderLayout());

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    add(tabbedPane);

    {
      final JPanel panelIntroduction = new JPanel();
      tabbedPane.addTab("Intro", null, panelIntroduction, null);
      panelIntroduction.setLayout(null);

      final JLabel lblCrownwearingNucleiTracker = new JLabel("Crown-Wearing Nuclei Segmenter");
      lblCrownwearingNucleiTracker.setFont(BIG_FONT);
      lblCrownwearingNucleiTracker.setHorizontalAlignment(SwingConstants.CENTER);
      lblCrownwearingNucleiTracker.setBounds(10, 11, 268, 30);
      panelIntroduction.add(lblCrownwearingNucleiTracker);

      final JLabel labelIntro = new JLabel(INTRO_TEXT);
      labelIntro.setFont(SMALL_FONT.deriveFont(11f));
      labelIntro.setBounds(10, 52, 268, 173);
      panelIntroduction.add(labelIntro);

      final JButton btnTestParamtersLive =
          new JButton("<html><div align=\"center\">Live test parameters</dic></html>");
      btnTestParamtersLive.setBounds(10, 292, 103, 72);
      btnTestParamtersLive.setFont(FONT);
      liveLaunched = false;
      btnTestParamtersLive.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
              if (liveLaunched) {
                stopLive();
                btnTestParamtersLive.setText(
                    "<html><div align=\"center\">Live test parameters</div></html>");
                liveLaunched = false;
              } else {
                launchLive();
                btnTestParamtersLive.setText(
                    "<html><div align=\"center\">Stop live test</div></html>");
                liveLaunched = true;
              }
            }
          });
      panelIntroduction.add(btnTestParamtersLive);

      final String segFrameButtonText = "<html><CENTER>Segment current frame</center></html>";
      final JButton segFrameButton = new JButton(segFrameButtonText);
      segFrameButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
              new Thread("CWNT thread") {
                @Override
                public void run() {
                  segFrameButton.setText("Segmenting...");
                  segFrameButton.setEnabled(false);
                  try {
                    launchSingleFrameSegmentation();
                  } finally {
                    segFrameButton.setEnabled(true);
                    segFrameButton.setText(segFrameButtonText);
                  }
                }
              }.start();
            }
          });
      segFrameButton.setFont(FONT);
      segFrameButton.setBounds(175, 292, 103, 72);
      panelIntroduction.add(segFrameButton);

      labelDurationEstimate = new JLabel();
      labelDurationEstimate.setBounds(10, 375, 268, 14);
      panelIntroduction.setFont(FONT);
      panelIntroduction.add(labelDurationEstimate);
    }

    final JPanel panelParams1 = new JPanel();
    {
      tabbedPane.addTab("Param set 1", null, panelParams1, null);
      panelParams1.setLayout(null);

      final JLabel lblFiltering = new JLabel("1. Filtering");
      lblFiltering.setFont(BIG_FONT);
      lblFiltering.setBounds(10, 11, 268, 29);
      panelParams1.add(lblFiltering);

      {
        final JLabel lblGaussianFilter = new JLabel("Gaussian filter \u03C3:");
        lblGaussianFilter.setFont(SMALL_FONT);
        lblGaussianFilter.setBounds(10, 51, 268, 14);
        panelParams1.add(lblGaussianFilter);

        gaussFiltSigmaSlider =
            new DoubleJSlider(0, 5 * scale, (int) (maskingParams[0] * scale), scale);
        gaussFiltSigmaSlider.setBounds(10, 76, 223, 23);
        panelParams1.add(gaussFiltSigmaSlider);

        gaussFiltSigmaText = new JFormattedTextField(new Double(maskingParams[0]));
        gaussFiltSigmaText.setHorizontalAlignment(SwingConstants.CENTER);
        gaussFiltSigmaText.setBounds(243, 76, 35, 23);
        gaussFiltSigmaText.setFont(FONT);
        panelParams1.add(gaussFiltSigmaText);

        link(gaussFiltSigmaSlider, gaussFiltSigmaText);
        gaussFiltSigmaSlider.addChangeListener(step1ChangeListener);
        gaussFiltSigmaText.addKeyListener(step1KeyListener);
      }

      final JLabel lblAnisotropicDiffusion = new JLabel("2. Anisotropic diffusion");
      lblAnisotropicDiffusion.setFont(BIG_FONT);
      lblAnisotropicDiffusion.setBounds(10, 128, 268, 29);
      panelParams1.add(lblAnisotropicDiffusion);

      {
        final JLabel lblNumberOfIterations = new JLabel("Number of iterations:");
        lblNumberOfIterations.setFont(SMALL_FONT);
        lblNumberOfIterations.setBounds(10, 168, 268, 14);
        panelParams1.add(lblNumberOfIterations);

        aniDiffNIterText = new JFormattedTextField(new Integer((int) maskingParams[1]));
        aniDiffNIterText.setHorizontalAlignment(SwingConstants.CENTER);
        aniDiffNIterText.setFont(FONT);
        aniDiffNIterText.setBounds(243, 193, 35, 23);
        panelParams1.add(aniDiffNIterText);

        aniDiffNIterSlider = new DoubleJSlider(0, 10, (int) maskingParams[1], 1);
        aniDiffNIterSlider.setBounds(10, 193, 223, 23);
        panelParams1.add(aniDiffNIterSlider);

        link(aniDiffNIterSlider, aniDiffNIterText);
        aniDiffNIterSlider.addChangeListener(step2ChangeListener);
        aniDiffNIterText.addKeyListener(step2KeyListener);
      }

      {
        final JLabel lblGradientDiffusionThreshold =
            new JLabel("Gradient diffusion threshold \u03BA:");
        lblGradientDiffusionThreshold.setFont(SMALL_FONT);
        lblGradientDiffusionThreshold.setBounds(10, 227, 268, 14);
        panelParams1.add(lblGradientDiffusionThreshold);

        aniDiffKappaText = new JFormattedTextField(new Double(maskingParams[2]));
        aniDiffKappaText.setHorizontalAlignment(SwingConstants.CENTER);
        aniDiffKappaText.setFont(FONT);
        aniDiffKappaText.setBounds(243, 252, 35, 23);
        panelParams1.add(aniDiffKappaText);

        aniDiffKappaSlider = new DoubleJSlider(1, 100, (int) maskingParams[2], 1);
        aniDiffKappaSlider.setBounds(10, 252, 223, 23);
        panelParams1.add(aniDiffKappaSlider);

        link(aniDiffKappaSlider, aniDiffKappaText);
        aniDiffKappaSlider.addChangeListener(step2ChangeListener);
        aniDiffKappaText.addKeyListener(step2KeyListener);
      }

      final JLabel lblDerivativesCalculation = new JLabel("3. Derivatives calculation");
      lblDerivativesCalculation.setFont(BIG_FONT);
      lblDerivativesCalculation.setBounds(10, 298, 268, 29);
      panelParams1.add(lblDerivativesCalculation);

      {
        final JLabel lblGaussianGradient = new JLabel("Gaussian gradient \u03C3:");
        lblGaussianGradient.setFont(FONT);
        lblGaussianGradient.setBounds(10, 338, 268, 14);
        panelParams1.add(lblGaussianGradient);

        gaussGradSigmaText = new JFormattedTextField(new Double(maskingParams[3]));
        gaussGradSigmaText.setFont(FONT);
        gaussGradSigmaText.setHorizontalAlignment(SwingConstants.CENTER);
        gaussGradSigmaText.setBounds(243, 363, 35, 23);
        panelParams1.add(gaussGradSigmaText);

        gaussGradSigmaSlider =
            new DoubleJSlider(0, 5 * scale, (int) (maskingParams[3] * scale), scale);
        gaussGradSigmaSlider.setBounds(10, 363, 223, 23);
        panelParams1.add(gaussGradSigmaSlider);

        link(gaussGradSigmaSlider, gaussGradSigmaText);
        gaussGradSigmaSlider.addChangeListener(step3ChangeListener);
        gaussGradSigmaText.addKeyListener(step3KeyListener);
      }
    }

    final JPanel panelParams2 = new JPanel();
    {
      tabbedPane.addTab("Param set 2", panelParams2);
      panelParams2.setLayout(null);

      final JLabel lblMasking = new JLabel("4. Masking");
      lblMasking.setFont(BIG_FONT);
      lblMasking.setBounds(10, 11, 268, 29);
      panelParams2.add(lblMasking);

      {
        final JLabel gammeLabel = new JLabel("\u03B3: tanh shift");
        gammeLabel.setFont(SMALL_FONT);
        gammeLabel.setBounds(10, 51, 268, 14);
        panelParams2.add(gammeLabel);

        gammaSlider =
            new DoubleJSlider(-5 * scale, 5 * scale, (int) (maskingParams[4] * scale), scale);
        gammaSlider.setBounds(10, 76, 223, 23);
        panelParams2.add(gammaSlider);

        gammaText = new JFormattedTextField(new Double(maskingParams[4]));
        gammaText.setFont(FONT);
        gammaText.setBounds(243, 76, 35, 23);
        panelParams2.add(gammaText);

        link(gammaSlider, gammaText);
        gammaSlider.addChangeListener(step4ChangeListener);
        gammaSlider.addKeyListener(step4KeyListener);
      }
      {
        final JLabel lblNewLabel_3 = new JLabel("\u03B1: gradient prefactor");
        lblNewLabel_3.setFont(SMALL_FONT);
        lblNewLabel_3.setBounds(10, 110, 268, 14);
        panelParams2.add(lblNewLabel_3);

        alphaSlider = new DoubleJSlider(0, 20 * scale, (int) (maskingParams[5] * scale), scale);
        alphaSlider.setBounds(10, 135, 223, 23);
        panelParams2.add(alphaSlider);

        alphaText = new JFormattedTextField(new Double(maskingParams[5]));
        alphaText.setFont(FONT);
        alphaText.setBounds(243, 135, 35, 23);
        panelParams2.add(alphaText);

        link(alphaSlider, alphaText);
        alphaSlider.addChangeListener(step4ChangeListener);
        alphaText.addKeyListener(step4KeyListener);
      }
      {
        final JLabel betaLabel = new JLabel("\u03B2: positive laplacian magnitude prefactor");
        betaLabel.setFont(SMALL_FONT);
        betaLabel.setBounds(10, 169, 268, 14);
        panelParams2.add(betaLabel);

        betaSlider = new DoubleJSlider(0, 20 * scale, (int) (maskingParams[6] * scale), scale);
        betaSlider.setBounds(10, 194, 223, 23);
        panelParams2.add(betaSlider);

        betaText = new JFormattedTextField(new Double(maskingParams[6]));
        betaText.setFont(FONT);
        betaText.setBounds(243, 194, 35, 23);
        panelParams2.add(betaText);

        link(betaSlider, betaText);
        betaSlider.addChangeListener(step4ChangeListener);
        betaText.addKeyListener(step4KeyListener);
      }
      {
        final JLabel epsilonLabel = new JLabel("\u03B5: negative hessian magnitude");
        epsilonLabel.setFont(SMALL_FONT);
        epsilonLabel.setBounds(10, 228, 268, 14);
        panelParams2.add(epsilonLabel);

        epsilonSlider = new DoubleJSlider(0, 20 * scale, (int) (scale * maskingParams[7]), scale);
        epsilonSlider.setBounds(10, 253, 223, 23);
        panelParams2.add(epsilonSlider);

        epsilonText = new JFormattedTextField(new Double(maskingParams[7]));
        epsilonText.setFont(FONT);
        epsilonText.setText("" + maskingParams[7]);
        epsilonText.setBounds(243, 253, 35, 23);
        panelParams2.add(epsilonText);

        link(epsilonSlider, epsilonText);
        epsilonSlider.addChangeListener(step4ChangeListener);
        epsilonText.addKeyListener(step4KeyListener);
      }
      {
        final JLabel deltaLabel = new JLabel("\u03B4: derivatives sum scale");
        deltaLabel.setFont(SMALL_FONT);
        deltaLabel.setBounds(10, 287, 268, 14);
        panelParams2.add(deltaLabel);

        deltaText = new JFormattedTextField(new Double(maskingParams[8]));
        deltaText.setFont(FONT);
        deltaText.setText("" + maskingParams[8]);
        deltaText.setBounds(243, 312, 35, 23);
        panelParams2.add(deltaText);

        deltaSlider = new DoubleJSlider(0, 5 * scale, (int) (maskingParams[8] * scale), scale);
        deltaSlider.setBounds(10, 312, 223, 23);
        panelParams2.add(deltaSlider);

        link(deltaSlider, deltaText);
        deltaSlider.addChangeListener(step4ChangeListener);
        deltaText.addKeyListener(step4KeyListener);
      }

      final JLabel lblEquation =
          new JLabel(
              "<html>M = \u00BD ( 1 + <i>tanh</i> ( \u03B3 - ( \u03B1 G + \u03B2 L + \u03B5 H ) / \u03B4 ) )</html>");
      lblEquation.setHorizontalAlignment(SwingConstants.CENTER);
      lblEquation.setFont(FONT.deriveFont(12f));
      lblEquation.setBounds(10, 364, 268, 35);
      panelParams2.add(lblEquation);
    }

    {
      final JPanel panel = new JPanel();
      tabbedPane.addTab("Param set 3", null, panel, null);
      panel.setLayout(null);

      final JLabel labelThresholding = new JLabel("5. Thresholding");
      labelThresholding.setBounds(10, 11, 268, 28);
      labelThresholding.setFont(BIG_FONT);
      panel.add(labelThresholding);

      final JLabel labelThresholdFactor = new JLabel("Threshold factor:");
      labelThresholdFactor.setFont(SMALL_FONT);
      labelThresholdFactor.setBounds(10, 50, 268, 14);
      panel.add(labelThresholdFactor);

      thresholdFactorSlider =
          new DoubleJSlider(0, 5 * scale, (int) (thresholdFactor * scale), scale);
      thresholdFactorSlider.setBounds(10, 75, 223, 23);
      panel.add(thresholdFactorSlider);

      thresholdFactorText = new JFormattedTextField(new Double(thresholdFactor));
      thresholdFactorText.setFont(FONT);
      thresholdFactorText.setBounds(243, 75, 35, 23);
      panel.add(thresholdFactorText);

      link(thresholdFactorSlider, thresholdFactorText);
      thresholdFactorSlider.addChangeListener(step5ChangeListener);
      thresholdFactorText.addKeyListener(step5KeyListener);
    }
  }
Exemplo n.º 2
0
  /** Create the frame. */
  public Calculator() {
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 384, 259);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new BorderLayout(7, 3));

    displayField = new JFormattedTextField();
    displayField.setFont(new Font("Tahoma", Font.PLAIN, 14));
    displayField.setPreferredSize(new Dimension(6, 30));
    displayField.setMinimumSize(new Dimension(10, 10));
    displayField.setEditable(false);
    displayField.setHorizontalAlignment(SwingConstants.RIGHT);
    contentPane.add(displayField, BorderLayout.NORTH);

    JPanel panel = new JPanel();
    contentPane.add(panel, BorderLayout.CENTER);
    panel.setLayout(new GridLayout(4, 3, 3, 3));

    CalculatorActionsListener calcListener = new CalculatorActionsListener(this);

    JButton btnNewButton7 = new JButton("7");
    btnNewButton7.setFont(new Font("Tahoma", Font.PLAIN, 14));
    btnNewButton7.setSize(new Dimension(25, 23));
    btnNewButton7.setMaximumSize(new Dimension(23, 23));
    btnNewButton7.setPreferredSize(new Dimension(25, 23));
    panel.add(btnNewButton7);
    btnNewButton7.addActionListener(calcListener);

    JButton btnNewButton8 = new JButton("8");
    btnNewButton8.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton8);
    btnNewButton8.addActionListener(calcListener);

    JButton btnNewButton9 = new JButton("9");
    btnNewButton9.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton9);
    btnNewButton9.addActionListener(calcListener);

    JButton btnNewButton4 = new JButton("4");
    btnNewButton4.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton4);
    btnNewButton4.addActionListener(calcListener);

    JButton btnNewButton5 = new JButton("A");
    btnNewButton5.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton5);
    btnNewButton5.addActionListener(calcListener);

    JButton btnNewButton6 = new JButton("6");
    btnNewButton6.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton6);
    btnNewButton6.addActionListener(calcListener);

    JButton btnNewButton1 = new JButton("1");
    btnNewButton1.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton1);
    btnNewButton1.addActionListener(calcListener);

    JButton btnNewButton2 = new JButton("2");
    btnNewButton2.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton2);
    btnNewButton2.addActionListener(calcListener);

    JButton btnNewButton3 = new JButton("3");
    btnNewButton3.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButton3);
    btnNewButton3.addActionListener(calcListener);

    JButton btnNewButtonZero = new JButton("0");
    btnNewButtonZero.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonZero);
    btnNewButtonZero.addActionListener(calcListener);

    JButton btnNewButtonDot = new JButton(".");
    btnNewButtonDot.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonDot);
    btnNewButtonDot.addActionListener(calcListener);

    btnNewButtonEqual = new JButton("=");
    btnNewButtonEqual.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel.add(btnNewButtonEqual);
    btnNewButtonEqual.addActionListener(calcListener);

    JPanel panel_1 = new JPanel();
    panel_1.setPreferredSize(new Dimension(80, 10));
    panel_1.setBounds(new Rectangle(5, 5, 5, 5));
    contentPane.add(panel_1, BorderLayout.EAST);
    panel_1.setLayout(new GridLayout(4, 1, 3, 3));

    btnNewButtonDiv = new JButton("/");
    btnNewButtonDiv.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonDiv);
    btnNewButtonDiv.addActionListener(calcListener);

    btnNewButtonMult = new JButton("*");
    btnNewButtonMult.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonMult);
    btnNewButtonMult.addActionListener(calcListener);

    btnNewButtonSub = new JButton("-");
    btnNewButtonSub.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonSub);
    btnNewButtonSub.addActionListener(calcListener);

    btnNewButtonAdd = new JButton("+");
    btnNewButtonAdd.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panel_1.add(btnNewButtonAdd);
    btnNewButtonAdd.addActionListener(calcListener);
  }
Exemplo n.º 3
0
  /** Initialize */
  @Override
  public void init() {
    //	Content
    MigLayout layout = new MigLayout("ins 0 0", "[fill|fill|fill|fill]", "[nogrid]unrel[||]");
    setLayout(layout);

    Font bigFont = AdempierePLAF.getFont_Field().deriveFont(16f);

    String buttonSize = "w 50!, h 50!,";
    // NEW
    f_bNew = createButtonAction("New", KeyStroke.getKeyStroke(KeyEvent.VK_F2, Event.F2));
    add(f_bNew, buttonSize);

    // EDIT
    f_bEdit = createButtonAction("Edit", null);
    add(f_bEdit, buttonSize);
    f_bEdit.setEnabled(false);

    // HISTORY
    f_history = createButtonAction("History", null);
    add(f_history, buttonSize);

    // CANCEL
    f_process = createButtonAction("Cancel", null);
    add(f_process, buttonSize);
    f_process.setEnabled(false);

    // PAYMENT
    f_cashPayment = createButtonAction("Payment", null);
    f_cashPayment.setActionCommand("Cash");
    add(f_cashPayment, buttonSize);
    f_cashPayment.setEnabled(false);

    // PRINT
    f_print = createButtonAction("Print", null);
    add(f_print, buttonSize);
    f_print.setEnabled(false);

    // Settings
    f_bSettings = createButtonAction("Preference", null);
    add(f_bSettings, buttonSize);

    //
    f_logout = createButtonAction("Logout", null);
    add(f_logout, buttonSize + ", gapx 25, wrap");

    // DOC NO
    add(new CLabel(Msg.getMsg(Env.getCtx(), "DocumentNo")), "");

    f_DocumentNo = new CTextField("");
    f_DocumentNo.setName("DocumentNo");
    f_DocumentNo.setEditable(false);
    add(f_DocumentNo, "growx, pushx");

    CLabel lNet = new CLabel(Msg.translate(Env.getCtx(), "SubTotal"));
    add(lNet, "");
    f_net = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_net.setHorizontalAlignment(JTextField.TRAILING);
    f_net.setEditable(false);
    f_net.setFocusable(false);
    lNet.setLabelFor(f_net);
    add(f_net, "wrap, growx, pushx");
    f_net.setValue(Env.ZERO);
    //

    /*
    	// BPARTNER
    	f_bSearch = createButtonAction ("BPartner", KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.SHIFT_MASK+Event.CTRL_MASK));
    	add (f_bSearch,buttonSize + ", spany 2");
    */

    /*
     * f_name.setName("Name");
    f_name.addActionListener(this);
    f_name.addFocusListener(this);
    add (f_name, "wrap");
    */

    // SALES REP
    add(new CLabel(Msg.translate(Env.getCtx(), "SalesRep_ID")), "");
    f_RepName = new CTextField("");
    f_RepName.setName("SalesRep");
    f_RepName.setEditable(false);
    add(f_RepName, "growx, pushx");

    CLabel lTax = new CLabel(Msg.translate(Env.getCtx(), "TaxAmt"));
    add(lTax);
    f_tax = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_tax.setHorizontalAlignment(JTextField.TRAILING);
    f_tax.setEditable(false);
    f_tax.setFocusable(false);
    lTax.setLabelFor(f_tax);
    add(f_tax, "wrap, growx, pushx");
    f_tax.setValue(Env.ZERO);
    //

    /*
    	f_location = new CComboBox();
    	add (f_location, " wrap");
    */

    // BP
    add(new CLabel(Msg.translate(Env.getCtx(), "C_BPartner_ID")), "");
    f_name = new CTextField();
    f_name.setEditable(false);
    f_name.setName("Name");
    add(f_name, "growx, pushx");

    //
    CLabel lTotal = new CLabel(Msg.translate(Env.getCtx(), "GrandTotal"));
    lTotal.setFont(bigFont);
    add(lTotal, "");
    f_total = new JFormattedTextField(DisplayType.getNumberFormat(DisplayType.Amount));
    f_total.setHorizontalAlignment(JTextField.TRAILING);
    f_total.setFont(bigFont);
    f_total.setEditable(false);
    f_total.setFocusable(false);
    lTotal.setLabelFor(f_total);
    add(f_total, "growx, pushx");
    f_total.setValue(Env.ZERO);
    /*
    //
    f_user = new CComboBox();
    add (f_user, "skip 1");
    */
  } //	init
Exemplo n.º 4
0
  Liqui(Connection LoginCN) {
    cn = LoginCN;
    liquiwindow = new JFrame("Liquistatus");
    liquiwindow.setSize(800, 560);
    liquiwindow.setLocation(200, 200);
    liquiwindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    liquiwindow.setLayout(null);
    liquiwindow.setResizable(false);

    // schriftenfestlegungen
    fontTxtFields = new Font("Arial", Font.PLAIN, 16);
    fontCmbBoxes = new Font("Arial", Font.PLAIN, 16);
    fontLists = new Font("Arial", Font.PLAIN, 10);

    pnlAbrMonat = new JPanel();
    pnlAbrMonat.setLayout(null);
    pnlAbrMonat.setBounds(30, 30, 150, 60);
    pnlAbrMonat.setBorder(new TitledBorder("Abrechnungsmonat"));
    // inhalt fuer Panel AbrMonat erstellen
    try {
      txtAbrMonat = new JFormattedTextField(new MaskFormatter("01-##-20##"));
    } catch (ParseException e1) {
      e1.printStackTrace();
    }
    txtAbrMonat.setBounds(20, 25, 110, 25);
    txtAbrMonat.setHorizontalAlignment(JFormattedTextField.RIGHT);
    txtAbrMonat.setFont(fontTxtFields);
    txtAbrMonat.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent ke) {}

          @Override
          public void keyReleased(KeyEvent ke) {
            if (ke.getKeyCode() == KeyEvent.VK_ENTER
                && Pattern.matches("\\d{2}.\\d{2}.[1-9]{1}\\d{3}", txtAbrMonat.getText())) {
              txtHinweis.setText(""); // clear txtHinweis Field
              lstModelAllIncome.clear(); // clear form old values from the previos call
              cmbModelPerson.removeAllElements(); // clear befor put new elements in to it
              calculate_profit(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));
              putPersonNameToCmbPerson();
              putIncomeToListAllIncome(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));

              // check if the actual liquimonth is already fix and it is so, then set the buttons,
              // who put and remove
              // incomes to and from persons, inactive
              if (is_liqui_fix(BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0))) {
                btnAdd.setEnabled(false);
                btnRemove.setEnabled(false);
              } else {
                btnAdd.setEnabled(true);
                btnRemove.setEnabled(true);
              }
            }
          }

          @Override
          public void keyPressed(KeyEvent ke) {}
        });
    // inhalte fuer das Panel AbrMonat auf selbiges legen
    pnlAbrMonat.add(txtAbrMonat);

    pnlRestwert = new JPanel();
    pnlRestwert.setLayout(null);
    pnlRestwert.setBounds(30, 115, 150, 60);
    pnlRestwert.setBorder(new TitledBorder("Monatsrestwert"));
    // inhalt fuer Panel Restwert erstellen
    txtNutzBetr = new JFormattedTextField(new NumberFormatter(new DecimalFormat("#,##0.00")));
    txtNutzBetr.setBounds(20, 25, 110, 25);
    txtNutzBetr.setHorizontalAlignment(JFormattedTextField.RIGHT);
    txtNutzBetr.setFont(fontTxtFields);
    txtNutzBetr.setText("0,00");
    txtNutzBetr.addFocusListener(
        new FocusListener() {
          public void focusLost(FocusEvent fe) {}

          public void focusGained(FocusEvent fe) {
            txtNutzBetr.selectAll();
          }
        });
    // inhalte fuer das Panel AbrMonat auf selbiges legen
    pnlRestwert.add(txtNutzBetr);

    // Textfeld fuer Hinweise zum errechneten Betrag
    txtHinweis = new JTextArea();
    txtHinweis.setBounds(195, 30, 230, 205);
    txtHinweis.setBorder(BorderFactory.createEtchedBorder());
    txtHinweis.setEditable(false); // infos sollen nur vom Programm gesetzt werden

    // Bereich fuer die Einnahmenaufteilung anlegen
    pnlEinahmenAufteilung = new JPanel();
    pnlEinahmenAufteilung.setLayout(null);
    pnlEinahmenAufteilung.setBounds(30, 240, 640, 300);
    pnlEinahmenAufteilung.setBorder(new TitledBorder("Einnahmenaufteilung"));
    // elemente fuer die Einnahmenaufteilung anlegen
    lblPerson = new JLabel("Person");
    lblPerson.setBounds(20, 25, 110, 25);

    cmbModelPerson = new DefaultComboBoxModel<String>();
    cmbPerson = new JComboBox<String>(cmbModelPerson);
    cmbPerson.setBounds(130, 25, 170, 25);
    cmbPerson.setFont(fontCmbBoxes);
    cmbPerson.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == 1) {
              // clear the List IncomePerPerson when Person is changed (to another or to nothing)
              lstModelIncomePerPerson.clear();

              if (cmbPerson.getSelectedIndex() > 0) {
                // extract personen_id from selected Value
                String selectedValue = cmbPerson.getSelectedItem().toString();
                Integer personen_id =
                    Integer.valueOf(
                        selectedValue.substring(
                            selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));

                // fill lstIncomePerPerson
                getIncomeForSelectedPerson(
                    personen_id, BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));
              }
            }
          }
        });

    // Scrollliste der gesammten Einnahmen
    lstModelAllIncome = new DefaultListModel<String>();

    lstAllIncome = new JList<String>(lstModelAllIncome);
    lstAllIncome.setFont(fontLists);
    lstAllIncome.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseExited(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {}

          @Override
          public void mouseClicked(MouseEvent e) {
            // do someone only when elements exist
            if (lstModelAllIncome.getSize() > 0) {
              String elementValue = lstModelAllIncome.getElementAt(lstAllIncome.getSelectedIndex());
              lblBuchtext.setToolTipText(
                  getBuchText(
                      elementValue.substring(
                          elementValue.indexOf("(") + 1, elementValue.indexOf(")"))));

              // chek if a splitted part of the transaktions_id of the selectet Value is already put
              // to a
              // person, if it is so, the checkbox split must checked and protect against unchecked
              if (existSplittedPartInIpp(
                  elementValue.substring(
                      elementValue.indexOf("(") + 1, elementValue.indexOf(")")))) {
                chkAufteilung.setSelected(true);
                chkAufteilung.setEnabled(false);
              } else {
                chkAufteilung.setSelected(false);
                chkAufteilung.setEnabled(true);
              }
            }
          }
        });

    spAllIncome = new JScrollPane(lstAllIncome);
    spAllIncome.setBounds(20, 65, 100, 205);

    // scrollliste der einnahmen pro Person
    lstModelIncomePerPerson = new DefaultListModel<String>();

    lstIncomPerPerson = new JList<String>(lstModelIncomePerPerson);
    lstIncomPerPerson.setFont(fontLists);

    spIncomePerPerson = new JScrollPane(lstIncomPerPerson);
    spIncomePerPerson.setBounds(220, 65, 100, 205);

    // checkbox fuer die Aufteilungskennzeichnung
    chkAufteilung = new JCheckBox("Split", false);
    chkAufteilung.setBounds(145, 70, 60, 30);

    // Buttons fuer das hinzufuegen und entfernen der Betraege zu den Personen
    btnAdd = new JButton(">>");
    btnAdd.setBounds(145, 130, 60, 20);
    btnAdd.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Integer AllIncomeSelectedIndex;
            Integer PersonSelectedIndex;

            // note important selected Index
            AllIncomeSelectedIndex = lstAllIncome.getSelectedIndex();
            PersonSelectedIndex = cmbPerson.getSelectedIndex();

            // move the selected field from lstAllIncome to lstIncomePerPerson
            if (AllIncomeSelectedIndex >= 0 && PersonSelectedIndex >= 1) {
              // note some selected Values
              String selectedValue = cmbPerson.getSelectedItem().toString();
              Integer personen_id =
                  Integer.valueOf(
                      selectedValue.substring(
                          selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));

              // get Selected Value from the AllIncomeList
              String selectedAmountWithKey = lstModelAllIncome.getElementAt(AllIncomeSelectedIndex);

              // extract transaktions_id from the selected Amountvalue
              Integer transaktions_id =
                  Integer.valueOf(
                      selectedAmountWithKey.substring(
                          selectedAmountWithKey.indexOf("(") + 1,
                          selectedAmountWithKey.indexOf(")")));
              String sAmount =
                  selectedAmountWithKey.substring(0, selectedAmountWithKey.indexOf(" ("));

              // check if Amount have to split and get the Person_id who get the splited Amount
              if (chkAufteilung.isSelected()) {
                String AmountPart =
                    JOptionPane.showInputDialog(
                        "Bitte den Teilbetrag von " + sAmount + " eingeben:", sAmount);
                AmountPart = AmountPart.replace(",", ".");
                if (AmountPart.matches("^[0-9]+(\\.[0-9]{1,2})?$")) {
                  lstModelIncomePerPerson.insertElementAt(
                      AmountPart + " (" + transaktions_id + ")", lstModelIncomePerPerson.getSize());

                  // remove old Amount Value from List AllIncome
                  lstModelAllIncome.remove(AllIncomeSelectedIndex);

                  // calculate the diffrence between Old Amount and the AmountPart
                  Float AmountAllIncomeNew = Float.valueOf(sAmount) - Float.valueOf(AmountPart);

                  // put difference in the List AllIncome if it greater then zero
                  if (AmountAllIncomeNew > 0)
                    lstModelAllIncome.insertElementAt(
                        AmountAllIncomeNew.toString() + " (" + transaktions_id + ")",
                        lstModelAllIncome.getSize());

                  // put AmountPart in the IPP Table
                  pushAmountToTableIPP(AmountPart, transaktions_id, personen_id, "true");
                } else {
                  JOptionPane.showMessageDialog(
                      liquiwindow,
                      "Eingabe ist kein gültiger Zahlwert! Der Gesamtbetrag wird genommen.");
                  lstModelIncomePerPerson.insertElementAt(
                      selectedAmountWithKey, lstModelIncomePerPerson.getSize());
                  lstModelAllIncome.remove(AllIncomeSelectedIndex);
                  pushAmountToTableIPP(sAmount, transaktions_id, personen_id, "false");
                }
              } else {
                lstModelIncomePerPerson.insertElementAt(
                    selectedAmountWithKey, lstModelIncomePerPerson.getSize());
                lstModelAllIncome.remove(AllIncomeSelectedIndex);
                pushAmountToTableIPP(sAmount, transaktions_id, personen_id, "false");
              }
            }
          }
        });

    btnRemove = new JButton("<<");
    btnRemove.setBounds(145, 175, 60, 20);
    btnRemove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Integer IncomePerPersonSelectedIndex;
            Integer PersonSelectedIndex;
            Boolean transaktions_id_is_in_elements = false;
            int eID =
                0; // counter for the elements in the Enumeration to find an element with the same
                   // transaktions_id

            // note important selected Indexes
            IncomePerPersonSelectedIndex = lstIncomPerPerson.getSelectedIndex();
            PersonSelectedIndex = cmbPerson.getSelectedIndex();

            // move the selected field from lstIncomePerPerson to lstAllIncome
            if (IncomePerPersonSelectedIndex >= 0 && PersonSelectedIndex >= 1) {
              String selectedPersonAmountWithKey =
                  lstModelIncomePerPerson.getElementAt(IncomePerPersonSelectedIndex);

              // note the transaktions_id from the selectet Value at the right site
              String transaktions_id_right_site =
                  selectedPersonAmountWithKey.substring(
                      selectedPersonAmountWithKey.indexOf("(") + 1,
                      selectedPersonAmountWithKey.indexOf(")"));

              // check if the transaktions_id from the element that remove from the
              // IncomPerPerson List at the right site, is alredy in the list AllIncome at the
              // left Site. If it is so, then we must add the amount of the elements at the left
              // side to the right
              // where the transaktions_id is the same
              Enumeration<String> e = lstModelAllIncome.elements();

              while (e.hasMoreElements() && !transaktions_id_is_in_elements) {
                // note the actual Elemant in the Enumeration
                String actualElement = e.nextElement().toString();

                // note the transaktions_id from the actual element at the left site
                String transaktions_id_left_site =
                    actualElement.substring(
                        actualElement.indexOf("(") + 1, actualElement.indexOf(")"));

                if (transaktions_id_right_site.equals(transaktions_id_left_site)) {
                  // we need not look further and set transaktions_id_is_in_elements to true
                  // that will break the while loop
                  transaktions_id_is_in_elements = true;
                } else {
                  transaktions_id_is_in_elements = false;
                  eID++;
                }
              }

              if (transaktions_id_is_in_elements) {
                // if found an element with the same id in the left field, add the amount of the
                // removed
                // element at the right site, to the amount of the found element and put the result
                // at the end of the listAllIncome

                // note the two Amounts that have to add
                String AmountFromRightSite =
                    selectedPersonAmountWithKey.substring(
                        0, selectedPersonAmountWithKey.indexOf(" ("));
                String AmountFromLeftSite =
                    lstModelAllIncome
                        .getElementAt(eID)
                        .substring(0, lstModelAllIncome.getElementAt(eID).indexOf(" ("));
                Float newAmount =
                    Float.valueOf(AmountFromRightSite) + Float.valueOf(AmountFromLeftSite);

                // remove the element at the right and the left site
                lstModelIncomePerPerson.remove(IncomePerPersonSelectedIndex);
                lstModelAllIncome.remove(eID);

                // put the new build Element to the left site
                lstModelAllIncome.insertElementAt(
                    newAmount + " (" + transaktions_id_right_site + ")",
                    lstModelAllIncome.getSize());
              } else {
                // if not found, only put the removed Elemnt to the end of the List at the left site
                lstModelAllIncome.insertElementAt(
                    selectedPersonAmountWithKey, lstModelAllIncome.getSize());
                lstModelIncomePerPerson.remove(IncomePerPersonSelectedIndex);
              }

              // delete the moved Amount in the Table ipp for the selected Person
              String selectedValue = cmbPerson.getSelectedItem().toString();
              Integer personen_id =
                  Integer.valueOf(
                      selectedValue.substring(
                          selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));
              deleteAmountFromTableIPP(selectedPersonAmountWithKey, personen_id);
            }
          }
        });

    lblBuchtext = new JLabel("Buchungstext (Tooltip)");
    lblBuchtext.setBounds(20, 275, 300, 20);

    btnCalcPercentualPortion = new JButton("Anteilberechnung");
    btnCalcPercentualPortion.setBounds(330, 65, 160, 20);
    btnCalcPercentualPortion.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            int personCount;
            double[] PersonAmount;
            double TotalPersonAmount = 0;

            // clear the infotextfield
            txtHinweisAufteilung.setText("");

            // note the amount of person in the cmb box person
            // the first entry is not a person
            personCount = cmbModelPerson.getSize() - 1;

            // sum up the acounts of each person if there are one
            if (personCount > 0) {
              PersonAmount = new double[personCount];
              double dResidualValue = Double.valueOf(txtNutzBetr.getText().replace(",", "."));

              for (int PersonCounter = 1; PersonCounter <= personCount; PersonCounter++) {
                String selectedValue = cmbPerson.getItemAt(PersonCounter).toString();
                Integer personen_id =
                    Integer.valueOf(
                        selectedValue.substring(
                            selectedValue.indexOf("(") + 1, selectedValue.indexOf(")")));

                PersonAmount[PersonCounter - 1] =
                    getPersonAcountSumPerLiqui(
                        personen_id, BigOneTools.datum_wandeln(txtAbrMonat.getText(), 0));
                TotalPersonAmount =
                    roundScale2(TotalPersonAmount + PersonAmount[PersonCounter - 1]);
              }

              // hint the total sum of all person
              txtHinweisAufteilung.append("Gesammtsumme:\n");
              txtHinweisAufteilung.append(
                  Double.toString(TotalPersonAmount).replace(".", ",") + "\n");

              // calc the proportion of the sums in percent, to the total Sum of all persons
              txtHinweisAufteilung.append(
                  "Sparbetrag: " + Double.toString(dResidualValue).replace(".", ",") + "\n");
              for (int PersonCounter = 0; PersonCounter < PersonAmount.length; PersonCounter++) {
                double percent =
                    roundScale2((PersonAmount[PersonCounter] * 100) / TotalPersonAmount);
                double dValue = roundScale2((percent * dResidualValue) / 100);
                txtHinweisAufteilung.append(
                    Double.toString(percent).replace(".", ",")
                        + "% / "
                        + Double.toString(dValue).replace(".", ",")
                        + "\n");
              }
            }
          }
        });

    // Textfeld fuer Hinweise zum errechneten Betrag
    txtHinweisAufteilung = new JTextArea();
    txtHinweisAufteilung.setBounds(330, 90, 180, 180);
    txtHinweisAufteilung.setBorder(BorderFactory.createEtchedBorder());
    txtHinweisAufteilung.setEditable(false); // infos sollen nur vom Programm gesetzt werden

    // zuweisen der Elemente fuer das Panel Einnahmenaufteilung
    pnlEinahmenAufteilung.add(lblPerson);
    pnlEinahmenAufteilung.add(cmbPerson);
    pnlEinahmenAufteilung.add(spAllIncome);
    pnlEinahmenAufteilung.add(spIncomePerPerson);
    pnlEinahmenAufteilung.add(chkAufteilung);
    pnlEinahmenAufteilung.add(btnAdd);
    pnlEinahmenAufteilung.add(btnRemove);
    pnlEinahmenAufteilung.add(lblBuchtext);
    pnlEinahmenAufteilung.add(btnCalcPercentualPortion);
    pnlEinahmenAufteilung.add(txtHinweisAufteilung);

    liquiwindow.add(pnlAbrMonat);
    liquiwindow.add(pnlRestwert);
    liquiwindow.add(txtHinweis);
    liquiwindow.add(pnlEinahmenAufteilung);

    liquiwindow.setVisible(true);
  }
Exemplo n.º 5
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();
    }
  }
Exemplo n.º 6
0
  /** Create the frame. */
  public GIncidencia() {

    setIconImage(
        Toolkit.getDefaultToolkit()
            .getImage(
                GIncidencia.class.getResource("/javax/swing/plaf/basic/icons/JavaCup16.png")));
    setResizable(false);
    setTitle("  Ingresar Nueva GIncidencia");
    setBounds(100, 100, 887, 575);
    getContentPane().setLayout(null);

    lblMensListado2 = new JLabel("");
    lblMensListado2.setFont(new Font("Tahoma", Font.PLAIN, 13));
    lblMensListado2.setVisible(false);
    lblMensListado2.setBounds(349, 64, 346, 19);
    getContentPane().add(lblMensListado2);

    lblMensListado1 = new JLabel("");
    lblMensListado1.setVisible(false);
    lblMensListado1.setFont(new Font("Tahoma", Font.PLAIN, 13));
    lblMensListado1.setBounds(10, 64, 319, 19);
    getContentPane().add(lblMensListado1);

    panel = new JPanel();
    panel.setVisible(false);
    panel.setBounds(10, 11, 319, 515);
    panel.setBackground(new Color(51, 102, 153));
    panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    getContentPane().add(panel);
    panel.setLayout(null);

    btnListado = new JButton("LISTAR");
    btnListado.setVisible(false);
    btnListado.setBackground(SystemColor.controlShadow);
    btnListado.addActionListener(this);
    btnListado.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource("/com/sun/java/swing/plaf/motif/icons/Warn.gif")));

    Incidencia = new JScrollPane();
    Incidencia.setVisible(false);
    Incidencia.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
    Incidencia.setBounds(339, 103, 522, 388);
    getContentPane().add(Incidencia);

    txtIncidencia = new JTextArea();
    txtIncidencia.setFont(new Font("Arial", Font.PLAIN, 17));
    txtIncidencia.setToolTipText("");
    Incidencia.setViewportView(txtIncidencia);

    btnLimpiar = new JButton("LIMPIAR");
    btnLimpiar.setVisible(false);

    btnBuscar = new JButton("BUSCAR");
    btnBuscar.setVisible(false);

    btnNuevo = new JButton("NUEVO");
    btnNuevo.setVisible(false);
    btnNuevo.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource("/com/sun/java/swing/plaf/windows/icons/File.gif")));
    btnNuevo.setBackground(SystemColor.controlShadow);
    btnNuevo.setBounds(339, 11, 228, 33);
    getContentPane().add(btnNuevo);

    btnNuevo.addActionListener(this);
    btnBuscar.setBackground(SystemColor.controlShadow);
    btnBuscar.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource("/com/sun/java/swing/plaf/windows/icons/Directory.gif")));
    btnBuscar.setBounds(339, 11, 228, 33);
    getContentPane().add(btnBuscar);
    btnBuscar.addActionListener(this);
    btnLimpiar.setIcon(
        new ImageIcon(GIncidencia.class.getResource("/javax/swing/plaf/metal/icons/sortDown.png")));
    btnLimpiar.setBackground(SystemColor.controlShadow);
    btnLimpiar.setBounds(633, 11, 228, 33);
    getContentPane().add(btnLimpiar);
    btnLimpiar.addActionListener(this);

    btnRegistrar = new JButton("REGISTRAR");
    btnRegistrar.setVisible(false);
    btnRegistrar.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource(
                "/com/sun/javafx/webkit/prism/resources/mediaPlayDisabled.png")));
    btnRegistrar.setBackground(SystemColor.controlShadow);
    btnRegistrar.setBounds(339, 55, 522, 37);
    getContentPane().add(btnRegistrar);
    btnRegistrar.addActionListener(this);

    btnModificar = new JButton("MODIFICAR");
    btnModificar.setVisible(false);
    btnModificar.setIcon(
        new ImageIcon(
            GIncidencia.class.getResource(
                "/com/sun/javafx/scene/control/skin/caspian/dialog-more-details.png")));
    btnModificar.setBackground(SystemColor.controlShadow);
    btnModificar.setBounds(339, 55, 522, 37);
    getContentPane().add(btnModificar);
    btnModificar.addActionListener(this);
    btnListado.setBounds(10, 11, 260, 37);
    getContentPane().add(btnListado);

    JSeparator separator = new JSeparator();
    separator.setBounds(10, 111, 299, 7);
    panel.add(separator);

    JSeparator separator_1 = new JSeparator();
    separator_1.setBounds(10, 294, 299, 14);
    panel.add(separator_1);

    JLabel lblNewLabel = new JLabel("CODIGO DE USUARIO:");
    lblNewLabel.setForeground(Color.WHITE);
    lblNewLabel.setBounds(10, 36, 172, 14);
    panel.add(lblNewLabel);

    JLabel lblCodigo = new JLabel("CODIGO DE INCIDENCIA: ");
    lblCodigo.setForeground(Color.WHITE);
    lblCodigo.setBounds(10, 11, 172, 14);
    panel.add(lblCodigo);

    txtCodigo = new JTextField();
    txtCodigo.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtCodigo.setHorizontalAlignment(SwingConstants.RIGHT);
    txtCodigo.setBackground(SystemColor.controlShadow);
    txtCodigo.setEditable(false);
    txtCodigo.setBounds(203, 9, 106, 17);
    panel.add(txtCodigo);
    txtCodigo.setColumns(10);

    txtCodUsu = new JTextField();
    txtCodUsu.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtCodUsu.setHorizontalAlignment(SwingConstants.RIGHT);
    txtCodUsu.setBackground(SystemColor.controlShadow);
    txtCodUsu.setEditable(false);
    txtCodUsu.setColumns(10);
    txtCodUsu.setBounds(203, 34, 106, 17);
    panel.add(txtCodUsu);

    JLabel lblCodigoDeEspecialista = new JLabel("CODIGO DE ESPECIALISTA:");
    lblCodigoDeEspecialista.setForeground(Color.WHITE);
    lblCodigoDeEspecialista.setBounds(10, 61, 172, 14);
    panel.add(lblCodigoDeEspecialista);

    JLabel lblCodigoDeTipo = new JLabel("CODIGO DE TIPO DE INCIDENCIA:");
    lblCodigoDeTipo.setForeground(Color.WHITE);
    lblCodigoDeTipo.setBounds(10, 86, 188, 14);
    panel.add(lblCodigoDeTipo);

    JLabel lblDescripcion = new JLabel("DESCRIPCION:");
    lblDescripcion.setForeground(Color.WHITE);
    lblDescripcion.setBounds(10, 115, 110, 14);
    panel.add(lblDescripcion);

    JLabel lblComentariosObservaciones = new JLabel("COMENTARIOS / OBSERVACIONES:");
    lblComentariosObservaciones.setForeground(Color.WHITE);
    lblComentariosObservaciones.setBounds(10, 198, 188, 28);
    panel.add(lblComentariosObservaciones);

    JLabel lblTiempoEstimadoDe = new JLabel("TIEMPO ESTIMADO DE SOLUCION:");
    lblTiempoEstimadoDe.setForeground(Color.WHITE);
    lblTiempoEstimadoDe.setBounds(10, 309, 203, 14);
    panel.add(lblTiempoEstimadoDe);

    txtTiempoEstimado = new JTextField();
    txtTiempoEstimado.addKeyListener(this);
    txtTiempoEstimado.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtTiempoEstimado.setHorizontalAlignment(SwingConstants.RIGHT);
    txtTiempoEstimado.setColumns(10);
    txtTiempoEstimado.setBounds(215, 306, 94, 17);
    panel.add(txtTiempoEstimado);

    JLabel lblTiempoRealDe = new JLabel("TIEMPO REAL DE SOLUCION:");
    lblTiempoRealDe.setForeground(Color.WHITE);
    lblTiempoRealDe.setBounds(10, 337, 172, 14);
    panel.add(lblTiempoRealDe);

    txtTiempoReal = new JTextField();
    txtTiempoReal.addKeyListener(this);
    txtTiempoReal.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtTiempoReal.setHorizontalAlignment(SwingConstants.RIGHT);
    txtTiempoReal.setColumns(10);
    txtTiempoReal.setBounds(215, 334, 94, 17);
    panel.add(txtTiempoReal);

    JLabel lblFechaDeRegistro = new JLabel("FECHA DE REGISTRO:");
    lblFechaDeRegistro.setForeground(Color.WHITE);
    lblFechaDeRegistro.setBounds(10, 365, 172, 14);
    panel.add(lblFechaDeRegistro);

    txtFecRegistro = new JTextField();
    txtFecRegistro.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtFecRegistro.setHorizontalAlignment(SwingConstants.RIGHT);
    txtFecRegistro.setBackground(SystemColor.controlShadow);
    txtFecRegistro.setEditable(false);
    txtFecRegistro.setColumns(10);
    txtFecRegistro.setBounds(181, 362, 128, 17);
    panel.add(txtFecRegistro);

    JLabel lblFechaDeInicio = new JLabel("FECHA DE INICIO DE ATENCION:");
    lblFechaDeInicio.setForeground(Color.WHITE);
    lblFechaDeInicio.setBounds(10, 393, 188, 14);
    panel.add(lblFechaDeInicio);

    try {
      MaskFormatter mascara = new MaskFormatter("##-##-####");
      mascara.setPlaceholderCharacter(' ');
      txtFecInicio = new JFormattedTextField(mascara);
      txtFecInicio.setHorizontalAlignment(SwingConstants.RIGHT);
      txtFecInicio.setFont(new Font("Tahoma", Font.PLAIN, 13));
      txtFecInicio.setBounds(215, 390, 100, 17);
      panel.add(txtFecInicio);
    } catch (Exception e) {
      e.printStackTrace();
    }

    JLabel lblFechaDeFin = new JLabel("FECHA FINAL DE ATENCION:");
    lblFechaDeFin.setForeground(Color.WHITE);
    lblFechaDeFin.setBounds(10, 421, 172, 14);
    panel.add(lblFechaDeFin);

    try {
      MaskFormatter mascara = new MaskFormatter("##-##-####");
      mascara.setPlaceholderCharacter(' ');
      txtFecFinal = new JFormattedTextField(mascara);
      txtFecFinal.setHorizontalAlignment(SwingConstants.RIGHT);
      txtFecFinal.setFont(new Font("Tahoma", Font.PLAIN, 13));
      txtFecFinal.setBounds(215, 418, 100, 17);
      panel.add(txtFecFinal);
    } catch (Exception e) {
      e.printStackTrace();
    }

    JLabel lblEstado = new JLabel("ESTADO:");
    lblEstado.setForeground(Color.WHITE);
    lblEstado.setBounds(10, 449, 86, 14);
    panel.add(lblEstado);

    cboEstado = new JComboBox();
    cboEstado.setFont(new Font("Tahoma", Font.PLAIN, 13));
    cboEstado.setBackground(UIManager.getColor("Button.background"));
    cboEstado.setModel(
        new DefaultComboBoxModel(new String[] {"Registrada", "Iniciada", "Cancelada", "Cerrada"}));
    cboEstado.setBounds(137, 446, 172, 20);
    panel.add(cboEstado);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(10, 129, 299, 69);
    panel.add(scrollPane_1);

    txtDescripcion = new JTextArea();
    txtDescripcion.addKeyListener(this);
    txtDescripcion.setFont(new Font("Arial", Font.PLAIN, 19));
    scrollPane_1.setViewportView(txtDescripcion);

    JScrollPane scrollPane_2 = new JScrollPane();
    scrollPane_2.setBounds(10, 220, 299, 69);
    panel.add(scrollPane_2);

    txtObservacion = new JTextArea();
    txtObservacion.addKeyListener(this);
    txtObservacion.setFont(new Font("Arial", Font.PLAIN, 19));
    scrollPane_2.setViewportView(txtObservacion);

    cboEspecialista = new JComboBox();
    cboEspecialista.setFont(new Font("Tahoma", Font.PLAIN, 13));
    cboEspecialista.setBounds(203, 58, 106, 20);
    cboEspecialista.addItem("");
    panel.add(cboEspecialista);

    cboTipoInc = new JComboBox();
    cboTipoInc.setFont(new Font("Tahoma", Font.PLAIN, 13));
    cboTipoInc.setBounds(203, 83, 106, 20);
    cboTipoInc.addItem("");
    panel.add(cboTipoInc);

    btnImprimir = new JButton("IMPRIMIR");
    btnImprimir.addActionListener(this);
    btnImprimir.setIcon(
        new ImageIcon(GIncidencia.class.getResource("/sun/print/resources/orientLandscape.png")));
    btnImprimir.setBounds(633, 493, 228, 33);
    getContentPane().add(btnImprimir);

    Listado = new JScrollPane(TablaIncidencias);
    Listado.setVisible(false);
    Listado.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
    JViewport viewport = new JViewport();
    Listado.setRowHeaderView(viewport);
    Listado.setBounds(10, 99, 861, 347);
    getContentPane().add(Listado);

    TablaIncidencias = new JTable();
    TablaIncidencias.setFont(new Font("Tahoma", Font.PLAIN, 13));
    TablaIncidencias.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    Listado.setViewportView(TablaIncidencias);
    columnas();
    tamañoColumnas();

    llenaCampos();
  }
  @Override
  public void installUI(JComponent c) {
    super.installUI(c);

    textFormattedField = (JFormattedTextField) c;

    textFormattedField.setFocusable(true);
    textFormattedField.setOpaque(false);
    textFormattedField.setMargin(new Insets(0, 0, 0, 0));
    textFormattedField.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    textFormattedField.setFont(AdobeLookAndFeel.fontBold);
    textFormattedField.setForeground(AdobeLookAndFeel.colorText);
    textFormattedField.setSelectionColor(new Color(100, 100, 100));
    textFormattedField.setCaretColor(AdobeLookAndFeel.colorText);

    mouseAdapter =
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent e) {
            textFormattedField.repaint();
          }

          @Override
          public void mousePressed(MouseEvent e) {
            textFormattedField.repaint();
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            textFormattedField.repaint();
          }
        };
    textFormattedField.addMouseListener(mouseAdapter);

    keyAdapter =
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            textFormattedField.repaint();
          }
        };
    textFormattedField.addKeyListener(keyAdapter);

    focusListener =
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            textFormattedField.repaint();
          }

          @Override
          public void focusLost(FocusEvent e) {
            textFormattedField.repaint();
          }
        };
    textFormattedField.addFocusListener(focusListener);

    propertyChangeListener =
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            textFormattedField.repaint();
          }
        };
    textFormattedField.addPropertyChangeListener(
        AccessibleContext.ACCESSIBLE_STATE_PROPERTY, propertyChangeListener);
  }
Exemplo n.º 8
0
  public DefaultDnDSupport() {
    JFrame fen = new JFrame("DnD et CCP");
    fen.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER));
    fen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Panel gauche
    JPanel panelgauche = new JPanel();
    panelgauche.setLayout(new BoxLayout(panelgauche, BoxLayout.Y_AXIS));

    // JTextField
    JTextField textField = new JTextField(10);
    textField.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JTextField"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    textField.setDragEnabled(true);

    // JPasswordField
    JPasswordField passwordField = new JPasswordField(10);
    passwordField.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JPasswordField"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    passwordField.setDragEnabled(true);

    // JFormattedTextField
    JFormattedTextField ftf = new JFormattedTextField("Universite de Lille 1");
    ftf.setFont(new Font("Courier", Font.ITALIC, 12));
    ftf.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JFormattedTextField"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    ftf.setDragEnabled(true);

    // JTextArea
    JTextArea jta = new JTextArea("Master 1 informatique");
    jta.setFont(new Font("Arial", Font.BOLD, 12));
    jta.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JTextArea"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    jta.setDragEnabled(true);

    // JEditorPane
    JEditorPane editorPane = createEditorPane();
    editorPane.setDragEnabled(true);
    JScrollPane editorScrollPane = new JScrollPane(editorPane);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JEditorPane"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // JColorChooser
    JColorChooser cc = new JColorChooser();
    cc.setDragEnabled(true);
    cc.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JColorChooser"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Panel droit
    JPanel paneldroit = new JPanel();
    paneldroit.setLayout(new BoxLayout(paneldroit, BoxLayout.Y_AXIS));

    // JList
    String[] data = {
      "AAC", "AEV", "ANG", "ASE", "COA", "PJE", "CAR", "PJI", "AeA", "BDA", "CALP", "FDD", "HECI",
      "IHM", "M3DS", "PAC", "PPD", "RdF", "SVL", "TI"
    };
    JList liste = new JList(data);
    JScrollPane jscrollListe = new JScrollPane(liste);
    jscrollListe.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JList"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    // liste.setDragEnabled(true);

    // JTree
    DefaultMutableTreeNode m1 = new DefaultMutableTreeNode("M1");
    DefaultMutableTreeNode s1 = new DefaultMutableTreeNode("S1");
    m1.add(s1);
    s1.add(new DefaultMutableTreeNode("AAC"));
    s1.add(new DefaultMutableTreeNode("AEV"));
    s1.add(new DefaultMutableTreeNode("ANG"));
    s1.add(new DefaultMutableTreeNode("ASE"));
    s1.add(new DefaultMutableTreeNode("COA"));
    s1.add(new DefaultMutableTreeNode("PJE"));
    DefaultMutableTreeNode s2 = new DefaultMutableTreeNode("S2");
    m1.add(s2);
    s2.add(new DefaultMutableTreeNode("CAR"));
    s2.add(new DefaultMutableTreeNode("PJI"));
    s2.add(new DefaultMutableTreeNode("AeA"));
    s2.add(new DefaultMutableTreeNode("BDA"));
    s2.add(new DefaultMutableTreeNode("CALP"));
    s2.add(new DefaultMutableTreeNode("FDD"));
    s2.add(new DefaultMutableTreeNode("HECI"));
    s2.add(new DefaultMutableTreeNode("IHM"));
    s2.add(new DefaultMutableTreeNode("M3DS"));
    s2.add(new DefaultMutableTreeNode("PAC"));
    s2.add(new DefaultMutableTreeNode("PPD"));
    s2.add(new DefaultMutableTreeNode("RdF"));
    s2.add(new DefaultMutableTreeNode("SVL"));
    s2.add(new DefaultMutableTreeNode("TI"));
    JTree tree = new JTree(m1);
    // tree.setDragEnabled(true);
    JScrollPane jscrollTree = new JScrollPane(tree);
    jscrollTree.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JTree"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    jscrollTree.setPreferredSize(new Dimension(200, 200));

    // JTable
    String[] columnNames = {"S1", "S2"};
    Object[][] data2 = {
      {"AAC", "CAR"},
      {"AEV", "PJI"},
      {"ANG", "AeA"},
      {"ASE", "BDA"},
      {"COA", "CALP"},
      {"PJE", "FDD"},
      {"", "HECI"},
      {"", "IHM"},
      {"", "M3DS"},
      {"", "PAC"},
      {"", "PPD"},
      {"", "RdF"},
      {"", "SVL"},
      {"", "TI"}
    };

    JTable table = new JTable(data2, columnNames);
    JScrollPane scrollPaneTable = new JScrollPane(table);
    table.setDragEnabled(true);

    // JFileChooser
    JFileChooser fc = new JFileChooser();
    fc.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("JFileChooser"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    fc.setDragEnabled(true);

    panelgauche.add(textField);
    panelgauche.add(passwordField);
    panelgauche.add(ftf);
    panelgauche.add(jta);
    panelgauche.add(cc);
    panelgauche.add(editorScrollPane);
    fen.getContentPane().add(panelgauche);

    paneldroit.add(fc);
    paneldroit.add(jscrollListe);
    paneldroit.add(jscrollTree);
    paneldroit.add(scrollPaneTable);

    fen.getContentPane().add(paneldroit);

    fen.pack();
    fen.setVisible(true);
  }