Example usage for javax.swing JTable JTable

List of usage examples for javax.swing JTable JTable

Introduction

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

Prototype

public JTable() 

Source Link

Document

Constructs a default JTable that is initialized with a default data model, a default column model, and a default selection model.

Usage

From source file:org.apache.taverna.activities.xpath.ui.contextualview.XPathActivityMainContextualView.java

@Override
public JComponent getMainFrame() {
    jpMainPanel = new JPanel(new GridBagLayout());
    jpMainPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 2, 4, 2),
            BorderFactory.createEmptyBorder()));

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.weighty = 0;//  w w  w . j av a 2s  .  c  o m

    // --- XPath Expression ---

    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 5, 5, 5);
    JLabel jlXPathExpression = new JLabel("XPath Expression:");
    jlXPathExpression.setFont(jlXPathExpression.getFont().deriveFont(Font.BOLD));
    jpMainPanel.add(jlXPathExpression, c);

    c.gridx++;
    c.weightx = 1.0;
    tfXPathExpression = new JTextField();
    tfXPathExpression.setEditable(false);
    jpMainPanel.add(tfXPathExpression, c);

    // --- Label to Show/Hide Mapping Table ---

    final JLabel jlShowHideNamespaceMappings = new JLabel("Show namespace mappings...");
    jlShowHideNamespaceMappings.setForeground(Color.BLUE);
    jlShowHideNamespaceMappings.setCursor(new Cursor(Cursor.HAND_CURSOR));
    jlShowHideNamespaceMappings.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            spXPathNamespaceMappings.setVisible(!spXPathNamespaceMappings.isVisible());
            jlShowHideNamespaceMappings.setText(
                    (spXPathNamespaceMappings.isVisible() ? "Hide" : "Show") + " namespace mappings...");
            thisContextualView.revalidate();
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    jpMainPanel.add(jlShowHideNamespaceMappings, c);

    // --- Namespace Mapping Table ---

    xpathNamespaceMappingsTableModel = new DefaultTableModel() {
        /**
         * No cells should be editable
         */
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return (false);
        }
    };
    xpathNamespaceMappingsTableModel.addColumn("Namespace Prefix");
    xpathNamespaceMappingsTableModel.addColumn("Namespace URI");

    jtXPathNamespaceMappings = new JTable();
    jtXPathNamespaceMappings.setModel(xpathNamespaceMappingsTableModel);
    jtXPathNamespaceMappings.setPreferredScrollableViewportSize(new Dimension(200, 90));
    // TODO - next line is to be enabled when Taverna is migrated to Java
    // 1.6; for now it's fine to run without this
    // jtXPathNamespaceMappings.setFillsViewportHeight(true); // makes sure
    // that when the dedicated area is larger than the table, the latter is
    // stretched vertically to fill the empty space

    jtXPathNamespaceMappings.getColumnModel().getColumn(0).setPreferredWidth(20); // set
    // relative
    // sizes of
    // columns
    jtXPathNamespaceMappings.getColumnModel().getColumn(1).setPreferredWidth(300);

    c.gridy++;
    spXPathNamespaceMappings = new JScrollPane(jtXPathNamespaceMappings);
    spXPathNamespaceMappings.setVisible(false);
    jpMainPanel.add(spXPathNamespaceMappings, c);

    // populate the view with values
    refreshView();

    return jpMainPanel;
}

From source file:edu.harvard.mcz.imagecapture.DeterminationFrame.java

/**
 * This method initializes jTable   /*  w  w  w  .ja  v  a  2  s .  c o m*/
 *    
 * @return javax.swing.JTable   
 */
private JTable getJTable() {
    if (jTableDeterminations == null) {
        jTableDeterminations = new JTable();
        DeterminationTableModel model = new DeterminationTableModel();
        jTableDeterminations.setModel(model);
        if (determinations != null) {
            jTableDeterminations.setModel(determinations);
        }

        FilteringAgentJComboBox field = new FilteringAgentJComboBox();
        jTableDeterminations.getColumnModel().getColumn(DeterminationTableModel.ROW_IDENTIFIEDBY)
                .setCellEditor(new ComboBoxCellEditor(field));

        setTableColumnEditors();

        jTableDeterminations.setRowHeight(jTableDeterminations.getRowHeight() + 4);

        jTableDeterminations.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                if (e.isPopupTrigger()) {
                    clickedOnDetsRow = ((JTable) e.getComponent()).getSelectedRow();
                    jPopupDets.show(e.getComponent(), e.getX(), e.getY());
                }
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                if (e.isPopupTrigger()) {
                    clickedOnDetsRow = ((JTable) e.getComponent()).getSelectedRow();
                    jPopupDets.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        });

        jPopupDets = new JPopupMenu();
        JMenuItem mntmDeleteRow = new JMenuItem("Delete Row");
        mntmDeleteRow.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    log.debug(clickedOnDetsRow);
                    if (clickedOnDetsRow >= 0) {
                        int ok = JOptionPane.showConfirmDialog(thisFrame, "Delete the selected determination?",
                                "Delete Determination", JOptionPane.OK_CANCEL_OPTION);
                        if (ok == JOptionPane.OK_OPTION) {
                            log.debug("deleting determination row " + clickedOnDetsRow);
                            ((DeterminationTableModel) jTableDeterminations.getModel())
                                    .deleteRow(clickedOnDetsRow);
                        } else {
                            log.debug("determination row delete canceled by user.");
                        }
                    } else {
                        JOptionPane.showMessageDialog(thisFrame, "Unable to select row to delete.");
                    }
                } catch (Exception ex) {
                    log.error(ex.getMessage());
                    JOptionPane.showMessageDialog(thisFrame,
                            "Failed to delete a determination row. " + ex.getMessage());
                }
            }
        });
        jPopupDets.add(mntmDeleteRow);

    }
    return jTableDeterminations;
}

From source file:com.frostwire.gui.bittorrent.PartialFilesDialog.java

