Example usage for javax.swing.table DefaultTableModel DefaultTableModel

List of usage examples for javax.swing.table DefaultTableModel DefaultTableModel

Introduction

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

Prototype

public DefaultTableModel(Object[][] data, Object[] columnNames) 

Source Link

Document

Constructs a DefaultTableModel and initializes the table by passing data and columnNames to the setDataVector method.

Usage

From source file:op.care.nursingprocess.DlgNursingProcess.java

/**
 * This method is called from within the constructor to
 * initialize the form.//from   w  ww  .  ja  va2  s  . c o  m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    jPanel5 = new JPanel();
    lblTopic = new JLabel();
    txtStichwort = new JTextField();
    lblCat = new JLabel();
    cmbKategorie = new JComboBox<>();
    panel4 = new JPanel();
    lblSituation = new JLabel();
    btnPopoutSituation = new JButton();
    jScrollPane3 = new JScrollPane();
    txtSituation = new JTextArea();
    panel5 = new JPanel();
    lblGoal = new JLabel();
    btnPopoutGoal = new JButton();
    jScrollPane1 = new JScrollPane();
    txtZiele = new JTextArea();
    lblFirstRevision = new JLabel();
    jdcKontrolle = new JDateChooser();
    panel2 = new JPanel();
    jspPlanung = new JScrollPane();
    tblPlanung = new JTable();
    panel3 = new JPanel();
    btnAddIntervention = new JButton();
    panel1 = new JPanel();
    btnCancel = new JButton();
    btnSave = new JButton();

    //======== this ========
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("14dlu, $lcgap, 280dlu:grow, $ugap, pref, $lcgap, 14dlu",
            "fill:14dlu, $lgap, fill:default:grow, $rgap, pref, $lgap, 14dlu"));

    //======== jPanel5 ========
    {
        jPanel5.setLayout(new FormLayout("default, $lcgap, default:grow",
                "fill:default, $rgap, default, 2*($lgap, fill:default:grow), $lgap, 70dlu, $lgap, pref"));

        //---- lblTopic ----
        lblTopic.setFont(new Font("Arial", Font.PLAIN, 14));
        lblTopic.setText("Stichwort");
        jPanel5.add(lblTopic, CC.xy(1, 1, CC.DEFAULT, CC.TOP));

        //---- txtStichwort ----
        txtStichwort.setFont(new Font("Arial", Font.BOLD, 20));
        txtStichwort.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                txtStichwortFocusGained(e);
            }
        });
        jPanel5.add(txtStichwort, CC.xy(3, 1));

        //---- lblCat ----
        lblCat.setFont(new Font("Arial", Font.PLAIN, 14));
        lblCat.setText("Kategorie");
        jPanel5.add(lblCat, CC.xy(1, 3));

        //---- cmbKategorie ----
        cmbKategorie
                .setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbKategorie.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel5.add(cmbKategorie, CC.xy(3, 3));

        //======== panel4 ========
        {
            panel4.setLayout(new BorderLayout());

            //---- lblSituation ----
            lblSituation.setFont(new Font("Arial", Font.PLAIN, 14));
            lblSituation.setText("Situation");
            panel4.add(lblSituation, BorderLayout.CENTER);

            //---- btnPopoutSituation ----
            btnPopoutSituation.setText(null);
            btnPopoutSituation.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/popup.png")));
            btnPopoutSituation.setBorderPainted(false);
            btnPopoutSituation.setContentAreaFilled(false);
            btnPopoutSituation
                    .setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
            btnPopoutSituation.setBorder(null);
            btnPopoutSituation.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnPopoutSituation.addActionListener(e -> btnPopoutSituationActionPerformed(e));
            panel4.add(btnPopoutSituation, BorderLayout.EAST);
        }
        jPanel5.add(panel4, CC.xy(1, 5, CC.DEFAULT, CC.TOP));

        //======== jScrollPane3 ========
        {

            //---- txtSituation ----
            txtSituation.setColumns(20);
            txtSituation.setLineWrap(true);
            txtSituation.setRows(5);
            txtSituation.setWrapStyleWord(true);
            txtSituation.setFont(new Font("Arial", Font.PLAIN, 14));
            txtSituation.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtSituationFocusGained(e);
                }
            });
            jScrollPane3.setViewportView(txtSituation);
        }
        jPanel5.add(jScrollPane3, CC.xy(3, 5));

        //======== panel5 ========
        {
            panel5.setLayout(new BorderLayout());

            //---- lblGoal ----
            lblGoal.setFont(new Font("Arial", Font.PLAIN, 14));
            lblGoal.setText("Ziele");
            panel5.add(lblGoal, BorderLayout.CENTER);

            //---- btnPopoutGoal ----
            btnPopoutGoal.setText(null);
            btnPopoutGoal.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/popup.png")));
            btnPopoutGoal.setBorderPainted(false);
            btnPopoutGoal.setContentAreaFilled(false);
            btnPopoutGoal
                    .setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
            btnPopoutGoal.setBorder(null);
            btnPopoutGoal.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnPopoutGoal.addActionListener(e -> btnPopoutGoalActionPerformed(e));
            panel5.add(btnPopoutGoal, BorderLayout.EAST);
        }
        jPanel5.add(panel5, CC.xy(1, 7, CC.DEFAULT, CC.TOP));

        //======== jScrollPane1 ========
        {

            //---- txtZiele ----
            txtZiele.setColumns(20);
            txtZiele.setLineWrap(true);
            txtZiele.setRows(5);
            txtZiele.setWrapStyleWord(true);
            txtZiele.setFont(new Font("Arial", Font.PLAIN, 14));
            txtZiele.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtZieleFocusGained(e);
                }
            });
            jScrollPane1.setViewportView(txtZiele);
        }
        jPanel5.add(jScrollPane1, CC.xy(3, 7));

        //---- lblFirstRevision ----
        lblFirstRevision.setFont(new Font("Arial", Font.PLAIN, 14));
        lblFirstRevision.setText("Erste Kontrolle am");
        jPanel5.add(lblFirstRevision, CC.xy(1, 11));

        //---- jdcKontrolle ----
        jdcKontrolle.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel5.add(jdcKontrolle, CC.xy(3, 11));
    }
    contentPane.add(jPanel5, CC.xy(3, 3, CC.DEFAULT, CC.FILL));

    //======== panel2 ========
    {
        panel2.setLayout(new FormLayout("default:grow", "default, $lgap, default"));

        //======== jspPlanung ========
        {
            jspPlanung.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentResized(ComponentEvent e) {
                    jspPlanungComponentResized(e);
                }
            });

            //---- tblPlanung ----
            tblPlanung.setModel(new DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null }, },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
            tblPlanung.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
            tblPlanung.addMouseListener(new MouseAdapter() {
                @Override
                public void mousePressed(MouseEvent e) {
                    tblPlanungMousePressed(e);
                }
            });
            jspPlanung.setViewportView(tblPlanung);
        }
        panel2.add(jspPlanung, CC.xy(1, 1));

        //======== panel3 ========
        {
            panel3.setLayout(new BoxLayout(panel3, BoxLayout.X_AXIS));

            //---- btnAddIntervention ----
            btnAddIntervention.setText(null);
            btnAddIntervention.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnAddIntervention.setContentAreaFilled(false);
            btnAddIntervention.setBorderPainted(false);
            btnAddIntervention.setBorder(null);
            btnAddIntervention
                    .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnAddIntervention.addActionListener(e -> btnAddInterventionActionPerformed(e));
            panel3.add(btnAddIntervention);
        }
        panel2.add(panel3, CC.xy(1, 3));
    }
    contentPane.add(panel2, CC.xy(5, 3));

    //======== panel1 ========
    {
        panel1.setLayout(new HorizontalLayout(5));

        //---- btnCancel ----
        btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
        btnCancel.setText(null);
        btnCancel.addActionListener(e -> btnCancelActionPerformed(e));
        panel1.add(btnCancel);

        //---- btnSave ----
        btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
        btnSave.setText(null);
        btnSave.addActionListener(e -> btnSaveActionPerformed(e));
        panel1.add(btnSave);
    }
    contentPane.add(panel1, CC.xy(5, 5, CC.RIGHT, CC.DEFAULT));
    setSize(1145, 695);
    setLocationRelativeTo(getOwner());
}

From source file:op.care.prescription.DlgRegular.java

/**
 * This method is called from within the constructor to
 * initialize the form./*from w w w.  j a va  2 s. c om*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    jPanel1 = new JPanel();
    txtMed = new JXSearchField();
    cmbMed = new JComboBox<>();
    panel4 = new JPanel();
    btnMed = new JButton();
    cmbIntervention = new JComboBox<>();
    txtIntervention = new JXSearchField();
    jPanel8 = new JPanel();
    jspDosis = new JScrollPane();
    tblDosis = new JTable();
    panel2 = new JPanel();
    btnAddDosis = new JButton();
    jPanel3 = new JPanel();
    pnlOFF = new JPanel();
    rbActive = new JRadioButton();
    rbDate = new JRadioButton();
    txtTo = new JTextField();
    rbEndOfPackage = new JRadioButton();
    jScrollPane3 = new JScrollPane();
    txtBemerkung = new JTextPane();
    lblText = new JLabel();
    pnlON = new JPanel();
    cmbDocON = new JComboBox<>();
    btnAddGP = new JButton();
    cmbHospitalON = new JComboBox<>();
    btnAddHospital = new JButton();
    panel1 = new JPanel();
    btnClose = new JButton();
    btnSave = new JButton();
    lblTX = new JLabel();

    //======== this ========
    setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    setResizable(false);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("$rgap, $lcgap, default, $lcgap, pref, $lcgap, $rgap",
            "$rgap, $lgap, fill:default:grow, $lgap, fill:default, $lgap, $rgap"));

    //======== jPanel1 ========
    {
        jPanel1.setBorder(null);
        jPanel1.setLayout(new FormLayout("68dlu, $lcgap, 284dlu, $lcgap, pref",
                "2*(16dlu, $lgap), default, $lgap, fill:default:grow"));

        //---- txtMed ----
        txtMed.setFont(new Font("Arial", Font.PLAIN, 14));
        txtMed.setPrompt("Medikamente");
        txtMed.setFocusBehavior(PromptSupport.FocusBehavior.HIGHLIGHT_PROMPT);
        txtMed.addActionListener(e -> txtMedActionPerformed(e));
        txtMed.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                txtMedFocusGained(e);
            }
        });
        jPanel1.add(txtMed, CC.xy(1, 1));

        //---- cmbMed ----
        cmbMed.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbMed.setFont(new Font("Arial", Font.PLAIN, 14));
        cmbMed.addItemListener(e -> cmbMedItemStateChanged(e));
        jPanel1.add(cmbMed, CC.xy(3, 1));

        //======== panel4 ========
        {
            panel4.setLayout(new BoxLayout(panel4, BoxLayout.LINE_AXIS));

            //---- btnMed ----
            btnMed.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnMed.setBorderPainted(false);
            btnMed.setBorder(null);
            btnMed.setContentAreaFilled(false);
            btnMed.setToolTipText("Neues Medikament eintragen");
            btnMed.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnMed.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnMed.addActionListener(e -> btnMedActionPerformed(e));
            panel4.add(btnMed);
        }
        jPanel1.add(panel4, CC.xy(5, 1));

        //---- cmbIntervention ----
        cmbIntervention
                .setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbIntervention.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel1.add(cmbIntervention, CC.xywh(3, 3, 3, 1));

        //---- txtIntervention ----
        txtIntervention.setFont(new Font("Arial", Font.PLAIN, 14));
        txtIntervention.setPrompt("Massnahmen");
        txtIntervention.addActionListener(e -> txtMassActionPerformed(e));
        jPanel1.add(txtIntervention, CC.xy(1, 3));

        //======== jPanel8 ========
        {
            jPanel8.setBorder(new TitledBorder(null, "Dosis / H\u00e4ufigkeit", TitledBorder.LEADING,
                    TitledBorder.DEFAULT_POSITION, new Font("Arial", Font.PLAIN, 14)));
            jPanel8.setFont(new Font("Arial", Font.PLAIN, 14));
            jPanel8.setLayout(new FormLayout("370dlu", "fill:default:grow, $lgap, pref"));

            //======== jspDosis ========
            {
                jspDosis.setToolTipText(null);

                //---- tblDosis ----
                tblDosis.setModel(new DefaultTableModel(
                        new Object[][] { { null, null, null, null }, { null, null, null, null },
                                { null, null, null, null }, { null, null, null, null }, },
                        new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
                tblDosis.setSurrendersFocusOnKeystroke(true);
                tblDosis.setToolTipText(null);
                tblDosis.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mousePressed(MouseEvent e) {
                        tblDosisMousePressed(e);
                    }
                });
                jspDosis.setViewportView(tblDosis);
            }
            jPanel8.add(jspDosis, CC.xy(1, 1));

            //======== panel2 ========
            {
                panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS));

                //---- btnAddDosis ----
                btnAddDosis.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
                btnAddDosis.setBorderPainted(false);
                btnAddDosis.setBorder(null);
                btnAddDosis.setContentAreaFilled(false);
                btnAddDosis.setToolTipText("Neue Dosierung eintragen");
                btnAddDosis.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                btnAddDosis.setSelectedIcon(
                        new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
                btnAddDosis.addActionListener(e -> btnAddDosisActionPerformed(e));
                panel2.add(btnAddDosis);
            }
            jPanel8.add(panel2, CC.xy(1, 3, CC.LEFT, CC.DEFAULT));
        }
        jPanel1.add(jPanel8, CC.xywh(1, 7, 5, 1));
    }
    contentPane.add(jPanel1, CC.xy(5, 3));

    //======== jPanel3 ========
    {
        jPanel3.setBorder(null);
        jPanel3.setLayout(new FormLayout("149dlu", "3*(fill:default, $lgap), fill:108dlu:grow, $lgap, 60dlu"));

        //======== pnlOFF ========
        {
            pnlOFF.setBorder(new TitledBorder("Absetzung"));
            pnlOFF.setLayout(new FormLayout("pref, 86dlu:grow", "2*(fill:17dlu, $lgap), fill:17dlu"));

            //---- rbActive ----
            rbActive.setText("text");
            rbActive.setSelected(true);
            rbActive.addItemListener(e -> rbActiveItemStateChanged(e));
            pnlOFF.add(rbActive, CC.xywh(1, 1, 2, 1));

            //---- rbDate ----
            rbDate.setText(null);
            rbDate.addItemListener(e -> rbDateItemStateChanged(e));
            pnlOFF.add(rbDate, CC.xy(1, 3));

            //---- txtTo ----
            txtTo.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(FocusEvent e) {
                    txtToFocusLost(e);
                }
            });
            pnlOFF.add(txtTo, CC.xy(2, 3));

            //---- rbEndOfPackage ----
            rbEndOfPackage.setText("text");
            rbEndOfPackage.addItemListener(e -> rbEndOfPackageItemStateChanged(e));
            pnlOFF.add(rbEndOfPackage, CC.xywh(1, 5, 2, 1));
        }
        jPanel3.add(pnlOFF, CC.xy(1, 3));

        //======== jScrollPane3 ========
        {

            //---- txtBemerkung ----
            txtBemerkung.addCaretListener(e -> txtBemerkungCaretUpdate(e));
            jScrollPane3.setViewportView(txtBemerkung);
        }
        jPanel3.add(jScrollPane3, CC.xy(1, 7));

        //---- lblText ----
        lblText.setText("Bemerkung:");
        jPanel3.add(lblText, CC.xy(1, 5));

        //======== pnlON ========
        {
            pnlON.setBorder(new TitledBorder("Ansetzung"));
            pnlON.setLayout(new FormLayout("119dlu:grow, $lcgap, default", "default, $lgap, default"));

            //---- cmbDocON ----
            cmbDocON.setModel(
                    new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
            cmbDocON.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    cmbDocONKeyPressed(e);
                }
            });
            pnlON.add(cmbDocON, CC.xy(1, 1));

            //---- btnAddGP ----
            btnAddGP.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnAddGP.setBorderPainted(false);
            btnAddGP.setBorder(null);
            btnAddGP.setContentAreaFilled(false);
            btnAddGP.setToolTipText("Neues Medikament eintragen");
            btnAddGP.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnAddGP.setSelectedIcon(
                    new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnAddGP.addActionListener(e -> btnAddGPActionPerformed(e));
            pnlON.add(btnAddGP, CC.xy(3, 1));

            //---- cmbHospitalON ----
            cmbHospitalON.setModel(
                    new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
            pnlON.add(cmbHospitalON, CC.xy(1, 3));

            //---- btnAddHospital ----
            btnAddHospital.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnAddHospital.setBorderPainted(false);
            btnAddHospital.setBorder(null);
            btnAddHospital.setContentAreaFilled(false);
            btnAddHospital.setToolTipText("Neues Medikament eintragen");
            btnAddHospital.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnAddHospital.setSelectedIcon(
                    new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnAddHospital.addActionListener(e -> btnAddHospitalActionPerformed(e));
            pnlON.add(btnAddHospital, CC.xy(3, 3));
        }
        jPanel3.add(pnlON, CC.xy(1, 1));
    }
    contentPane.add(jPanel3, CC.xy(3, 3));

    //======== panel1 ========
    {
        panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS));

        //---- btnClose ----
        btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
        btnClose.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnClose.addActionListener(e -> btnCloseActionPerformed(e));
        panel1.add(btnClose);

        //---- btnSave ----
        btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
        btnSave.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnSave.addActionListener(e -> btnSaveActionPerformed(e));
        panel1.add(btnSave);
    }
    contentPane.add(panel1, CC.xy(5, 5, CC.RIGHT, CC.DEFAULT));

    //---- lblTX ----
    lblTX.setText(null);
    lblTX.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/ambulance2.png")));
    contentPane.add(lblTX, CC.xy(3, 5));
    setSize(1015, 640);
    setLocationRelativeTo(getOwner());

    //---- bgMedikament ----
    ButtonGroup bgMedikament = new ButtonGroup();
    bgMedikament.add(rbActive);
    bgMedikament.add(rbDate);
    bgMedikament.add(rbEndOfPackage);
}

From source file:op.care.sysfiles.PnlFiles.java

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

    //======== this ========
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    //======== pnlMain ========
    {
        pnlMain.setLayout(new BoxLayout(pnlMain, BoxLayout.X_AXIS));

        //======== jspFiles ========
        {
            jspFiles.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentResized(ComponentEvent e) {
                    jspFilesComponentResized(e);
                }
            });

            //---- tblFiles ----
            tblFiles.setModel(new DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null }, },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
            tblFiles.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            tblFiles.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            tblFiles.addMouseListener(new MouseAdapter() {
                @Override
                public void mousePressed(MouseEvent e) {
                    tblFilesMousePressed(e);
                }
            });
            jspFiles.setViewportView(tblFiles);
        }
        pnlMain.add(jspFiles);
    }
    add(pnlMain);
}

From source file:org.boaboa.vistas.FormularioVenta.java

public FormularioVenta(Usuario usuario) {
    this.session = usuario;
    initComponents();/*from   ww w  . j  a  va 2 s.  c o m*/
    String cabecera[] = { "Producto", "Cantidad", "Precio Unitario", "Precio Total" };
    String dats[][] = {};
    defaultTableModel = new DefaultTableModel(dats, cabecera);
    jTable.setModel(defaultTableModel);

}

