Example usage for javax.swing JOptionPane OK_CANCEL_OPTION

List of usage examples for javax.swing JOptionPane OK_CANCEL_OPTION

Introduction

In this page you can find the example usage for javax.swing JOptionPane OK_CANCEL_OPTION.

Prototype

int OK_CANCEL_OPTION

To view the source code for javax.swing JOptionPane OK_CANCEL_OPTION.

Click Source Link

Document

Type used for showConfirmDialog.

Usage

From source file:io.github.jeddict.jpa.modeler.properties.PropertiesHandler.java

public static ComboBoxPropertySupport getCollectionImplTypeProperty(
        AttributeWidget<? extends Attribute> attributeWidget, final CollectionTypeHandler colSpec) {
    JPAModelerScene modelerScene = attributeWidget.getModelerScene();
    EntityMappings em = modelerScene.getBaseElementSpec();
    ModelerFile modelerFile = modelerScene.getModelerFile();
    ComboBoxListener<String> comboBoxListener = new ComboBoxListener<String>() {
        private final Set<String> value = new HashSet<>();

        @Override//w  w w .  j  av  a 2s . c  o  m
        public void setItem(ComboBoxValue<String> value) {
            setCollectionImplType(value);
        }

        void setCollectionImplType(ComboBoxValue<String> value) {
            String collectionImplType = value.getValue();
            boolean valid = validateCollectionType(colSpec.getCollectionType(), collectionImplType, false);
            if (valid) {
                colSpec.setCollectionImplType(collectionImplType);
                em.getCache().addCollectionImplClass(collectionImplType);
            } else if (StringUtils.isEmpty(collectionImplType)) {
                colSpec.setCollectionImplType(null);
            }
        }

        @Override
        public ComboBoxValue<String> getItem() {
            if (!value.contains(colSpec.getCollectionImplType())) {
                value.add(colSpec.getCollectionImplType());
                em.getCache().addCollectionImplClass(colSpec.getCollectionImplType());
            }
            if (StringUtils.isNotEmpty(colSpec.getCollectionImplType())) {
                return new ComboBoxValue(colSpec.getCollectionImplType(), colSpec.getCollectionImplType()
                        .substring(colSpec.getCollectionImplType().lastIndexOf('.') + 1));
            } else {
                return new ComboBoxValue(null, EMPTY);
            }
        }

        @Override
        public List<ComboBoxValue<String>> getItemList() {
            List<ComboBoxValue<String>> comboBoxValues = new ArrayList<>();
            comboBoxValues.add(new ComboBoxValue(null, ""));
            value.addAll(em.getCache().getCollectionImplClasses());
            em.getCache().getCollectionImplClasses().stream().filter(StringUtils::isNotEmpty)
                    .forEach(collection -> {
                        Class _class;
                        try {
                            _class = Class.forName(collection);
                            comboBoxValues.add(new ComboBoxValue(_class.getName(), _class.getSimpleName()));
                        } catch (ClassNotFoundException ex) {
                            comboBoxValues.add(new ComboBoxValue(collection, collection + "(Not Exist)"));
                        }
                    });
            return comboBoxValues;
        }

        @Override
        public String getDefaultText() {
            return EMPTY;
        }

        @Override
        public ActionHandler getActionHandler() {
            return ActionHandler.getInstance(() -> {
                String collectionType = NBModelerUtil.browseClass(modelerFile);
                try {
                    if (Collection.class.isAssignableFrom(Class.forName(collectionType))
                            || Map.class.isAssignableFrom(Class.forName(collectionType))) {
                        return new ComboBoxValue<>(collectionType,
                                collectionType.substring(collectionType.lastIndexOf('.') + 1));
                    }
                } catch (ClassNotFoundException ex) {

                }
                throw new IllegalStateException("Invalid Collection/Map type");
            }).afterCreation(e -> em.getCache().addCollectionImplClass(e.getValue()))
                    .afterDeletion(e -> em.getCache().getCollectionImplClasses().remove(e.getValue()))
                    .beforeDeletion(
                            () -> JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(),
                                    "Are you sue you want to delete this collection implementation class ?",
                                    "Delete Collection Implementation Class", JOptionPane.OK_CANCEL_OPTION));
        }
    };
    org.netbeans.modeler.config.element.Attribute attribute = new org.netbeans.modeler.config.element.Attribute(
            "collectionImplType", "Collection Implementation Type", "");
    attribute.setAfter("collectionType");
    return new ComboBoxPropertySupport(modelerScene.getModelerFile(), attribute, comboBoxListener);
}

From source file:com.smanempat.controller.ControllerEvaluation.java