private void setupTable() {
    GridBagConstraints c;//w w  w  .  j a  va2  s .c  om
    _table = new JTable() {
        private static final long serialVersionUID = -4266029708016964901L;

        public void paint(java.awt.Graphics g) {
            super.paint(g);

            try {
                if (tablePainted) {
                    return;
                }
                tablePainted = true;

                GUIUtils.adjustColumnWidth(_model, 2, 620, 10, this);
                GUIUtils.adjustColumnWidth(_model, 3, 150, 10, this);
            } catch (Exception e) {
                tablePainted = false;
            }

        };
    };

    _table.setPreferredScrollableViewportSize(new Dimension(600, 300));
    _table.setRowSelectionAllowed(false);
    _table.setModel(_model);
    _table.getColumnModel().getColumn(0).setHeaderValue(""); //checkbox
    _table.getColumnModel().getColumn(1).setHeaderValue(""); //icon
    _table.getColumnModel().getColumn(2).setHeaderValue(I18n.tr("File"));
    _table.getColumnModel().getColumn(3).setHeaderValue(I18n.tr("Type"));
    _table.getColumnModel().getColumn(4).setHeaderValue(I18n.tr("Extension"));
    _table.getColumnModel().getColumn(5).setHeaderValue(I18n.tr("Size"));

    _table.getColumnModel().getColumn(0).setPreferredWidth(30);//checkbox
    _table.getColumnModel().getColumn(1).setPreferredWidth(30);//icon
    _table.getColumnModel().getColumn(2).setPreferredWidth(620);
    _table.getColumnModel().getColumn(3).setPreferredWidth(150);
    _table.getColumnModel().getColumn(4).setPreferredWidth(60);
    _table.getColumnModel().getColumn(5).setPreferredWidth(60);

    _scrollPane = new JScrollPane(_table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    _table.setFillsViewportHeight(true);
    _table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    panel.add(_scrollPane, c);
}

From source file:com.tiempometa.muestradatos.JProgramTags.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY
    // //GEN-BEGIN:initComponents
    ResourceBundle bundle = ResourceBundle.getBundle("com.tiempometa.muestradatos.muestradatos");
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    label1 = new JLabel();
    statusLabel = new JLabel();
    nextChipnumberTextField = new JTextField();
    programButton = new JButton();
    bibLabel = new JLabel();
    label3 = new JLabel();
    tidTextField = new JTextField();
    label4 = new JLabel();
    epcTextField = new JTextField();
    label5 = new JLabel();
    programmedEpcTextField = new JTextField();
    scrollPane1 = new JScrollPane();
    tagReadTable = new JTable();
    lockCheckbox = new JCheckBox();
    label2 = new JLabel();
    accessPasswordTextField = new JTextField();
    label6 = new JLabel();
    killPasswordTextField = new JTextField();
    checkBox1 = new JCheckBox();
    buttonBar = new JPanel();
    closeButton = new JButton();
    CellConstraints cc = new CellConstraints();

    // ======== this ========
    setTitle(bundle.getString("JProgramTags.this.title"));
    setIconImage(/*from  w w  w. ja va  2 s  .  c  o m*/
            new ImageIcon(getClass().getResource("/com/tiempometa/resources/tiempometa_icon_large_alpha.png"))
                    .getImage());
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    // ======== dialogPane ========
    {
        dialogPane.setBorder(Borders.DIALOG_BORDER);
        dialogPane.setLayout(new BorderLayout());

        // ======== contentPanel ========
        {
            contentPanel.setFont(new Font("Tahoma", Font.PLAIN, 14));
            contentPanel.setLayout(new FormLayout(
                    new ColumnSpec[] { new ColumnSpec(Sizes.dluX(12)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                            new ColumnSpec(Sizes.dluX(86)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                            new ColumnSpec(Sizes.dluX(73)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                            new ColumnSpec(Sizes.dluX(71)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                            new ColumnSpec(Sizes.dluX(68)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                            new ColumnSpec(Sizes.dluX(97)) },
                    new RowSpec[] { new RowSpec(Sizes.dluY(10)), FormFactory.LINE_GAP_ROWSPEC,
                            new RowSpec(Sizes.dluY(15)), FormFactory.LINE_GAP_ROWSPEC,
                            FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC,
                            FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC,
                            new RowSpec(Sizes.dluY(17)), FormFactory.LINE_GAP_ROWSPEC,
                            FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC,
                            FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC,
                            FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC,
                            FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC,
                            FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC,
                            FormFactory.DEFAULT_ROWSPEC }));

            // ---- label1 ----
            label1.setText(bundle.getString("JProgramTags.label1.text"));
            label1.setFont(new Font("Tahoma", Font.PLAIN, 36));
            contentPanel.add(label1, cc.xywh(3, 5, 3, 1));

            // ---- statusLabel ----
            statusLabel.setText(bundle.getString("JProgramTags.statusLabel.text"));
            statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
            statusLabel.setBackground(Color.yellow);
            statusLabel.setOpaque(true);
            statusLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
            contentPanel.add(statusLabel, cc.xywh(9, 3, 3, 5));

            // ---- nextChipnumberTextField ----
            nextChipnumberTextField.setFont(new Font("Tahoma", Font.PLAIN, 36));
            contentPanel.add(nextChipnumberTextField, cc.xy(7, 5));

            // ---- programButton ----
            programButton.setText(bundle.getString("JProgramTags.programButton.text"));
            programButton.setFont(new Font("Tahoma", Font.PLAIN, 14));
            programButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    programButtonActionPerformed(e);
                }
            });
            contentPanel.add(programButton, cc.xywh(3, 7, 3, 1));

            // ---- bibLabel ----
            bibLabel.setForeground(Color.red);
            bibLabel.setFont(new Font("Tahoma", Font.BOLD, 36));
            bibLabel.setHorizontalAlignment(SwingConstants.CENTER);
            contentPanel.add(bibLabel, cc.xy(11, 9));

            // ---- label3 ----
            label3.setText(bundle.getString("JProgramTags.label3.text"));
            label3.setFont(new Font("Tahoma", Font.PLAIN, 14));
            contentPanel.add(label3, cc.xy(7, 11));

            // ---- tidTextField ----
            tidTextField.setEditable(false);
            tidTextField.setFont(new Font("Tahoma", Font.PLAIN, 14));
            contentPanel.add(tidTextField, cc.xywh(9, 11, 3, 1));

            // ---- label4 ----
            label4.setText(bundle.getString("JProgramTags.label4.text"));
            label4.setFont(new Font("Tahoma", Font.PLAIN, 14));
            contentPanel.add(label4, cc.xy(7, 13));

            // ---- epcTextField ----
            epcTextField.setEditable(false);
            epcTextField.setFont(new Font("Tahoma", Font.PLAIN, 14));
            contentPanel.add(epcTextField, cc.xywh(9, 13, 3, 1));

            // ---- label5 ----
            label5.setText(bundle.getString("JProgramTags.label5.text"));
            label5.setFont(new Font("Tahoma", Font.PLAIN, 14));
            contentPanel.add(label5, cc.xy(7, 15));

            // ---- programmedEpcTextField ----
            programmedEpcTextField.setEditable(false);
            programmedEpcTextField.setFont(new Font("Tahoma", Font.PLAIN, 14));
            contentPanel.add(programmedEpcTextField, cc.xywh(9, 15, 3, 1));

            // ======== scrollPane1 ========
            {
                scrollPane1.setViewportView(tagReadTable);
            }
            contentPanel.add(scrollPane1, cc.xywh(3, 17, 9, 1));

            // ---- lockCheckbox ----
            lockCheckbox.setText(bundle.getString("JProgramTags.lockCheckbox.text"));
            lockCheckbox.setSelected(true);
            lockCheckbox.setFont(new Font("Tahoma", Font.PLAIN, 14));
            lockCheckbox.addItemListener(new ItemListener() {
                @Override
                public void itemStateChanged(ItemEvent e) {
                    checkBox2ItemStateChanged(e);
                }
            });
            contentPanel.add(lockCheckbox, cc.xy(3, 19));

            // ---- label2 ----
            label2.setText(bundle.getString("JProgramTags.label2.text"));
            label2.setFont(new Font("Tahoma", Font.PLAIN, 14));
            contentPanel.add(label2, cc.xy(5, 19));

            // ---- accessPasswordTextField ----
            accessPasswordTextField.setFont(new Font("Tahoma", Font.PLAIN, 14));
            contentPanel.add(accessPasswordTextField, cc.xy(7, 19));

            // ---- label6 ----
            label6.setText(bundle.getString("JProgramTags.label6.text"));
            label6.setFont(new Font("Tahoma", Font.PLAIN, 14));
            contentPanel.add(label6, cc.xy(5, 21));

            // ---- killPasswordTextField ----
            killPasswordTextField.setFont(new Font("Tahoma", Font.PLAIN, 14));
            contentPanel.add(killPasswordTextField, cc.xy(7, 21));

            // ---- checkBox1 ----
            checkBox1.setText(bundle.getString("JProgramTags.checkBox1.text"));
            checkBox1.setEnabled(false);
            contentPanel.add(checkBox1, cc.xy(9, 21));
        }
        dialogPane.add(contentPanel, BorderLayout.EAST);

        // ======== buttonBar ========
        {
            buttonBar.setBorder(Borders.BUTTON_BAR_GAP_BORDER);
            buttonBar.setLayout(
                    new FormLayout(new ColumnSpec[] { FormFactory.GLUE_COLSPEC, FormFactory.BUTTON_COLSPEC },
                            RowSpec.decodeSpecs("pref")));

            // ---- closeButton ----
            closeButton.setText("Cerrar");
            closeButton.setFont(new Font("Tahoma", Font.PLAIN, 14));
            closeButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    closeButtonActionPerformed(e);
                }
            });
            buttonBar.add(closeButton, cc.xy(2, 1));
        }
        dialogPane.add(buttonBar, BorderLayout.SOUTH);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    setSize(700, 625);
    setLocationRelativeTo(getOwner());
    // //GEN-END:initComponents
}