From source file:org.boaboa.vistas.FormularioVenta.java

public FormularioVenta(Usuario usuario, Cliente cliente) {
    this.session = usuario;
    this.clienteFiado = cliente;
    initComponents();/*from   ww  w .j a  va2 s  . co m*/
    String cabecera[] = { "Producto", "Cantidad", "Precio Unitario", "Precio Total" };
    String dats[][] = {};
    defaultTableModel = new DefaultTableModel(dats, cabecera);
    jTable.setModel(defaultTableModel);
}

From source file:org.datacleaner.panels.DatabaseDriversPanel.java

private DCTable getDatabaseDriverTable() {
    final List<DatabaseDriverDescriptor> databaseDrivers = _databaseDriverCatalog.getDatabaseDrivers();
    final List<UserDatabaseDriver> userPreferencesDatabaseDrivers = _userPreferences.getDatabaseDrivers();
    final List<UserDatabaseDriver> unknownManuallyInstalledDrivers = getUnknownManuallyInstalledDrivers(
            userPreferencesDatabaseDrivers, databaseDrivers);
    final TableModel tableModel = new DefaultTableModel(
            new String[] { "", "Database", "Driver class", "Installed?", "Used?" },
            databaseDrivers.size() + unknownManuallyInstalledDrivers.size());

    final DCTable table = new DCTable(tableModel);

    final Icon validIcon = imageManager.getImageIcon(IconUtils.STATUS_VALID, IconUtils.ICON_SIZE_SMALL);
    final Icon invalidIcon = imageManager.getImageIcon(IconUtils.STATUS_ERROR, IconUtils.ICON_SIZE_SMALL);

    final int installedCol = 3;
    final int usedCol = 4;
    int row = 0;//  w w  w. java 2 s. c  om
    for (final DatabaseDriverDescriptor dd : databaseDrivers) {
        final String driverClassName = dd.getDriverClassName();
        final String displayName = dd.getDisplayName();

        final Icon driverIcon = imageManager.getImageIcon(DatabaseDriverCatalog.getIconImagePath(dd),
                IconUtils.ICON_SIZE_SMALL);

        tableModel.setValueAt(driverIcon, row, 0);
        tableModel.setValueAt(displayName, row, 1);
        tableModel.setValueAt(driverClassName, row, 2);
        tableModel.setValueAt("", row, 3);
        tableModel.setValueAt("", row, 4);

        final DatabaseDriverState state = _databaseDriverCatalog.getState(dd);
        if (state == DatabaseDriverState.INSTALLED_WORKING) {
            tableModel.setValueAt(validIcon, row, installedCol);
        } else if (state == DatabaseDriverState.INSTALLED_NOT_WORKING) {
            tableModel.setValueAt(invalidIcon, row, installedCol);
        } else if (state == DatabaseDriverState.NOT_INSTALLED) {
            final String[] downloadUrls = dd.getDownloadUrls();
            if (downloadUrls != null) {
                final DCPanel buttonPanel = new DCPanel();
                buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 0));

                final JButton downloadButton = WidgetFactory.createSmallButton(IconUtils.ACTION_DOWNLOAD);
                downloadButton.setToolTipText("Download and install the driver for " + dd.getDisplayName());

                downloadButton.addActionListener(createDownloadActionListener(dd));
                buttonPanel.add(downloadButton);

                tableModel.setValueAt(buttonPanel, row, installedCol);
            }
        }

        if (isUsed(driverClassName)) {
            tableModel.setValueAt(validIcon, row, usedCol);
        }

        row++;
    }

    for (UserDatabaseDriver driver : unknownManuallyInstalledDrivers) {
        final String driverClassName = driver.getDriverClassName();
        final Icon driverIcon = imageManager.getImageIcon(IconUtils.GENERIC_DATASTORE_IMAGEPATH,
                IconUtils.ICON_SIZE_SMALL);
        tableModel.setValueAt(driverIcon, row, 0);
        tableModel.setValueAt("", row, 1);
        tableModel.setValueAt(driverClassName, row, 2);
        final DatabaseDriverState state = driver.getState();
        if (state == DatabaseDriverState.INSTALLED_WORKING) {
            tableModel.setValueAt(validIcon, row, installedCol);
        } else if (state == DatabaseDriverState.INSTALLED_NOT_WORKING) {
            tableModel.setValueAt(invalidIcon, row, installedCol);
        } else if (state == DatabaseDriverState.NOT_INSTALLED) {
            final Icon icon = imageManager.getImageIcon(IconUtils.STATUS_WARNING, IconUtils.ICON_SIZE_SMALL);
            tableModel.setValueAt(icon, row, installedCol);

        }
        if (isUsed(driverClassName)) {
            tableModel.setValueAt(validIcon, row, usedCol);
        }
        row++;
    }

    table.setAlignment(installedCol, Alignment.CENTER);
    table.setAlignment(usedCol, Alignment.CENTER);

    table.setRowHeight(IconUtils.ICON_SIZE_SMALL + 4);
    table.getColumn(0).setMaxWidth(IconUtils.ICON_SIZE_SMALL + 4);
    table.getColumn(installedCol).setMaxWidth(84);
    table.getColumn(usedCol).setMaxWidth(70);
    table.setColumnControlVisible(false);
    return table;
}