public void proccessMining(JTable tableDataSetModel, JTable tableDataSetTesting, JTextField txtNumberOfK,
        JLabel labelPesanError, JTabbedPane jTabbedPane1, JTable tableResult, JTable tableConfMatrix,
        JTable tableTahunTesting, JLabel totalAccuracy, JPanel panelChart, JPanel panelChart1,
        JPanel panelChart2, JRadioButton singleTesting, JRadioButton multiTesting, JTextArea txtArea)
        throws SQLException {
    Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
    modelEvaluation = new ModelEvaluation();
    int rowCountModel = tableDataSetModel.getRowCount();
    int rowCountTest = tableDataSetTesting.getRowCount();
    int[] tempK;/* ww w  .java2s .  co  m*/
    double[][] tempEval;
    double[][] evalValue;
    boolean valid = false;

    /*Validasi Dataset Model dan Dataset Uji*/
    if (rowCountModel == 0) {
        JOptionPane.showMessageDialog(null, "Pilih dataset model terlebih dahulu!", "Error",
                JOptionPane.INFORMATION_MESSAGE,
                new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
        txtNumberOfK.requestFocus();
    } else if (rowCountTest == 0) {
        JOptionPane.showMessageDialog(null, "Pilih dataset uji terlebih dahulu!", "Error",
                JOptionPane.INFORMATION_MESSAGE,
                new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
        txtNumberOfK.requestFocus();
    } else {
        valid = true;
    }
    /*Validasi Dataset Model dan Dataset Uji*/

    if (valid == true) {
        if (multiTesting.isSelected()) {
            String iterasi = JOptionPane.showInputDialog("Input Jumlah Iterasi Pengujian :");
            boolean validMulti = false;

            if (iterasi != null) {

                /*Validasi Jumlah Iterasi*/
                if (Pattern.matches("[0-9]+", iterasi) == false && iterasi.length() > 0) {
                    JOptionPane.showMessageDialog(null, "Nilai iterasi tidak valid!", "Error",
                            JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else if (iterasi.isEmpty()) {
                    JOptionPane.showMessageDialog(null, "Nilai iterasi tidak boleh kosong!", "Error",
                            JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else if (iterasi.length() == 9) {
                    JOptionPane.showMessageDialog(null, "Nilai iterasi terlalu panjang!", "Error",
                            JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else if (rowCountTest > rowCountModel) {

                    JOptionPane.showMessageDialog(null, "Data Uji tidak boleh lebih besar daripada data Model!",
                            "Error", JOptionPane.INFORMATION_MESSAGE,
                            new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                } else {
                    validMulti = true;
                    System.out.println("valiMulti = " + validMulti + " Kok");
                }
                /*Validasi Jumlah Iterasi*/
            }

            if (validMulti == true) {
                tempK = new int[Integer.parseInt(iterasi)];
                evalValue = new double[3][tempK.length];
                for (int i = 0; i < Integer.parseInt(iterasi); i++) {
                    validMulti = false;
                    String k = JOptionPane
                            .showInputDialog("Input Nilai Nearest Neighbor (k) ke " + (i + 1) + " :");
                    if (k != null) {
                        /*Validasi Nilai K Tiap Iterasi*/
                        if (Pattern.matches("[0-9]+", k) == false && k.length() > 0) {
                            JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) tidak valid!",
                                    "Error", JOptionPane.INFORMATION_MESSAGE,
                                    new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                        } else if (k.isEmpty()) {
                            JOptionPane.showMessageDialog(null,
                                    "Nilai nearest neighbor (k) tidak boleh kosong!", "Error",
                                    JOptionPane.INFORMATION_MESSAGE,
                                    new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                        } else if (k.length() == 9) {
                            JOptionPane.showMessageDialog(null, "Nilai nearest neighbor (k) terlalu panjang!",
                                    "Error", JOptionPane.INFORMATION_MESSAGE,
                                    new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                        } else {
                            validMulti = true;
                        }
                        /*Validasi Nilai K Tiap Iterasi*/
                    }

                    if (validMulti == true) {
                        tempK[i] = Integer.parseInt(k);
                        System.out.println(tempK[i]);
                    } else {
                        break;
                    }
                }

                if (validMulti == true) {
                    for (int i = 0; i < tempK.length; i++) {
                        int kValue = tempK[i];
                        String[][] modelValue = getModelValue(rowCountModel, tableDataSetModel);
                        double[][] testValue = getTestvalue(rowCountTest, tableDataSetTesting);
                        String[] knnValue = getKNNValue(rowCountModel, rowCountTest, modelValue, testValue,
                                kValue);
                        tempEval = evaluationModel(tableResult, tableConfMatrix, totalAccuracy,
                                tableTahunTesting, tableDataSetTesting, knnValue, i, tempK, panelChart);
                        //Menampung nilai Accuracy
                        evalValue[0][i] = tempEval[0][i];
                        //Menampung nilai Recall
                        evalValue[1][i] = tempEval[1][i];
                        //Menampung nilai Precision
                        evalValue[2][i] = tempEval[2][i];
                        jTabbedPane1.setSelectedIndex(1);
                        txtArea.append(
                                "Tingkat Keberhasilan Sistem dengan Nilai Number of Nearest Neighbor (K) = "
                                        + tempK[i] + "\n");
                        txtArea.append("Akurasi\t\t: " + evalValue[0][i] * 100 + " %\n");
                        txtArea.append("Recall\t\t: " + evalValue[1][i] * 100 + " %\n");
                        txtArea.append("Precision\t: " + evalValue[2][i] * 100 + " %\n");
                        txtArea.append(
                                "=============================================================================\n");
                    }
                    showChart(tempK, evalValue, panelChart, panelChart1, panelChart2);
                }
            }
        } else if (singleTesting.isSelected()) {
            boolean validSingle = false;
            String k = txtNumberOfK.getText();
            int nilaiK = 0;
            evalValue = new double[3][1];

            /*Validasi Nilai Number of Nearest Neighbor*/
            if (Pattern.matches("[0-9]+", k) == false && k.length() > 0) {
                labelPesanError.setText("Number of Nearest Neighbor tidak valid");
                JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak valid!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else if (k.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Number of Nearest Neighbor tidak boleh kosong!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                labelPesanError.setText("Number of Nearest Neighbor tidak boleh kosong");
                txtNumberOfK.requestFocus();
            } else if (rowCountModel == 0 && Integer.parseInt(k) >= rowCountModel) {
                JOptionPane.showMessageDialog(null, "Pilih dataset model terlebih dahulu!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else if (rowCountTest == 0 && Integer.parseInt(k) >= rowCountTest) {
                JOptionPane.showMessageDialog(null, "Pilih dataset uji terlebih dahulu!", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else if (Integer.parseInt(k) >= rowCountModel) {
                JOptionPane.showMessageDialog(null,
                        "Number of Nearest Neighbor tidak boleh lebih dari " + rowCountModel + " !", "Error",
                        JOptionPane.INFORMATION_MESSAGE,
                        new ImageIcon(getClass().getResource("/com/smanempat/image/fail.png")));
                txtNumberOfK.requestFocus();
            } else {
                validSingle = true;
                nilaiK = Integer.parseInt(k);
            }
            /*Validasi Nilai Number of Nearest Neighbor*/

            if (validSingle == true) {
                int confirm;
                int i = 0;
                confirm = JOptionPane.showOptionDialog(null, "Yakin ingin memproses data?",
                        "Proses Klasifikasi", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                        null, null);
                if (confirm == JOptionPane.OK_OPTION) {

                    int kValue = Integer.parseInt(txtNumberOfK.getText());
                    String[][] modelValue = getModelValue(rowCountModel, tableDataSetModel);
                    double[][] testValue = getTestvalue(rowCountTest, tableDataSetTesting);
                    String[] knnValue = getKNNValue(rowCountModel, rowCountTest, modelValue, testValue, kValue);
                    tempEval = evaluationModel(tableResult, tableConfMatrix, totalAccuracy, tableTahunTesting,
                            tableDataSetTesting, knnValue, nilaiK, panelChart);
                    evalValue[0][i] = tempEval[0][0];
                    evalValue[1][i] = tempEval[1][0];
                    evalValue[2][i] = tempEval[2][0];
                    jTabbedPane1.setSelectedIndex(1);
                }
                System.out.println("com.smanempat.controller.ControllerEvaluation.proccessMining()OKOKOK");
                showChart(nilaiK, evalValue, panelChart, panelChart1, panelChart2);
                Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
            }
        }
    }

}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JFrame createJDialog(final String titulo) {
    final JFrame d = new JFrame(titulo);
    d.setResizable(false);/* w  w w  .j  a v  a 2s. c  o  m*/
    d.setAlwaysOnTop(true);
    d.setIconImage(window.getIconImage());
    d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    d.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            if (cambios) {
                int res = JOptionPane.showConfirmDialog(d,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION);
                if (res != JOptionPane.CANCEL_OPTION) {
                    e.getWindow().dispose();
                }
            } else {
                e.getWindow().dispose();
            }
        }
    });
    d.setLayout(new BorderLayout(5, 5));
    d.setBackground(Color.WHITE);
    d.getContentPane().setBackground(Color.WHITE);
    return d;
}

From source file:com.sshtools.common.vomanagementtool.common.VOHelper.java

public static boolean createAddVODialog() {
    boolean isSuccessful = false;
    NewVOPanel newVOPanel = new NewVOPanel();

    while (true) {
        int result = JOptionPane.showConfirmDialog(null, newVOPanel, "New VO", JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE, new ResourceIcon(newVOPanel.getClass(), ConfigHelper.ICON));

        if (result == JOptionPane.OK_OPTION) {

            String msg = "";
            if (newVOPanel.getServerIssuerDN().equals("")) {
                msg = "Field 'Server Certificate Issuer DN' cannot be empty.";
            }/*www  .  j a  v  a  2s .  co m*/
            if (newVOPanel.getServerDN().equals("")) {
                msg = "Field 'Server DN' cannot be empty.\n" + msg;
            }
            if (newVOPanel.getPort() == 0) {
                msg = "Field 'Port' cannot be empty.\n" + msg;
            }
            if (newVOPanel.getServer().equals("")) {
                msg = "Field 'Server' cannot be empty.\n" + msg;
            }
            if (newVOPanel.getVOName().equals("")) {
                msg = "Field 'VO name' cannot be empty.\n" + msg;
            }

            if (!msg.equals("")) {
                JOptionPane.showMessageDialog(null, msg, "Error: Add new VO", JOptionPane.ERROR_MESSAGE);
            } else {
                TreeMap vo = new TreeMap();
                vo.put("localvoname", newVOPanel.getVOName());
                vo.put("servervoname", newVOPanel.getVOName());
                vo.put("server", newVOPanel.getServer());
                vo.put("port", newVOPanel.getPort());
                vo.put("serverdn", newVOPanel.getServerDN());
                vo.put("serverissuerdn", newVOPanel.getServerIssuerDN());
                try {
                    isSuccessful = addNewVO(vo);
                    break;
                } catch (IOException e) {
                    JOptionPane.showMessageDialog(null, e.getMessage(), "Error: Add new VO",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        } else {
            break;
        }
    }

    return isSuccessful;
}

From source file:org.gumtree.vis.hist2d.Hist2DPanel.java

private void showPropertyEditor(int tabIndex) {
    Hist2DChartEditor editor = new Hist2DChartEditor(getChart(), this);
    editor.getTabs().setSelectedIndex(tabIndex);
    int result = JOptionPane.showConfirmDialog(this, editor,
            localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE);
    if (result == JOptionPane.OK_OPTION) {
        editor.updateChart(getChart());//w ww. j  ava 2s.co  m
    }
}

From source file:de.adv_online.aaa.profiltool.ProfilDialog.java

protected void closeDialog() {
    try {//ww  w.  ja va2s . c om
        String msg = null;
        if (transformationRunning)
            msg = "Eine Profilerzeugung luft derzeit.\n";// Meldung

        if (msg != null) {
            msg += "Soll die Anwendung beendet werden?";
            Object[] options = { "Exit", "Cancel" };
            int val = JOptionPane.showOptionDialog(null, msg, "Confirmation", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
            if (val == 1)
                return;
        }

        if (model != null)
            model.shutdown();

        System.exit(0);
    } catch (Exception e) {
        System.out.println("closeDialog - Exception: " + e.toString());
        //System.exit(1);
    }
}

From source file:com.diversityarrays.kdxplore.field.FieldViewDialog.java

private void handleFileDrop(Component component, List<File> files, DropLocationInfo dli) {
    Integer column = dli.column;// www  .  j a  v a  2 s .  c om
    Integer row = dli.rowOrIndex;

    List<Plot> plots = fieldViewPanel.getFieldLayout().getItemsAt(Arrays.asList(new Point(column, row)));

    System.out.println("Dropped on: col,row=" + column + "," + row);

    List<File> filesAdded = new ArrayList<>();
    for (Plot plot : plots) {
        System.out.println("plot: " + plot.getPlotId() + ": " + plot.getPlotColumn() + "," + plot.getPlotRow());

        List<Specimen> specimens = plot.getSpecimens();
        if (specimens == null || specimens.isEmpty()) {

            try {
                for (File file : files) {
                    File storedFile = copyToMediaStoreDir(file, plot, PlotOrSpecimen.ORGANISM_NUMBER_IS_PLOT);
                    database.addMediaFile(sampleGroupChoiceForNewMedia, trial, plot,
                            PlotOrSpecimen.ORGANISM_NUMBER_IS_PLOT, storedFile);
                    filesAdded.add(file);
                }
            } catch (IOException e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(FieldViewDialog.this, e, "Database Error",
                        JOptionPane.ERROR_MESSAGE);
                break;
            }
        } else {
            List<String> plotOrSpecimen = new ArrayList<>();
            Map<String, PlotOrSpecimen> specimenByIdent = new HashMap<>();
            String plotIdent = trial.getPlotIdentOption().createPlotIdentString(plot, ",");
            plotOrSpecimen.add(plotIdent);
            specimenByIdent.put(plotIdent, plot);
            for (Specimen s : specimens) {
                if (PlotOrSpecimen.isSpecimenNumberForSpecimen(s.getSpecimenNumber())) {
                    String ident = "Individual#" + s.getSpecimenNumber();
                    plotOrSpecimen.add(ident);
                    specimenByIdent.put(ident, s);
                }
            }
            Object[] selectionValues = plotOrSpecimen.toArray(new String[plotOrSpecimen.size()]);
            Object initialSelectionValue = null;
            Object chosen = JOptionPane.showInputDialog(FieldViewDialog.this, "Select Plot or Specimen",
                    "Add Attachment", JOptionPane.OK_CANCEL_OPTION, null, selectionValues,
                    initialSelectionValue);
            if (chosen != null) {
                PlotOrSpecimen choice = specimenByIdent.get(chosen);
                if (choice != null) {
                    try {
                        for (File file : files) {
                            File storedFile = copyToMediaStoreDir(file, plot, choice.getSpecimenNumber());
                            database.addMediaFile(sampleGroupChoiceForNewMedia, trial, plot,
                                    choice.getSpecimenNumber(), storedFile);
                            filesAdded.add(file);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(FieldViewDialog.this, e, "Database Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                }
            }
        }
    }

    if (!filesAdded.isEmpty()) {
        String message = filesAdded.stream().map(File::getName).collect(Collectors.joining("\n"));
        JOptionPane.showMessageDialog(FieldViewDialog.this, message, "Attachments Added",
                JOptionPane.INFORMATION_MESSAGE);
    }

}

From source file:fi.hoski.remote.ui.Admin.java

private JMenuItem menuItemRemoveYear() {
    final String title = TextUtil.getText("REMOVE YEAR");
    JMenuItem removeEntityItem = new JMenuItem(title);
    ActionListener removeEntityAction = new ActionListener() {

        @Override/*from  ww  w  .  j  a  v  a 2  s .  co m*/
        public void actionPerformed(ActionEvent e) {
            Object yearString = JOptionPane.showInputDialog(frame, title, "", JOptionPane.OK_CANCEL_OPTION);
            if (yearString != null) {
                String confirm = TextUtil.getText("CONFIRM REMOVE") + " " + yearString;
                if (JOptionPane.showConfirmDialog(frame, confirm, "",
                        JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                    long year = Long.parseLong(yearString.toString());
                    Day now = new Day();
                    if (year < now.getYear()) {
                        int count = dss.remove(year);
                        JOptionPane.showMessageDialog(frame, TextUtil.getText("REMOVED") + " " + count);
                    } else {
                        JOptionPane.showMessageDialog(frame, TextUtil.getText("CANNOT REMOVE") + " " + year);
                    }
                }
            }
        }
    };
    removeEntityAction = createActionListener(frame, removeEntityAction);
    removeEntityItem.addActionListener(removeEntityAction);
    return removeEntityItem;
}

From source file:br.com.jinsync.view.FrmJInSync.java

/**
 * Initialize the contents of the frame.
 *//*from w  w w .  ja  v  a  2  s .  c om*/
private void initialize() {

    Language.loadParameters();

    setBounds(100, 100, 1136, 665);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 0, 0 };
    gridBagLayout.rowHeights = new int[] { 600, 53, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 1.0, 0.0, 0.0, Double.MIN_VALUE };
    getContentPane().setLayout(gridBagLayout);

    grpFontes = new JTabbedPane(SwingConstants.TOP);
    GridBagConstraints gbc_grpFontes = new GridBagConstraints();
    gbc_grpFontes.insets = new Insets(0, 0, 5, 0);
    gbc_grpFontes.fill = GridBagConstraints.BOTH;
    gbc_grpFontes.gridx = 0;
    gbc_grpFontes.gridy = 0;
    getContentPane().add(grpFontes, gbc_grpFontes);

    tabCopybook = new JPanel();
    tabCopybook.setBackground(Color.WHITE);
    grpFontes.addTab(Language.tabCopy, null, tabCopybook, null);

    GridBagLayout gbl_tabCopybook = new GridBagLayout();
    gbl_tabCopybook.columnWidths = new int[] { 10, 1, 0, 349, 0, 0, 62, 28, 71, 0, 0, 0 };
    gbl_tabCopybook.rowHeights = new int[] { 1, 0, 0, 0 };
    gbl_tabCopybook.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    gbl_tabCopybook.rowWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE };
    tabCopybook.setLayout(gbl_tabCopybook);

    JLabel lblCopybook = new JLabel(Language.txtFilePds);
    GridBagConstraints gbc_lblCopybook = new GridBagConstraints();
    gbc_lblCopybook.anchor = GridBagConstraints.EAST;
    gbc_lblCopybook.insets = new Insets(0, 0, 5, 5);
    gbc_lblCopybook.gridx = 1;
    gbc_lblCopybook.gridy = 1;
    tabCopybook.add(lblCopybook, gbc_lblCopybook);

    txtPath = new JTextField();
    GridBagConstraints gbc_txtPath = new GridBagConstraints();
    gbc_txtPath.gridwidth = 4;
    gbc_txtPath.insets = new Insets(0, 0, 5, 5);
    gbc_txtPath.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtPath.gridx = 2;
    gbc_txtPath.gridy = 1;
    tabCopybook.add(txtPath, gbc_txtPath);
    txtPath.setColumns(10);

    JButton btnDiretorio = new JButton("");
    btnDiretorio.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/folder.png")));
    btnDiretorio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            openDirectory();
        }
    });
    GridBagConstraints gbc_btnDiretorio = new GridBagConstraints();
    gbc_btnDiretorio.insets = new Insets(0, 0, 5, 5);
    gbc_btnDiretorio.gridx = 6;
    gbc_btnDiretorio.gridy = 1;
    tabCopybook.add(btnDiretorio, gbc_btnDiretorio);

    btnClearCopy = new JButton("");
    btnClearCopy.setEnabled(false);
    btnClearCopy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            tableCopy = new JTable();
            scrCopy.setViewportView(tableCopy);
            tableString = new JTable();
            scrTableString.setViewportView(tableString);

            btnExcelString.setEnabled(false);
            btnClearString.setEnabled(false);
            textAreaString.setText("");

            console.removeAllElements();
            btnExcel.setEnabled(false);
            btnClearCopy.setEnabled(false);
            grpFontes.setEnabledAt(1, false);

            tableFile = new JTable();
            scrFile.setViewportView(tableFile);
            btnExcelFile.setEnabled(false);
            btnClearFile.setEnabled(false);
            grpFontes.setEnabledAt(2, false);

        }
    });
    btnClearCopy.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png")));
    GridBagConstraints gbc_btnLimpar = new GridBagConstraints();
    gbc_btnLimpar.fill = GridBagConstraints.BOTH;
    gbc_btnLimpar.insets = new Insets(0, 0, 5, 5);
    gbc_btnLimpar.gridx = 9;
    gbc_btnLimpar.gridy = 1;
    tabCopybook.add(btnClearCopy, gbc_btnLimpar);

    JButton btnProcessarBook = new JButton("");
    btnProcessarBook.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            loadData();
            btnClearCopy.setEnabled(true);
            grpFontes.setEnabledAt(1, true);
            grpFontes.setEnabledAt(2, true);
        }
    });
    btnProcessarBook.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png")));
    GridBagConstraints gbc_btnProcessarBook = new GridBagConstraints();
    gbc_btnProcessarBook.fill = GridBagConstraints.VERTICAL;
    gbc_btnProcessarBook.insets = new Insets(0, 0, 5, 5);
    gbc_btnProcessarBook.gridx = 7;
    gbc_btnProcessarBook.gridy = 1;
    tabCopybook.add(btnProcessarBook, gbc_btnProcessarBook);

    btnExcel = new JButton("");
    btnExcel.setEnabled(false);
    btnExcel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            expExcelBook();
            // exportarExcelBook(tableCopy, txtPath.getText(),
            // "Horizontal");
        }
    });
    btnExcel.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png")));
    GridBagConstraints gbc_btnExcel = new GridBagConstraints();
    gbc_btnExcel.insets = new Insets(0, 0, 5, 5);
    gbc_btnExcel.gridx = 8;
    gbc_btnExcel.gridy = 1;
    tabCopybook.add(btnExcel, gbc_btnExcel);

    // JScrollPane scrCopy = new JScrollPane();
    gbc_scrCopy = new GridBagConstraints();
    gbc_scrCopy.gridwidth = 9;
    gbc_scrCopy.insets = new Insets(0, 0, 0, 5);
    gbc_scrCopy.fill = GridBagConstraints.BOTH;
    gbc_scrCopy.gridx = 1;
    gbc_scrCopy.gridy = 2;
    // tabCopybook.add(scrCopy, gbc_scrCopy);

    panelConsole = new Panel();
    GridBagConstraints gbc_panelConsole = new GridBagConstraints();
    gbc_panelConsole.insets = new Insets(0, 0, 5, 0);
    gbc_panelConsole.fill = GridBagConstraints.BOTH;
    gbc_panelConsole.gridx = 0;
    gbc_panelConsole.gridy = 1;
    getContentPane().add(panelConsole, gbc_panelConsole);
    panelConsole.setLayout(new BorderLayout(0, 0));

    listTerminal = new JList<String>();
    listTerminal.setFont(new Font("Courier New", Font.PLAIN, 11));
    listTerminal.setModel(console);

    scrConsole = new JScrollPane(listTerminal);
    panelConsole.add(scrConsole);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnNewMenu = new JMenu(Language.menuParam);
    menuBar.add(mnNewMenu);

    JMenuItem mnItemUsuario = new JMenuItem(Language.menuParamUser);
    mnItemUsuario.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FrmUser frmUsuar = new FrmUser();
            frmUsuar.setLocationRelativeTo(null);
            frmUsuar.setVisible(true);
            setUser();
        }
    });
    mnNewMenu.add(mnItemUsuario);

    JMenuItem mnItemFtp = new JMenuItem(Language.menuParamFtp);
    mnItemFtp.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FrmFtp frmFtp = new FrmFtp();
            frmFtp.setLocationRelativeTo(null);
            frmFtp.setVisible(true);
            setFtp();
        }
    });

    mnNewMenu.add(mnItemFtp);

    JMenu mnAjuda = new JMenu(Language.menuHelp);
    menuBar.add(mnAjuda);

    JMenuItem mntmNewMenuItem = new JMenuItem(Language.menuHelpAbout);
    mntmNewMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            FrmAbout frmSobre = new FrmAbout();
            frmSobre.setLocationRelativeTo(null);
            frmSobre.setVisible(true);
        }
    });
    mnAjuda.add(mntmNewMenuItem);

    tabCopybook.setFont(new Font("Arial", Font.PLAIN, 12));
    tabCopybook.add(scrCopy, gbc_scrCopy);

    tabString = new JPanel();
    tabString.setFont(new Font("Arial", Font.PLAIN, 12));
    tabString.setBackground(Color.WHITE);
    grpFontes.addTab(Language.tabString, null, tabString, null);
    grpFontes.setEnabledAt(1, false);
    GridBagLayout gbl_tabString = new GridBagLayout();
    gbl_tabString.columnWidths = new int[] { 10, 1, 346, 349, 0, 0, 62, 28, 71, 0, 0, 0 };
    gbl_tabString.rowHeights = new int[] { 1, 0, 0, 17, 22, 0, 259, 0 };
    gbl_tabString.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    gbl_tabString.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
    tabString.setLayout(gbl_tabString);

    JLabel lblString = new JLabel("String:");
    GridBagConstraints gbc_lblString = new GridBagConstraints();
    gbc_lblString.anchor = GridBagConstraints.WEST;
    gbc_lblString.insets = new Insets(0, 0, 5, 5);
    gbc_lblString.gridx = 1;
    gbc_lblString.gridy = 1;
    tabString.add(lblString, gbc_lblString);

    textAreaString = new JTextArea();

    JScrollPane scrStringData = new JScrollPane(textAreaString);
    GridBagConstraints gbc_scrString = new GridBagConstraints();
    gbc_scrString.gridheight = 3;
    gbc_scrString.gridwidth = 8;
    gbc_scrString.insets = new Insets(0, 0, 5, 5);
    gbc_scrString.fill = GridBagConstraints.BOTH;
    gbc_scrString.gridx = 1;
    gbc_scrString.gridy = 2;
    tabString.add(scrStringData, gbc_scrString);

    btnClearString = new JButton("");
    btnClearString.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            scrTableString.setViewportView(tableString);
            btnExcelString.setEnabled(false);
            btnClearString.setEnabled(false);
            textAreaString.setText("");
            tableString = new JTable();
            scrTableString.setViewportView(tableString);
        }
    });

    btnExcelString = new JButton("");
    btnExcelString.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            expExcelString();
        }
    });

    JButton btnProcessarArq = new JButton("");
    btnProcessarArq.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            processString();
        }
    });
    btnProcessarArq.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png")));
    GridBagConstraints gbc_btnProcessarArq = new GridBagConstraints();
    gbc_btnProcessarArq.fill = GridBagConstraints.VERTICAL;
    gbc_btnProcessarArq.insets = new Insets(0, 0, 5, 5);
    gbc_btnProcessarArq.gridx = 9;
    gbc_btnProcessarArq.gridy = 2;
    tabString.add(btnProcessarArq, gbc_btnProcessarArq);
    btnExcelString.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png")));
    btnExcelString.setEnabled(false);
    GridBagConstraints gbc_btnExcelString = new GridBagConstraints();
    gbc_btnExcelString.fill = GridBagConstraints.VERTICAL;
    gbc_btnExcelString.insets = new Insets(0, 0, 5, 5);
    gbc_btnExcelString.gridx = 9;
    gbc_btnExcelString.gridy = 3;
    tabString.add(btnExcelString, gbc_btnExcelString);
    btnClearString.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png")));
    btnClearString.setEnabled(false);
    GridBagConstraints gbc_btnClearString = new GridBagConstraints();
    gbc_btnClearString.fill = GridBagConstraints.VERTICAL;
    gbc_btnClearString.insets = new Insets(0, 0, 5, 5);
    gbc_btnClearString.gridx = 9;
    gbc_btnClearString.gridy = 4;
    tabString.add(btnClearString, gbc_btnClearString);

    JLabel lblSaida = new JLabel(Language.txtOutput);
    GridBagConstraints gbc_lblSaida = new GridBagConstraints();
    gbc_lblSaida.insets = new Insets(0, 0, 5, 5);
    gbc_lblSaida.gridx = 1;
    gbc_lblSaida.gridy = 5;
    tabString.add(lblSaida, gbc_lblSaida);

    GridBagConstraints gbc_scrArquivo = new GridBagConstraints();
    gbc_scrArquivo.fill = GridBagConstraints.BOTH;
    gbc_scrArquivo.gridwidth = 9;
    gbc_scrArquivo.insets = new Insets(0, 0, 0, 5);
    gbc_scrArquivo.gridx = 1;
    gbc_scrArquivo.gridy = 6;
    tabString.add(scrTableString, gbc_scrArquivo);

    tabFile = new JPanel();
    tabFile.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
            // TODO Auto-generated method stub
            if (isProcessStarted) {
                int key = e.getKeyCode();
                if (key == KeyEvent.VK_ESCAPE) {
                    int opc = JOptionPane.showConfirmDialog(null, Language.msgCancelProcess, Language.msgInf,
                            JOptionPane.OK_CANCEL_OPTION);
                    if (opc == JOptionPane.OK_OPTION) {
                        escProcessFile();
                    }
                }
            }

        }

        @Override
        public void keyReleased(KeyEvent arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void keyTyped(KeyEvent arg0) {
            // TODO Auto-generated method stub

        }

    });

    tabFile.setFont(new Font("Arial", Font.PLAIN, 12));
    tabFile.setBackground(Color.WHITE);
    grpFontes.addTab(Language.tabFile, null, tabFile, null);
    grpFontes.setEnabledAt(2, false);
    GridBagLayout gbl_tabFile = new GridBagLayout();
    gbl_tabFile.columnWidths = new int[] { 10, 1, 49, 459, 0, 0, 62, 28, 0, 71, 0, 0, 0, 0 };
    gbl_tabFile.rowHeights = new int[] { 1, 0, 0, 17, 22, 0, 259, 0, 0 };
    gbl_tabFile.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    gbl_tabFile.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
    tabFile.setLayout(gbl_tabFile);

    JLabel lblFile = new JLabel(Language.txtFilePds);
    GridBagConstraints gbc_lblFile = new GridBagConstraints();
    gbc_lblFile.anchor = GridBagConstraints.EAST;
    gbc_lblFile.insets = new Insets(0, 0, 5, 5);
    gbc_lblFile.gridx = 1;
    gbc_lblFile.gridy = 1;
    tabFile.add(lblFile, gbc_lblFile);

    txtFile = new JTextField();
    txtFile.setColumns(10);
    GridBagConstraints gbc_txtFile = new GridBagConstraints();
    gbc_txtFile.gridwidth = 5;
    gbc_txtFile.insets = new Insets(0, 0, 5, 5);
    gbc_txtFile.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtFile.gridx = 2;
    gbc_txtFile.gridy = 1;
    tabFile.add(txtFile, gbc_txtFile);

    btnClearFile = new JButton("");
    btnClearFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {

            tableFile = new JTable();
            scrFile.setViewportView(tableFile);
            btnExcelFile.setEnabled(false);
            btnClearFile.setEnabled(false);
            progressBar.setStringPainted(true);
            progressBar.setValue(0);
            progressBar.setString("");

        }
    });

    btnExcelFile = new JButton("");
    btnExcelFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            expExcelFile();
        }
    });

    btnProcFile = new JButton("");
    btnProcFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            loadFile();
        }
    });

    btnDirFile = new JButton("");
    btnDirFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            openDirFile();
        }
    });
    btnDirFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/folder.png")));
    GridBagConstraints gbc_btnDirFile = new GridBagConstraints();
    gbc_btnDirFile.fill = GridBagConstraints.VERTICAL;
    gbc_btnDirFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnDirFile.gridx = 7;
    gbc_btnDirFile.gridy = 1;
    tabFile.add(btnDirFile, gbc_btnDirFile);
    btnProcFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png")));
    GridBagConstraints gbc_btnProcFile = new GridBagConstraints();
    gbc_btnProcFile.fill = GridBagConstraints.VERTICAL;
    gbc_btnProcFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnProcFile.gridx = 8;
    gbc_btnProcFile.gridy = 1;
    tabFile.add(btnProcFile, gbc_btnProcFile);
    btnExcelFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png")));
    btnExcelFile.setEnabled(false);
    GridBagConstraints gbc_btnExcelFile = new GridBagConstraints();
    gbc_btnExcelFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnExcelFile.gridx = 9;
    gbc_btnExcelFile.gridy = 1;
    tabFile.add(btnExcelFile, gbc_btnExcelFile);
    btnClearFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png")));
    btnClearFile.setEnabled(false);
    GridBagConstraints gbc_btnLimparFile = new GridBagConstraints();
    gbc_btnLimparFile.fill = GridBagConstraints.VERTICAL;
    gbc_btnLimparFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnLimparFile.gridx = 10;
    gbc_btnLimparFile.gridy = 1;
    tabFile.add(btnClearFile, gbc_btnLimparFile);

    JLabel lblTamanho = new JLabel(Language.txtFileLength);
    GridBagConstraints gbc_lblTamanho = new GridBagConstraints();
    gbc_lblTamanho.anchor = GridBagConstraints.WEST;
    gbc_lblTamanho.insets = new Insets(0, 0, 5, 5);
    gbc_lblTamanho.gridx = 1;
    gbc_lblTamanho.gridy = 2;
    tabFile.add(lblTamanho, gbc_lblTamanho);

    txtLength = new JTextField();
    GridBagConstraints gbc_txtTamanho = new GridBagConstraints();
    gbc_txtTamanho.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtTamanho.insets = new Insets(0, 0, 5, 5);
    gbc_txtTamanho.gridx = 2;
    gbc_txtTamanho.gridy = 2;
    tabFile.add(txtLength, gbc_txtTamanho);
    txtLength.setColumns(10);

    JLabel label_1 = new JLabel(Language.txtOutput);
    GridBagConstraints gbc_label_1 = new GridBagConstraints();
    gbc_label_1.anchor = GridBagConstraints.WEST;
    gbc_label_1.insets = new Insets(0, 0, 5, 5);
    gbc_label_1.gridx = 1;
    gbc_label_1.gridy = 3;
    tabFile.add(label_1, gbc_label_1);

    GridBagConstraints gbc_scrFile = new GridBagConstraints();
    gbc_scrFile.gridheight = 3;
    gbc_scrFile.fill = GridBagConstraints.BOTH;
    gbc_scrFile.gridwidth = 10;
    gbc_scrFile.insets = new Insets(0, 0, 5, 5);
    gbc_scrFile.gridx = 1;
    gbc_scrFile.gridy = 4;
    tabFile.add(scrFile, gbc_scrFile);

    progressBar = new JProgressBar();
    GridBagConstraints gbc_progressBar = new GridBagConstraints();
    gbc_progressBar.fill = GridBagConstraints.HORIZONTAL;
    gbc_progressBar.gridwidth = 10;
    gbc_progressBar.insets = new Insets(0, 0, 0, 5);
    gbc_progressBar.gridx = 1;
    gbc_progressBar.gridy = 7;
    tabFile.add(progressBar, gbc_progressBar);

    JLabel lblNewLabel = new JLabel(Language.txtDeveloped + " Rodrigo Augusto Silva dos Santos - 2016");
    GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
    gbc_lblNewLabel.gridx = 0;
    gbc_lblNewLabel.gridy = 2;
    getContentPane().add(lblNewLabel, gbc_lblNewLabel);

    loadParameters();

}