From source file:display.containers.FileManager.java

public Container getPane() {
    //if (gui==null) {

    fileSystemView = FileSystemView.getFileSystemView();
    desktop = Desktop.getDesktop();

    JPanel detailView = new JPanel(new BorderLayout(3, 3));
    //fileTableModel = new FileTableModel();

    table = new JTable();
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setAutoCreateRowSorter(true);//from  w  w  w.j  a va 2s .c o m
    table.setShowVerticalLines(false);
    table.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                Point p = e.getPoint();
                int row = table.convertRowIndexToModel(table.rowAtPoint(p));
                int column = table.convertColumnIndexToModel(table.columnAtPoint(p));
                if (row >= 0 && column >= 0) {
                    mouseDblClicked(row, column);
                }
            }
        }
    });
    table.addKeyListener(new KeyListener() {

        @Override
        public void keyTyped(KeyEvent arg0) {

        }

        @Override
        public void keyReleased(KeyEvent arg0) {
            if (KeyEvent.VK_DELETE == arg0.getKeyCode()) {
                if (mode != 2) {
                    parentFrame.setLock(true);
                    parentFrame.getProgressBarPanel().setVisible(true);
                    Thread t = new Thread(new Runnable() {

                        @Override
                        public void run() {
                            try {
                                deleteSelectedFiles();
                            } catch (IOException e) {
                                JOptionPane.showMessageDialog(parentFrame, "Error during the deletion.",
                                        "Deletion error", JOptionPane.ERROR_MESSAGE);
                                WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.", e);
                            } finally {
                                parentFrame.setLock(false);
                                refresh();
                                parentFrame.getProgressBarPanel().setVisible(false);
                            }
                        }
                    });
                    t.start();

                } else {
                    if (UserProfile.CURRENT_USER.getLevel() == 3) {
                        parentFrame.setLock(true);
                        parentFrame.getProgressBarPanel().setVisible(true);
                        Thread delThread = new Thread(new Runnable() {

                            @Override
                            public void run() {
                                int[] rows = table.getSelectedRows();
                                int[] columns = table.getSelectedColumns();
                                for (int i = 0; i < rows.length; i++) {
                                    if (!continueAction) {
                                        continueAction = true;
                                        return;
                                    }
                                    int row = table.convertRowIndexToModel(rows[i]);
                                    try {
                                        deleteServerFile(row);
                                    } catch (Exception e) {
                                        WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.",
                                                e);
                                    }
                                }
                                refresh();
                                parentFrame.setLock(false);
                                parentFrame.getProgressBarPanel().setVisible(false);
                            }
                        });
                        delThread.start();

                    }
                }
            }
        }

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

        }
    });
    table.getSelectionModel().addListSelectionListener(listSelectionListener);
    JScrollPane tableScroll = new JScrollPane(table);
    Dimension d = tableScroll.getPreferredSize();
    tableScroll.setPreferredSize(new Dimension((int) d.getWidth(), (int) d.getHeight() / 2));
    detailView.add(tableScroll, BorderLayout.CENTER);

    // the File tree
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    treeModel = new DefaultTreeModel(root);
    table.getRowSorter().addRowSorterListener(new RowSorterListener() {

        @Override
        public void sorterChanged(RowSorterEvent e) {
            ((FileTableModel) table.getModel()).fireTableDataChanged();
        }
    });

    // show the file system roots.
    File[] roots = fileSystemView.getRoots();
    for (File fileSystemRoot : roots) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(fileSystemRoot);
        root.add(node);
        //showChildren(node);
        //
        File[] files = fileSystemView.getFiles(fileSystemRoot, true);
        for (File file : files) {
            if (file.isDirectory()) {
                node.add(new DefaultMutableTreeNode(file));
            }
        }
        //
    }
    JScrollPane treeScroll = new JScrollPane();

    Dimension preferredSize = treeScroll.getPreferredSize();
    Dimension widePreferred = new Dimension(200, (int) preferredSize.getHeight());
    treeScroll.setPreferredSize(widePreferred);

    JPanel fileView = new JPanel(new BorderLayout(3, 3));

    detailView.add(fileView, BorderLayout.SOUTH);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeScroll, detailView);

    JPanel simpleOutput = new JPanel(new BorderLayout(3, 3));
    progressBar = new JProgressBar();
    simpleOutput.add(progressBar, BorderLayout.EAST);
    progressBar.setVisible(false);
    showChildren(getCurrentDir().toPath());
    //table.setDragEnabled(true);
    table.setColumnSelectionAllowed(false);

    // Menu popup
    Pmenu = new JPopupMenu();
    changeProjectitem = new JMenuItem("Reassign");
    renameProjectitem = new JMenuItem("Rename");
    twitem = new JMenuItem("To workspace");
    tlitem = new JMenuItem("To local");
    processitem = new JMenuItem("Select for process");
    switch (mode) {
    case 0:
        Pmenu.add(twitem);
        twitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtnlocalTowork().doClick();
            }
        });
        break;
    case 1:
        Pmenu.add(tlitem);
        Pmenu.add(processitem);
        tlitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtnWorkTolocal().doClick();
            }
        });
        processitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        // Recupere les lignes selectionnees
                        int[] indices = table.getSelectedRows();
                        // On recupere les fichiers correspondants
                        ArrayList<File> files = new ArrayList<File>();
                        for (int i = 0; i < indices.length; i++) {
                            int row = table.convertRowIndexToModel(indices[i]);
                            File fi = ((FileTableModel) table.getModel()).getFile(row);
                            if (fi.isDirectory())
                                files.add(fi);
                        }
                        ImageProcessingFrame imf = new ImageProcessingFrame(files);
                    }
                });

            }
        });
        break;
    case 2:
        if (UserProfile.CURRENT_USER.getLevel() == 3) {
            Pmenu.add(changeProjectitem);
            Pmenu.add(renameProjectitem);
        }
        Pmenu.add(twitem);
        twitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtndistToWorkspace().doClick();
            }
        });
        Pmenu.add(tlitem);
        tlitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtndistToLocal().doClick();
            }
        });
        break;
    }
    changeProjectitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            table.setEnabled(false);
            File from = ((FileTableModel) table.getModel())
                    .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0]));

            ReassignProjectPanel reas = new ReassignProjectPanel(from.toPath()); // mode creation de liens
            Popup popup = PopupFactory.getSharedInstance().getPopup(WindowManager.MAINWINDOW, reas,
                    (int) WindowManager.MAINWINDOW.getX() + 200, (int) WindowManager.MAINWINDOW.getY() + 150);
            reas.setPopupWindow(popup);
            popup.show();
            table.setEnabled(true);
        }
    });
    renameProjectitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            table.setEnabled(false);
            final File from = ((FileTableModel) table.getModel())
                    .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0]));
            JDialog.setDefaultLookAndFeelDecorated(true);
            String s = (String) JOptionPane.showInputDialog(WindowManager.MAINWINDOW, "New project name ?",
                    "Rename project", JOptionPane.PLAIN_MESSAGE, null, null, from.getName());

            //If a string was returned, say so.
            if ((s != null) && (s.length() > 0)) {
                ProjectDAO pdao = new MySQLProjectDAO();
                if (new File(from.getParent() + File.separator + s).exists()) {
                    SwingUtilities.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            JDialog.setDefaultLookAndFeelDecorated(true);
                            JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                    "Couldn't rename " + from.getName()
                                            + " (A file with this filename already exists)",
                                    "Renaming error", JOptionPane.ERROR_MESSAGE);
                        }
                    });
                    WindowManager.mwLogger.log(Level.SEVERE,
                            "Error during file project renaming (" + from.getName() + "). [Duplication error]");
                } else {
                    try {
                        boolean succeed = pdao.renameProject(from.getName(), s);
                        if (!succeed) {
                            SwingUtilities.invokeLater(new Runnable() {

                                @Override
                                public void run() {
                                    JDialog.setDefaultLookAndFeelDecorated(true);
                                    JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                            "Couldn't rename " + from.getName()
                                                    + " (no project with this name)",
                                            "Renaming error", JOptionPane.ERROR_MESSAGE);
                                }
                            });
                        } else {
                            from.renameTo(new File(from.getParent() + File.separator + s));
                            // on renomme le repertoire nifti ou dicom correspondant si il existe
                            switch (from.getParentFile().getName()) {
                            case ServerInfo.NRI_ANALYSE_NAME:
                                if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_ANALYSE_NAME,
                                        ServerInfo.NRI_DICOM_NAME)).exists())
                                    try {
                                        Files.move(Paths.get(from.getAbsolutePath().replaceAll(
                                                ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)),
                                                Paths.get(from.getParent().replaceAll(
                                                        ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)
                                                        + File.separator + s));
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                        SwingUtilities.invokeLater(new Runnable() {

                                            @Override
                                            public void run() {
                                                JDialog.setDefaultLookAndFeelDecorated(true);
                                                JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                                        "Couldn't rename " + from.getName()
                                                                + " (error with file system)",
                                                        "Renaming error", JOptionPane.ERROR_MESSAGE);
                                            }
                                        });
                                        WindowManager.mwLogger.log(Level.SEVERE,
                                                "Error during file project renaming (" + from.getName() + ")",
                                                e);
                                    } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)+File.separator+s));
                                break;
                            case ServerInfo.NRI_DICOM_NAME:
                                if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_DICOM_NAME,
                                        ServerInfo.NRI_ANALYSE_NAME)).exists())
                                    try {
                                        Files.move(Paths.get(from.getAbsolutePath().replaceAll(
                                                ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)),
                                                Paths.get(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME,
                                                        ServerInfo.NRI_ANALYSE_NAME) + File.separator + s));
                                    } catch (IOException e) {
                                        SwingUtilities.invokeLater(new Runnable() {

                                            @Override
                                            public void run() {
                                                JDialog.setDefaultLookAndFeelDecorated(true);
                                                JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                                        "Couldn't rename " + from.getName()
                                                                + " (error with file system)",
                                                        "Renaming error", JOptionPane.ERROR_MESSAGE);
                                            }
                                        });
                                        e.printStackTrace();
                                        WindowManager.mwLogger.log(Level.SEVERE,
                                                "Error during file project renaming (" + from.getName() + ")",
                                                e);
                                    } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)+File.separator+s));
                                break;
                            }
                            refresh();
                        }
                    } catch (final SQLException e) {
                        WindowManager.mwLogger.log(Level.SEVERE, "Error during SQL project renaming", e);
                        SwingUtilities.invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                JDialog.setDefaultLookAndFeelDecorated(true);
                                JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                        "Exception : " + e.toString(), "Openning error",
                                        JOptionPane.ERROR_MESSAGE);
                            }
                        });
                    }
                }
            }
            table.setEnabled(true);
        }
    });
    table.addMouseListener(new MouseListener() {

        public void mouseClicked(MouseEvent me) {

        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent me) {
            if (me.getButton() == 3 && table.getSelectedRowCount() > 0) {
                int row = table.convertRowIndexToModel(table.rowAtPoint(me.getPoint()));
                changeProjectitem.setVisible(isPatient(((FileTableModel) table.getModel()).getFile(row)));
                renameProjectitem.setVisible(isProject(((FileTableModel) table.getModel()).getFile(row)));
                Pmenu.show(me.getComponent(), me.getX(), me.getY());
            }
        }
    });
    //

    //}
    return tableScroll;
}