From source file:org.dc.file.search.ui.DashboardForm.java

private void initCommentResultsTable() {
    txtCommentThread.setText("");
    Object[][] initData = {};// w  w w .j a v a  2s  .co  m
    DefaultTableModel commentModel = new DefaultTableModel(initData, commentColumnNames);
    tblComments.setModel(commentModel);
    tblComments.setRowHeight(32);

    TableColumn commentRatingColumn = tblComments.getColumnModel().getColumn(COMMENT_RATING_COL_INDEX);
    commentRatingColumn.setCellRenderer(new StarRatingsRenderer(tblComments, StarRatingsType.COMMENT));
    commentRatingColumn.setCellEditor(new StarRatingsEditor(tblComments, StarRatingsType.COMMENT));
    commentRatingColumn.setPreferredWidth(30);

    TableColumn commentReply = tblComments.getColumnModel().getColumn(COMMENT_REPLY_COL_INDEX);
    commentReply.setCellRenderer(new ButtonRenderer(tblComments));
    commentReply.setCellEditor(new ButtonEditor(tblComments));

    tblComments.getSelectionModel().addListSelectionListener(event -> {
        if (tblComments.getSelectedRow() >= 0) {
            txtCommentThread.setText("");
            DFile dFile = resultFiles.get(selectedFile);
            String commentId = tblComments.getValueAt(tblComments.getSelectedRow(), 0).toString();
            Comment parentComment = null;
            List<Comment> comments = dFile.getComments();
            for (Comment c : comments) {
                if (c.getCommentId().equals(commentId)) {
                    parentComment = c;
                    break;
                }
            }
            if (parentComment == null) {
                return;
            }
            StringBuilder stringBuilder = new StringBuilder();
            for (Comment replyComment : parentComment.getReplies()) {
                stringBuilder.append(replyComment.getUserName());
                stringBuilder.append(": ");
                stringBuilder.append(replyComment.getText());
                stringBuilder.append("\n----------------------------------\n");
            }
            txtCommentThread.setText(stringBuilder.toString());
        }
    });
}