From source file:pi.bestdeal.gui.InterfacePrincipale.java

private void Add_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Add_ButtonActionPerformed

    Panel_Ajouter panajout = new Panel_Ajouter();

    Deal deal = new Deal();

    int result = JOptionPane.showConfirmDialog(null, panajout, "Test", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE);

    if (result == JOptionPane.OK_OPTION) {
        deal.setTitreDeal_Deal(panajout.txtTitre.getText());
        Vendeur vendeur = new Vendeur();
        VendeurDAO daov = VendeurDAO.getInstance();

        for (Vendeur a : daov.displayvendeurByNom(String.valueOf(panajout.jList1.getSelectedValue()))) {
            vendeur = a;/*from  w w  w  .  j a  va 2  s . c om*/
        }
        if (panajout.jList1.getSelectedValue() == null) {
            vendeur.setIdVendeur(0);
        }

        deal.setDescDeal_Deal(panajout.txtDesc.getText());
        deal.setPrixDeal_Deal(Double.valueOf(panajout.txtPrix.getText()));
        deal.setNbrAchatValidation(Integer.valueOf(panajout.txtValidation.getText()));
        deal.setNbrAchatActuelDeal_Deal(0);
        deal.setNbrAffichage_Deal(0);
        deal.setEtatDeal_Deal("Comming");
        deal.setCategorie_Deal(panajout.ComboCategorie.getSelectedItem().toString());
        deal.setStatutDeal_Deal(false);
        java.util.Date d1 = panajout.jdateDebut.getCalendar().getTime();
        java.sql.Date sqlDate = new java.sql.Date(d1.getTime());
        java.util.Date d2 = panajout.jdateFin.getCalendar().getTime();
        java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime());
        if (d1.after(d2)) {
            JOptionPane.showMessageDialog(null, "les Dates sont non compatibles");
        } else {
            deal.setDateDebutDeal_Deal(sqlDate);
            deal.setDateFinDeal_Deal(sqlDate2);
            deal.setIdVendeur_Deal(vendeur.getIdVendeur());
            DealDAO dealdao = DealDAO.getInstance();

            dealdao.insertDeal(deal);
            Deal dd = dealdao.displayDeal().get((dealdao.displayDeal().size() - 1));
            y = dd.getIdDeal_Deal();
            System.out.println(y);
            if (panajout.fc.getSelectedFiles().length != 0) {
                for (int i = 0; i < panajout.fc.getSelectedFiles().length; i++) {

                    FileInputStream fis = null;
                    try {
                        fis = new FileInputStream(panajout.file[i]);
                    } catch (FileNotFoundException ex) {
                        Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    ImageDeal imgdeal = new ImageDeal();
                    Path path = Paths.get(panajout.file[i].getAbsolutePath());
                    try {
                        imgdeal.setImage(Files.readAllBytes(path));

                    } catch (IOException ex) {
                        Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    imgdeal.setIdDeal(y);

                    ImageDAO im = ImageDAO.getInstance();
                    im.InsertImage(imgdeal);

                }
            }

            JOptionPane.showMessageDialog(null, "Ajout termin");
            DealTableModel mymodel = new DealTableModel(list.displayDeal());
            jTable1.setModel(mymodel);
            jTable1.removeColumn(jTable1.getColumn("ID"));
            jTable1.removeColumn(jTable1.getColumn("Description"));
            jTable1.removeColumn(jTable1.getColumn("Achat Actuel"));
            jTable1.removeColumn(jTable1.getColumn("Etat"));
            jTable1.removeColumn(jTable1.getColumn("Statut"));
            jTable1.removeColumn(jTable1.getColumn("Nombre d'Affichage"));
            jTable1.removeColumn(jTable1.getColumn("Vendeur"));

            jTable1.getColumnModel().setColumnMargin(20);
            jTable1.setRowSelectionInterval(0, 0);
            y = mymodel.getRowCount();
            panajout.w = y;
            System.out.println("la valeur de y est :" + y + "et " + panajout.w);
        }
    } else {
        System.out.println("Cancelled");
    }

}