From source file:com.github.dougkelly88.FLIMPlateReaderGUI.SequencingClasses.GUIComponents.XYSequencing.java

private void setControlDefaults() {

    pmdp_ = new PlateMapDrawPanel(this);
    sap_ = SeqAcqProps.getInstance();/* w ww .j  a  va 2 s  .  c om*/
    plateMapBasePanel.setLayout(new BorderLayout());
    plateMapBasePanel.add(pmdp_, BorderLayout.CENTER);

    tableModel_ = new FOVTableModel(pp_);
    searchFOVtableModel_ = new FOVTableModel(pp_); //Not sure if this is the best way, but try it for now.
    tableModel_.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {

        }
    });

    fovTable_ = new JTable();
    fovTable_.setModel(tableModel_);
    fovTable_.setSurrendersFocusOnKeystroke(true);
    fovTable_.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

    JScrollPane scroller = new javax.swing.JScrollPane(fovTable_);
    fovTable_.setPreferredScrollableViewportSize(new java.awt.Dimension(190, 130));
    fovTablePanel.setLayout(new BorderLayout());
    fovTablePanel.add(scroller, BorderLayout.CENTER);

    final JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem deleteItem = new JMenuItem("Delete FOV");
    deleteItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int r = fovTable_.getSelectedRow();
            tableModel_.removeRow(r);
        }
    });
    JMenuItem addItem = new JMenuItem("Add FOV");
    addItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int r = fovTable_.getSelectedRow();
            tableModel_.insertRow(r, new FOV("A1", pp_, 6000));
        }
    });
    JMenuItem goToFOVItem = new JMenuItem("Go to FOV");
    goToFOVItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int r = fovTable_.getSelectedRow();
            //                FOV fov = tableModel_.getData().get(r);
            xyzmi_.gotoFOV(tableModel_.getData().get(r));
            if (!zAsOffset_) {
                double zval = tableModel_.getData().get(r).getZ();
                xyzmi_.moveZAbsolute(zval);
            } else {
                // obviously, this isn't quite right - we want to get
                // the offset of the CURRENT FOV (perhaps from parent in 
                // later implementations?) and subtract from that of the 
                // NEWLY SELECTED FOV. 
                // TODO: fix for proper zAsOffset behaviour. 
                // Wait for move completion
                while (xyzmi_.isStageBusy()) {
                    System.out.println("Stage moving...");
                }
                ;

                if (parent_.checkifAFenabled()) {
                    // If we have gone to the FOV, and have AF, do AF
                    xyzmi_.customAutofocus(parent_.getAFOffset());
                } else {
                    // If we don't have AF, go to the 'good offset position'
                    xyzmi_.moveZAbsolute(parent_.getFixedAFDefault());
                }
                //Now do the relative shift
                xyzmi_.moveZRelative(tableModel_.getData().get(r).getZ());
                System.out.println("Z value" + tableModel_.getData().get(r).getZ());
            }
        }
    });

    popupMenu.add(addItem);
    popupMenu.add(deleteItem);
    popupMenu.add(goToFOVItem);

    fovTable_.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            //                System.out.println("pressed");
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                JTable source = (JTable) e.getSource();
                int row = source.rowAtPoint(e.getPoint());
                int column = source.columnAtPoint(e.getPoint());

                if (!source.isRowSelected(row)) {
                    source.changeSelection(row, column, false, false);
                }
                popupMenu.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });

    //        fovTable_.setDefaultRenderer(FOV.class, new TableRenderer());
    setupInsertComboBox();
}