From source file:org.dc.file.search.ui.DashboardForm.java

private void initSearchResultsTable() {
    Object[][] initData = {};//from w  ww.jav a2 s.  c  o m
    DefaultTableModel searchModel = new DefaultTableModel(initData, searchColumnNames);
    tblSearchResults.setModel(searchModel);
    tblSearchResults.setRowHeight(32);

    tblSearchResults.getColumnModel().getColumn(PEER_COL_INDEX).setPreferredWidth(30);
    tblSearchResults.getColumnModel().getColumn(HOP_COUNT_COL_INDEX).setPreferredWidth(20);
    tblSearchResults.getColumnModel().getColumn(FILE_COL_INDEX).setPreferredWidth(20);

    TableColumn starRatingsColumn = tblSearchResults.getColumnModel().getColumn(STAR_RATINGS_COL_INDEX);
    starRatingsColumn.setCellRenderer(new StarRatingsRenderer(tblSearchResults, StarRatingsType.FILE));
    starRatingsColumn.setCellEditor(new StarRatingsEditor(tblSearchResults, StarRatingsType.FILE));
    starRatingsColumn.setPreferredWidth(30);

    tblSearchResults.getSelectionModel().addListSelectionListener(event -> {
        if (tblSearchResults.getSelectedRow() >= 0) {
            updateCommentTable();
        }
    });
}