From source file:regresiones.RegresionSimple.java

public void Resolver(JTabbedPane resultados) {

    for (int i = 0; i < 9; i++) {
        sumatorias[i] = 0.0;/*  w w  w.ja  v a 2 s .  c o  m*/
    }
    try {
        System.out.println("TOTAL DE DATOS: " + N);
        for (int i = 0; i < N; i++) {
            xiyi[i] = datos[i][0] * datos[i][1];
            System.out.println("X*Y" + i + ": " + xiyi[i]);
            x2[i] = datos[i][0] * datos[i][0]; //elevamos al cuadrado las x's
            y2[i] = datos[i][1] * datos[i][1]; //elevamos al cuadrado las y's
            sumatorias[0] += datos[i][0]; //sumatoria de x
            sumatorias[1] += datos[i][1]; //sumatoria de y

        }
        //sumatoria de xi*yi
        for (int j = 0; j < N; j++) {
            sumatorias[2] += xiyi[j];
        }

        //sumatoria de x^2
        for (int j = 0; j < N; j++) {
            sumatorias[3] += x2[j];
        }

        //sumatoria de y^2
        for (int j = 0; j < N; j++) {
            sumatorias[4] += y2[j];
        }

        mediax = sumatorias[0] / N;
        mediay = sumatorias[1] / N;

        System.out.println("RAIS 25: " + Math.sqrt(25));

        DecimalFormat df = new DecimalFormat("##.##");
        df.setRoundingMode(RoundingMode.DOWN);
        System.out.println("redondeo x^2-- " + df.format(sumatorias[3]));
        System.out.println("redondeo y^2-- " + df.format(sumatorias[4]));
        redondeoSumatoriax2 = Double.parseDouble(df.format(sumatorias[3]));
        redondeoSumatoriay2 = Double.parseDouble(df.format(sumatorias[4]));
        dxy = ((sumatorias[2]) / N) - mediax * mediay;
        dy = Math.sqrt(((redondeoSumatoriay2 / N) - (mediay * mediay)));
        dx = Math.sqrt(((redondeoSumatoriax2 / N) - (mediax * mediax)));

        b1 = ((sumatorias[2] * N) - sumatorias[0] * sumatorias[1])
                / ((sumatorias[3] * N) - (sumatorias[0] * sumatorias[0]));
        b0 = (sumatorias[1] / N) - ((b1 * sumatorias[0]) / N);

        // Y ESTIMADA
        for (int i = 0; i < N; i++) {
            yEstimada[i] = b0 + (b1 * datos[i][0]);
        }

        Se = Math.sqrt((sumatorias[4] - (b0 * sumatorias[1]) - (b1 * sumatorias[2])) / (N - 2));
        r = dxy / (dx * dy);
        System.out.println("sum x: " + sumatorias[0]);
        System.out.println("sum y: " + sumatorias[1]);
        System.out.println("sum x*y: " + sumatorias[2]);
        System.out.println("sum x^2: " + sumatorias[3]);
        System.out.println("sum y^2: " + sumatorias[4]);
        System.out.println("DX7: " + dxy);
        System.out.println("DY: " + dy);
        System.out.println("DX: " + dx);
        System.out.println("B0: " + b0);
        System.out.println("B1: " + b1);

        // mostramos resultados para la pestaa resultados***********************************************************************
        JPanel panel = new JPanel(new BorderLayout());
        panel.setBackground(Color.white);
        JLabel titulo = new JLabel("Resultados");//creamos el titulo
        panel.add(titulo, BorderLayout.PAGE_START);//lo agregamos al inicio
        jtable = new JTable();//creamos la tabla a mostrar
        jtable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
        jtable.setFont(new java.awt.Font("Arial", 1, 14));
        jtable.setColumnSelectionAllowed(true);
        jtable.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
        jtable.setInheritsPopupMenu(true);
        jtable.setMinimumSize(new java.awt.Dimension(80, 80));
        String[] titulos = { "X", "Y", "Xi*Yi", "X2", "Y2", "Y estimada" };//los titulos de la tabla
        arregloFinal = new String[N][6];
        DecimalFormat formato = new DecimalFormat("0.00");
        for (int i = 0; i < N; i++) {//armamos el arreglo
            arregloFinal[i][0] = datos[i][0] + ""; //X
            arregloFinal[i][1] = datos[i][1] + "";//Y
            arregloFinal[i][2] = formato.format(xiyi[i]);
            arregloFinal[i][3] = formato.format(x2[i]);
            arregloFinal[i][4] = formato.format(y2[i]);
            arregloFinal[i][5] = formato.format(yEstimada[i]);
        }
        DefaultTableModel TableModel = new DefaultTableModel(arregloFinal, titulos);
        jtable.setModel(TableModel);
        JScrollPane jScrollPane1 = new JScrollPane();
        jScrollPane1.setViewportView(jtable);
        jtable.getColumnModel().getSelectionModel()
                .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        panel.add(jScrollPane1, BorderLayout.CENTER);
        JPanel panel2 = new JPanel(new GridLayout(0, 4));//creo un panel con rejilla de 4 columnas
        JLabel etiquetaN = new JLabel("N");
        JTextField cajaN = new JTextField();
        cajaN.setText(N + "");
        JLabel etiquetab0 = new JLabel("b0");
        JTextField cajab0 = new JTextField();
        cajab0.setText(b0 + "");
        JLabel etiquetab1 = new JLabel("b1");
        JTextField cajab1 = new JTextField();
        cajab1.setText(b1 + "");
        JLabel etiquetadxy = new JLabel("DXy");
        JTextField cajadxy = new JTextField();
        cajadxy.setText(dxy + "");
        JLabel etiquetadx = new JLabel("DX");
        JTextField cajadx = new JTextField();
        cajadx.setText(dx + "");
        JLabel etiquetady = new JLabel("DY");
        JTextField cajady = new JTextField();
        cajady.setText(dy + "");
        JLabel etiquetaR = new JLabel("R");
        JTextField cajaR = new JTextField();
        cajaR.setText(r + "");
        JLabel etiquetaSE = new JLabel("SE");
        JTextField cajaSE = new JTextField();
        cajaSE.setText(Se + "");
        JButton boton = new JButton("Exportar a PDF");
        boton.addActionListener(this);
        panel2.add(etiquetaN);
        panel2.add(cajaN);
        panel2.add(etiquetab0);
        panel2.add(cajab0);
        panel2.add(etiquetab1);
        panel2.add(cajab1);
        panel2.add(etiquetadxy);
        panel2.add(cajadxy);
        panel2.add(etiquetadx);
        panel2.add(cajadx);
        panel2.add(etiquetady);
        panel2.add(cajady);
        panel2.add(etiquetaR);
        panel2.add(cajaR);
        panel2.add(etiquetaSE);
        panel2.add(cajaSE);
        panel2.add(boton);
        panel.add(panel2, BorderLayout.SOUTH);//agrego el panel2 con rejilla en el panel principal al sur
        resultados.addTab("resultado", panel);
        //**************************************************************************************
        //intervalos de confianza
        JPanel intervalos = new JPanel(new BorderLayout());
        JPanel variables = new JPanel(new GridLayout(0, 2));
        JLabel variableX1 = new JLabel("X1");
        cajaVariableX1 = new JTextField();
        boton = new JButton("calcular");
        boton.addActionListener(this);
        JLabel variableEfectividad = new JLabel("Efectividad");
        String[] efectividades = { "80", "85", "90", "95", "99" };
        combo = new JComboBox(efectividades);
        variables.add(variableX1);
        variables.add(cajaVariableX1);
        variables.add(variableEfectividad);
        variables.add(combo);
        variables.add(boton);//comentario
        //cometario2
        intervalos.add(variables, BorderLayout.NORTH);
        jtable2 = new JTable();//creamos la tabla a mostrar
        jtable2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
        jtable2.setFont(new java.awt.Font("Arial", 1, 14));
        jtable2.setColumnSelectionAllowed(true);
        jtable2.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
        jtable2.setInheritsPopupMenu(true);
        jtable2.setMinimumSize(new java.awt.Dimension(80, 80));
        String[] titulos2 = { "Y estimada", "Li", "Ls" };//los titulos de la tabla
        String[][] pruebaIntervalos = { { "", "", "" } };
        DefaultTableModel TableModel2 = new DefaultTableModel(pruebaIntervalos, titulos2);
        jtable2.setModel(TableModel2);
        JScrollPane jScrollPane2 = new JScrollPane();
        jScrollPane2.setViewportView(jtable2);
        jtable2.getColumnModel().getSelectionModel()
                .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        intervalos.add(jScrollPane2, BorderLayout.CENTER);
        resultados.addTab("intervalos", intervalos);
        // ***********************************************************************
        JPanel graficas = new JPanel(new GridLayout(0, 1));
        XYDataset dataset = createSampleDataset();
        JFreeChart chart = ChartFactory.createXYLineChart("Grafica", "X", "Y", dataset,
                PlotOrientation.VERTICAL, true, false, false);
        XYPlot plot = (XYPlot) chart.getPlot();
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setSeriesLinesVisible(0, true);
        renderer.setSeriesShapesVisible(0, true);
        renderer.setSeriesLinesVisible(1, true);
        renderer.setSeriesShapesVisible(1, true);
        plot.setRenderer(renderer);
        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
        graficas.add(chartPanel);//agregamos la primer grafica
        resultados.addTab("Graficas", graficas);
        //IMPRIMIR JTABLE
        /* MessageFormat headerFormat = new MessageFormat("MI CABECERA");
         MessageFormat footerFormat = new MessageFormat("- Pgina {0} -");
         jtable.print(PrintMode.FIT_WIDTH, headerFormat, footerFormat);
         */

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:gtu._work.ui.RenameUI.java

private void initGUI() {
    try {//from   w ww  .  j  ava2s .  c o m
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                jTabbedPane1.addTab("jPanel1", null, jPanel1, null);
                {
                    jLabel1 = new JLabel();
                    jPanel1.add(jLabel1);
                    jLabel1.setText("\u9078\u64c7\u76ee\u9304");
                }
                {
                    srcDirText = new JTextField();
                    JCommonUtil.jTextFieldSetFilePathMouseEvent(srcDirText, true);
                    jPanel1.add(srcDirText);
                    srcDirText.setPreferredSize(new java.awt.Dimension(470, 22));
                }
                {
                    jLabel2 = new JLabel();
                    jPanel1.add(jLabel2);
                    jLabel2.setText("\u6a94\u540dRegex");
                    jLabel2.setPreferredSize(new java.awt.Dimension(68, 15));
                }
                {
                    findFileRegexText = new JTextField();
                    jPanel1.add(findFileRegexText);
                    findFileRegexText.setPreferredSize(new java.awt.Dimension(446, 22));
                }
                {
                    jLabel3 = new JLabel();
                    jPanel1.add(jLabel3);
                    jLabel3.setText("\u4fee\u6539\u5f8c\u6a94\u540d");
                    jLabel3.setPreferredSize(new java.awt.Dimension(68, 15));
                }
                {
                    renameRegexText = new JTextField();
                    jPanel1.add(renameRegexText);
                    renameRegexText.setPreferredSize(new java.awt.Dimension(446, 22));
                }
                {
                    scanBtn = new JButton();
                    jPanel1.add(scanBtn);
                    scanBtn.setText("\u6383\u63cf\u76ee\u9304");
                    scanBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            scanBtnActionPerformed();
                        }
                    });
                }
                {
                    usePatternNewNameBtn = new JButton();
                    jPanel1.add(usePatternNewNameBtn);
                    usePatternNewNameBtn.setText("\u5957\u7528\u6a94\u540d");
                    usePatternNewNameBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            usePatternNewNameBtnActionPerformed();
                        }
                    });
                }
                {
                    executeBtn = new JButton();
                    jPanel1.add(executeBtn);
                    executeBtn.setText("\u4ee5\u8868\u683c\u8a2d\u5b9a\u66f4\u6b63");
                    executeBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            executeBtnActionPerformed();
                        }
                    });
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("jPanel2", null, jPanel2, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel2.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(552, 338));
                    {
                        renameTable = new JTable();
                        jScrollPane1.setViewportView(renameTable);
                        JTableUtil.defaultSetting(renameTable);
                        renameTable.setModel(createNewModel());
                    }
                }
            }
        }
        pack();
        this.setSize(565, 392);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:ru.develgame.jflickrorganizer.MainForm.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*  ww  w.j ava2 s.  c  o m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jLabelBackupFolder = new javax.swing.JLabel();
    jTextFieldBackupFolder = new javax.swing.JTextField();
    jButtonChooseBackupFolder = new javax.swing.JButton();
    jButtonBackup = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTreeAlbums = new javax.swing.JTree();
    jScrollPane2 = new javax.swing.JScrollPane();
    jTablePhotos = new JTable() {
        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component component = super.prepareRenderer(renderer, row, column);
            int rendererWidth = component.getPreferredSize().width + 5;
            TableColumn tableColumn = getColumnModel().getColumn(column);
            tableColumn.setPreferredWidth(
                    Math.max(rendererWidth + getIntercellSpacing().width, tableColumn.getPreferredWidth()));
            return component;
        }
    };
    jComboBoxVisibility = new javax.swing.JComboBox<>();
    jPanel1 = new javax.swing.JPanel();
    jLabelAll = new javax.swing.JLabel();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItemSetPassword = new javax.swing.JMenuItem();
    jMenuItemExit = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("MainForm"); // NOI18N
    setTitle(bundle.getString("MainForm.title")); // NOI18N
    setMinimumSize(new java.awt.Dimension(1024, 717));
    setName("Form"); // NOI18N

    jLabelBackupFolder.setText(bundle.getString("MainForm.jLabelBackupFolder.text")); // NOI18N
    jLabelBackupFolder.setName("jLabelBackupFolder"); // NOI18N

    jTextFieldBackupFolder.setName("jTextFieldBackupFolder"); // NOI18N

    jButtonChooseBackupFolder.setText(bundle.getString("MainForm.jButtonChooseBackupFolder.text")); // NOI18N
    jButtonChooseBackupFolder.setName("jButtonChooseBackupFolder"); // NOI18N
    jButtonChooseBackupFolder.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonChooseBackupFolderActionPerformed(evt);
        }
    });

    jButtonBackup.setText(bundle.getString("MainForm.jButtonBackup.text")); // NOI18N
    jButtonBackup.setName("jButtonBackup"); // NOI18N
    jButtonBackup.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonBackupActionPerformed(evt);
        }
    });

    jScrollPane1.setName("jScrollPane1"); // NOI18N

    jTreeAlbums.setName("jTreeAlbums"); // NOI18N
    jScrollPane1.setViewportView(jTreeAlbums);

    jScrollPane2.setName("jScrollPane2"); // NOI18N

    jTablePhotos.setAutoCreateRowSorter(true);
    jTablePhotos.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

    }, new String[] {

    }));
    jTablePhotos.setToolTipText(bundle.getString("MainForm.jTablePhotos.toolTipText")); // NOI18N
    jTablePhotos.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
    jTablePhotos.setName("jTablePhotos"); // NOI18N
    jTablePhotos.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jScrollPane2.setViewportView(jTablePhotos);

    jComboBoxVisibility.setName("jComboBoxVisibility"); // NOI18N

    jPanel1.setName("jPanel1"); // NOI18N

    jLabelAll.setText(bundle.getString("MainForm.jLabelAll.text")); // NOI18N
    jLabelAll.setName("jLabelAll"); // NOI18N

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout
            .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                            jPanel1Layout.createSequentialGroup()
                                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabelAll).addContainerGap()));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE).addComponent(jLabelAll)));

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

    jMenu1.setText(bundle.getString("MainForm.jMenu1.text")); // NOI18N
    jMenu1.setName("jMenu1"); // NOI18N

    jMenuItemSetPassword.setText(bundle.getString("MainForm.jMenuItemSetPassword.text")); // NOI18N
    jMenuItemSetPassword.setName("jMenuItemSetPassword"); // NOI18N
    jMenuItemSetPassword.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemSetPasswordActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItemSetPassword);

    jMenuItemExit.setText(bundle.getString("MainForm.jMenuItemExit.text")); // NOI18N
    jMenuItemExit.setName("jMenuItemExit"); // NOI18N
    jMenuItemExit.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemExitActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItemExit);

    jMenuBar1.add(jMenu1);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup().addComponent(jLabelBackupFolder)
                                    .addGap(68, 68, 68).addComponent(jTextFieldBackupFolder)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jButtonChooseBackupFolder)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jButtonBackup))
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 213,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    784, Short.MAX_VALUE)
                                            .addGroup(layout.createSequentialGroup()
                                                    .addComponent(jComboBoxVisibility,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 271,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(0, 0, Short.MAX_VALUE)))))
                    .addContainerGap())
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
            javax.swing.GroupLayout.Alignment.TRAILING,
            layout.createSequentialGroup().addContainerGap().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldBackupFolder, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonBackup).addComponent(jButtonChooseBackupFolder)
                    .addComponent(jLabelBackupFolder))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(jComboBoxVisibility, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 590,
                                            Short.MAX_VALUE))
                            .addComponent(jScrollPane1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jPanel1,
                            javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.PREFERRED_SIZE)));

    pack();
}

From source file:regresiones.RegresionMultiple.java

private void pintar(Double[] Yestimada, JTabbedPane resultados, Double[][] auxiliar) {
    // mostramos resultados para la pestaa resultados***********************************************************************
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(Color.white);
    JLabel titulo = new JLabel("Resultados");//creamos el titulo
    panel.add(titulo, BorderLayout.PAGE_START);//lo agregamos al inicio
    jtable = new JTable();//creamos la tabla a mostrar
    jtable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
    jtable.setFont(new java.awt.Font("Arial", 1, 14));
    jtable.setColumnSelectionAllowed(true);
    jtable.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
    jtable.setInheritsPopupMenu(true);/* www.j a v a  2  s  .  com*/
    jtable.setMinimumSize(new java.awt.Dimension(80, 80));
    String[] titulos = { "X1", "X2", "Y", "Y estimada", "X1^2", "X2^2", "X1*Y", "X2*Y", "Y-Y estimada" };//los titulos de la tabla
    arregloFinal = new String[N][9];
    DecimalFormat formato = new DecimalFormat("0.00");
    for (int i = 0; i < N; i++) {//armamos el arreglo
        arregloFinal[i][0] = datos[i][0] + "";
        arregloFinal[i][1] = datos[i][1] + "";
        arregloFinal[i][2] = datos[i][2] + "";
        arregloFinal[i][3] = formato.format(Yestimada[i]);
        arregloFinal[i][4] = formato.format(auxiliar[i][0]);
        arregloFinal[i][5] = formato.format(auxiliar[i][1]);
        arregloFinal[i][6] = formato.format(auxiliar[i][2]);
        arregloFinal[i][7] = formato.format(auxiliar[i][3]);
        arregloFinal[i][8] = formato.format(auxiliar[i][4]);
    }
    DefaultTableModel TableModel = new DefaultTableModel(arregloFinal, titulos);
    jtable.setModel(TableModel);
    JScrollPane jScrollPane1 = new JScrollPane();
    jScrollPane1.setViewportView(jtable);
    jtable.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    panel.add(jScrollPane1, BorderLayout.CENTER);
    JPanel panel2 = new JPanel(new GridLayout(0, 6));//creo un panel con rejilla de 4 columnas
    JLabel etiquetaN = new JLabel("N");
    JTextField cajaN = new JTextField();
    cajaN.setText(N + "");
    cajaN.setEditable(false);

    JLabel etiquetaK = new JLabel("K");
    JTextField cajaK = new JTextField();
    cajaK.setText("2");
    cajaK.setEditable(false);

    JLabel etiquetab0 = new JLabel("b0");
    JTextField cajab0 = new JTextField();
    cajab0.setText(formato.format(b0) + "");
    cajab0.setEditable(false);

    JLabel etiquetab1 = new JLabel("b1");
    JTextField cajab1 = new JTextField();
    cajab1.setText(formato.format(b1) + "");
    cajab1.setEditable(false);

    JLabel etiquetab2 = new JLabel("b2");
    JTextField cajab2 = new JTextField();
    cajab2.setText(formato.format(b2) + "");
    cajab2.setEditable(false);

    JLabel etiquetaSe = new JLabel("Se");
    JTextField cajaSe = new JTextField();
    cajaSe.setText(Se + "");
    cajaSe.setEditable(false);
    cajaSe.setAutoscrolls(true);

    JButton botonI = new JButton("Exportar a PDF");
    botonI.addActionListener(this);

    panel2.add(etiquetaN);
    panel2.add(cajaN);
    panel2.add(etiquetaK);
    panel2.add(cajaK);
    panel2.add(etiquetab2);
    panel2.add(etiquetab0);
    panel2.add(cajab0);
    panel2.add(etiquetab1);
    panel2.add(cajab1);
    panel2.add(etiquetab2);
    panel2.add(cajab2);
    panel2.add(etiquetaSe);
    panel2.add(cajaSe);
    panel2.add(botonI);
    panel.add(panel2, BorderLayout.SOUTH);//agrego el panel2 con rejilla en el panel principal al sur
    resultados.addTab("resultado", panel);
    //**************************************************************************************
    //intervalos de confianza
    JPanel intervalos = new JPanel(new BorderLayout());
    JPanel variables = new JPanel(new GridLayout(0, 2));
    JLabel variableX1 = new JLabel("X1");
    cajaVariableX1 = new JTextField();
    JLabel variableX2 = new JLabel("X2");
    cajaVariableX2 = new JTextField();
    boton = new JButton("calcular");
    boton.addActionListener(this);
    JLabel variableEfectividad = new JLabel("Efectividad");
    String[] efectividades = { "80", "85", "90", "95", "99" };
    combo = new JComboBox(efectividades);
    variables.add(variableX1);
    variables.add(cajaVariableX1);
    variables.add(variableX2);
    variables.add(cajaVariableX2);
    variables.add(variableEfectividad);
    variables.add(combo);
    variables.add(boton);
    intervalos.add(variables, BorderLayout.NORTH);
    jtable2 = new JTable();//creamos la tabla a mostrar
    jtable2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
    jtable2.setFont(new java.awt.Font("Arial", 1, 14));
    jtable2.setColumnSelectionAllowed(true);
    jtable2.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
    jtable2.setInheritsPopupMenu(true);
    jtable2.setMinimumSize(new java.awt.Dimension(80, 80));
    String[] titulos2 = { "Y estimada", "Li", "Ls" };//los titulos de la tabla
    String[][] pruebaIntervalos = { { "", "", "" } };
    DefaultTableModel TableModel2 = new DefaultTableModel(pruebaIntervalos, titulos2);
    jtable2.setModel(TableModel2);
    JScrollPane jScrollPane2 = new JScrollPane();
    jScrollPane2.setViewportView(jtable2);
    jtable2.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    intervalos.add(jScrollPane2, BorderLayout.CENTER);
    resultados.addTab("intervalos", intervalos);
    //***************************************************************************
    JPanel graficas = new JPanel(new GridLayout(0, 1));
    XYDataset dataset = createSampleDataset(Yestimada, 1);
    JFreeChart chart = ChartFactory.createXYLineChart("Grafica 1 - X1", "X", "Y", dataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, true);
    plot.setRenderer(renderer);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    graficas.add(chartPanel);//agregamos la primer grafica
    //********** creamos la segunda grafica
    XYDataset dataset2 = createSampleDataset(Yestimada, 2);
    JFreeChart chart2 = ChartFactory.createXYLineChart("Grafica 2 -X2", "X", "Y", dataset2,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot2 = (XYPlot) chart2.getPlot();
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, true);
    renderer2.setSeriesShapesVisible(0, true);
    renderer2.setSeriesLinesVisible(1, true);
    renderer2.setSeriesShapesVisible(1, true);
    plot2.setRenderer(renderer2);
    final ChartPanel chartPanel2 = new ChartPanel(chart2);
    chartPanel2.setPreferredSize(new java.awt.Dimension(500, 300));
    graficas.add(chartPanel2);
    resultados.addTab("graficas", graficas);
}