From source file:org.eobjects.datacleaner.panels.DatabaseDriversPanel.java

private DCTable getDatabaseDriverTable() {
    final List<DatabaseDriverDescriptor> databaseDrivers = _databaseDriverCatalog.getDatabaseDrivers();
    final TableModel tableModel = new DefaultTableModel(
            new String[] { "", "Database", "Driver class", "Installed?", "Used?" }, databaseDrivers.size());

    final DCTable table = new DCTable(tableModel);

    final Icon validIcon = imageManager.getImageIcon(IconUtils.STATUS_VALID, IconUtils.ICON_SIZE_SMALL);
    final Icon invalidIcon = imageManager.getImageIcon(IconUtils.STATUS_ERROR, IconUtils.ICON_SIZE_SMALL);

    final int installedCol = 3;
    final int usedCol = 4;
    int row = 0;/*from  w ww  .  j a  va 2  s  .  c  om*/
    for (final DatabaseDriverDescriptor dd : databaseDrivers) {
        final String driverClassName = dd.getDriverClassName();
        final String displayName = dd.getDisplayName();

        final Icon driverIcon = imageManager.getImageIcon(DatabaseDriverCatalog.getIconImagePath(dd),
                IconUtils.ICON_SIZE_SMALL);

        tableModel.setValueAt(driverIcon, row, 0);
        tableModel.setValueAt(displayName, row, 1);
        tableModel.setValueAt(driverClassName, row, 2);
        tableModel.setValueAt("", row, 3);
        tableModel.setValueAt("", row, 4);

        final DatabaseDriverState state = _databaseDriverCatalog.getState(dd);
        if (state == DatabaseDriverState.INSTALLED_WORKING) {
            tableModel.setValueAt(validIcon, row, installedCol);
        } else if (state == DatabaseDriverState.INSTALLED_NOT_WORKING) {
            tableModel.setValueAt(invalidIcon, row, installedCol);
        } else if (state == DatabaseDriverState.NOT_INSTALLED) {
            final String[] downloadUrls = dd.getDownloadUrls();
            if (downloadUrls != null) {
                final DCPanel buttonPanel = new DCPanel();
                buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 0));

                final JButton downloadButton = WidgetFactory.createSmallButton("images/actions/download.png");
                downloadButton.setToolTipText("Download and install the driver for " + dd.getDisplayName());

                downloadButton.addActionListener(createDownloadActionListener(dd));
                buttonPanel.add(downloadButton);

                tableModel.setValueAt(buttonPanel, row, installedCol);
            }
        }

        if (isUsed(driverClassName)) {
            tableModel.setValueAt(validIcon, row, usedCol);
        }

        row++;
    }

    table.setAlignment(installedCol, Alignment.CENTER);
    table.setAlignment(usedCol, Alignment.CENTER);

    table.setRowHeight(IconUtils.ICON_SIZE_SMALL + 4);
    table.getColumn(0).setMaxWidth(IconUtils.ICON_SIZE_SMALL + 4);
    table.getColumn(installedCol).setMaxWidth(84);
    table.getColumn(usedCol).setMaxWidth(70);
    table.setColumnControlVisible(false);
    return table;
}

From source file:org.executequery.gui.resultset.ResultSetTable.java

public TableModel selectedCellsAsTableModel() {

    int cols = getSelectedColumnCount();
    int rows = getSelectedRowCount();

    if (cols == 0 && rows == 0) {
        return null;
    }/*from   w  w  w. j a  v a  2 s .co m*/

    int[] selectedRows = getSelectedRows();
    int[] selectedCols = getSelectedColumns();

    Vector data = new Vector(rows);
    Vector columns = new Vector(cols);

    for (int i = 0; i < rows; i++) {

        Vector rowVector = new Vector(cols);

        for (int j = 0; j < cols; j++) {

            rowVector.add(getValueAt(selectedRows[i], selectedCols[j]));

            if (i == 0) {

                columns.add(getColumnName(selectedCols[j]));
            }

        }

        data.add(rowVector);
    }

    return new DefaultTableModel(data, columns);
}