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() 

Source Link

Document

Constructs a default DefaultTableModel which is a table of zero columns and zero rows.

Usage

From source file:sms.Form1Exams.java

public void findUsers() {
    String[] Subjects = findSubjectid();
    String[] Subjectsnames = findSubjectname();
    int subjectCount = Subjects.length;
    //JOptionPane.showMessageDialog(null, subjectCount);

    ArrayList<ExamDbDataHolder> users = ListUsers(this.sid.getText());
    DefaultTableModel model = new DefaultTableModel();

    //    String [] subjectsIdentifiers={"Maths","Eng","Kisw","Phy","Chem","Bio","Hist","Geo","Cre","Hre","Agri","Home Scie","Arts","Comp",
    //                                      "B/c","Wood","Metal","Music","French","German","Arabic","Business"};
    //    for(int y=0;y<Subjects.length;y++){
    //        /* w w  w .ja v a2s  .  co m*/
    //    }
    //    String []toCol;
    String col[] = { "Adm", "Uniq" };

    // String [] subjectsIdentifiers={}
    String[] both = (String[]) ArrayUtils.addAll(col, Subjectsnames);

    model.setColumnIdentifiers(both);
    Object[] row = new Object[subjectCount + 4];
    for (int i = 0; i < users.size(); i++) {

        row[0] = ((ExamDbDataHolder) users.get(i)).getSid();

        row[1] = ((ExamDbDataHolder) users.get(i)).getUnique();

        int c = 2;
        for (int s = 0; s < Subjects.length; s++) {

            if (Subjects[s].equals("s1")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getMathematics();
                c++;
            } else if (Subjects[s].equals("s2")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getEnglish();
                c++;
            } else if (Subjects[s].equals("s3")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getKiswahili();
                c++;
            } else if (Subjects[s].equals("s4")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getPhysics();
                c++;
            } else if (Subjects[s].equals("s5")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getChemistry();
                c++;
            } else if (Subjects[s].equals("s6")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getBiology();
                c++;
            } else if (Subjects[s].equals("s7")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getHistory();
                c++;
            } else if (Subjects[s].equals("s8")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getGeography();
                c++;
            } else if (Subjects[s].equals("s9")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getCre();
                c++;
            } else if (Subjects[s].equals("s10")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getIre();
                c++;
            } else if (Subjects[s].equals("s11")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getHre();
                c++;
            } else if (Subjects[s].equals("s12")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getAgriculture();
                c++;
            } else if (Subjects[s].equals("s13")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getHomescience();
                c++;
            } else if (Subjects[s].equals("s14")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getArtdesign();
                c++;
            } else if (Subjects[s].equals("s15")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getComputer();
                c++;

            } else if (Subjects[s].equals("s16")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getBuilding();
                c++;
            } else if (Subjects[s].equals("s17")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getWoodwork();
                c++;
            } else if (Subjects[s].equals("s18")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getMetalwork();
                c++;
            } else if (Subjects[s].equals("s19")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getMusic();
                c++;
            } else if (Subjects[s].equals("s20")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getFrench();
                c++;
            } else if (Subjects[s].equals("s21")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getGerman();
                c++;
            } else if (Subjects[s].equals("s22")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getArabic();
                c++;
            } else if (Subjects[s].equals("s23")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getBusiness();
                c++;
            }
        }

        //      row[2] = ((ExamDbDataHolder)users.get(i)).getMathematics();
        //      row[3] = ((ExamDbDataHolder)users.get(i)).getEng();
        //      row[4] = ((ExamDbDataHolder)users.get(i)).getKiswa();
        //      row[5] = ((ExamDbDataHolder)users.get(i)).getPhy();
        //      row[6] = ((ExamDbDataHolder)users.get(i)).getChem();
        //      row[7] = ((ExamDbDataHolder)users.get(i)).getBio();
        //      row[8] = ((ExamDbDataHolder)users.get(i)).getHist();
        //      row[9] = ((ExamDbDataHolder)users.get(i)).getGeo();
        //      row[10] = ((ExamDbDataHolder)users.get(i)).getCre();
        //      row[11] = ((ExamDbDataHolder)users.get(i)).getAgri();
        //      row[12] = ((ExamDbDataHolder)users.get(i)).getBs();

        model.addRow(row);
    }
    this.table.setModel(model);
}

From source file:sms.ViewResults.java

public void findUsers() {
    methods nn = new methods();
    Form1Exams n = new Form1Exams();
    String[] Subjects = n.findSubjectid();
    String[] Subjectsnames = n.findSubjectname();
    int subjectCount = Subjects.length;
    //JOptionPane.showMessageDialog(null, subjectCount);

    ArrayList<ExamDbDataHolder> users = ListUsers(this.sid.getText());
    DefaultTableModel model = new DefaultTableModel();

    //    String [] subjectsIdentifiers={"Maths","Eng","Kisw","Phy","Chem","Bio","Hist","Geo","Cre","Hre","Agri","Home Scie","Arts","Comp",
    //                                      "B/c","Wood","Metal","Music","French","German","Arabic","Business"};
    //    for(int y=0;y<Subjects.length;y++){
    //        /*w ww. j  a  va2s .  c  om*/
    //    }
    //    String []toCol;
    String col[] = { "Adm", "Uniq", "Total", "Ave", "AGG" };

    // String [] subjectsIdentifiers={}
    String[] both = (String[]) ArrayUtils.addAll(col, Subjectsnames);

    model.setColumnIdentifiers(both);
    Object[] row = new Object[subjectCount + 6];
    for (int i = 0; i < users.size(); i++) {

        row[0] = ((ExamDbDataHolder) users.get(i)).getSid();

        row[1] = ((ExamDbDataHolder) users.get(i)).getUnique();
        row[2] = ((ExamDbDataHolder) users.get(i)).getTotal();
        float g = Float.valueOf(((ExamDbDataHolder) users.get(i)).getTotal());
        //  tbl.addCell(String.format("%.1f", g));

        row[3] = String.format("%.1f", g / getYear());
        String gr = nn.checkGrade(yearid, String.format("%.1f", g / getYear()));
        row[4] = gr;
        int c = 5;
        for (int s = 0; s < Subjects.length; s++) {

            if (Subjects[s].equals("s1")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getMathematics();
                c++;
            } else if (Subjects[s].equals("s2")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getEnglish();
                c++;
            } else if (Subjects[s].equals("s3")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getKiswahili();
                c++;
            } else if (Subjects[s].equals("s4")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getPhysics();
                c++;
            } else if (Subjects[s].equals("s5")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getChemistry();
                c++;
            } else if (Subjects[s].equals("s6")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getBiology();
                c++;
            } else if (Subjects[s].equals("s7")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getHistory();
                c++;
            } else if (Subjects[s].equals("s8")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getGeography();
                c++;
            } else if (Subjects[s].equals("s9")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getCre();
                c++;
            } else if (Subjects[s].equals("s10")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getIre();
                c++;
            } else if (Subjects[s].equals("s11")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getHre();
                c++;
            } else if (Subjects[s].equals("s12")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getAgriculture();
                c++;
            } else if (Subjects[s].equals("s13")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getHomescience();
                c++;
            } else if (Subjects[s].equals("s14")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getArtdesign();
                c++;
            } else if (Subjects[s].equals("s15")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getComputer();
                c++;

            } else if (Subjects[s].equals("s16")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getBuilding();
                c++;
            } else if (Subjects[s].equals("s17")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getWoodwork();
                c++;
            } else if (Subjects[s].equals("s18")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getMetalwork();
                c++;
            } else if (Subjects[s].equals("s19")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getMusic();
                c++;
            } else if (Subjects[s].equals("s20")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getFrench();
                c++;
            } else if (Subjects[s].equals("s21")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getGerman();
                c++;
            } else if (Subjects[s].equals("s22")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getArabic();
                c++;
            } else if (Subjects[s].equals("s23")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getBusiness();
                c++;
            }
        }
        model.addRow(row);

    }
    this.table.setModel(model);
    counter(model.getRowCount());
}

From source file:sms.ViewResults.java

public void counter(int count) {

    DefaultTableModel model = new DefaultTableModel();
    String[] c = { "count" };
    model.setColumnIdentifiers(c);/*from  w ww.jav  a2  s .co m*/
    Object[] row = new Object[1];

    for (int a = 1; a <= count; a++) {

        row[0] = a;

        model.addRow(row);
    }

    this.tblCounter.setModel(model);

}

From source file:StockForecast.Main.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:
    Connect a = new Connect();
    DefaultTableModel tm = new DefaultTableModel();
    jTable1.setRowHeight(25);//from   ww  w.  ja  va 2s  . com
    tm.addColumn("User ID");
    tm.addColumn("Username");
    tm.addColumn("Password");
    tm.addColumn("User Type");
    tm.addColumn("Name");
    tm.addColumn("");
    tm.addColumn("");
    Action delete = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            jTable1 = (JTable) e.getSource();
            int modelRow = Integer.valueOf(e.getActionCommand());
            ((DefaultTableModel) jTable1.getModel()).removeRow(modelRow);
        }
    };

    String selectItem = jComboBox2.getSelectedItem().toString();
    String partQuery = "";
    String text = "";
    System.out.println(jComboBox4.getItemCount());
    if (jComboBox4.isEnabled()) {
        if (jComboBox4.getItemCount() > 0) {
            switch (selectItem) {
            case "All":
                partQuery = "";
                break;
            case "User ID":
                text = jComboBox4.getSelectedItem().toString();
                partQuery = " WHERE LOGINID='" + text + "'";
                break;
            case "User Name":
                text = jComboBox4.getSelectedItem().toString();
                partQuery = " WHERE NAME='" + text + "'";
                break;
            case "User Phone Number":
                text = jComboBox4.getSelectedItem().toString();
                partQuery = " WHERE NAME='" + text + "'";
                break;
            default:
                System.out.println("This Search Condition Not Yet Implemented");
            }
            try {
                ResultSet rs = a.connectSelect("1",
                        "SELECT * FROM ROOT.LOGIN NATURAL JOIN PROFILE" + partQuery);
                if (text.equals("")) {
                    JOptionPane.showMessageDialog(this, "Please Input Search Text");
                } else if (!rs.next()) {
                    JOptionPane.showMessageDialog(this, "There Is No Data With " + selectItem + ": " + text
                            + "\n" + "Please Try Using Valid (" + selectItem + ")");
                } else {
                    do {
                        tm.addRow(new Object[] { rs.getString(1), rs.getString(2), rs.getString(3),
                                rs.getString(4), rs.getString(6), "Delete", "Update" });
                        jTable1.setModel(tm);

                        ButtonColumn buttonColumn = new ButtonColumn(jTable1, delete, 5);
                        ButtonColumn btnColumn = new ButtonColumn(jTable1, delete, 6);
                        buttonColumn.setMnemonic(KeyEvent.VK_D);
                        btnColumn.setMnemonic(KeyEvent.VK_U);
                    } while (rs.next());
                }

            } catch (Exception ex) {
                System.out.println("Error: " + ex);
            }
        } else {
            JOptionPane.showMessageDialog(this, "There Is no Data Display in Table");
        }

    } else {
        try {
            ResultSet rs = a.connectSelect("1", "SELECT * FROM ROOT.LOGIN NATURAL JOIN PROFILE");
            if (!rs.next()) {
                JOptionPane.showMessageDialog(this, "There Is no Data Display in Table");
            } else {
                do {
                    tm.addRow(new Object[] { rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4),
                            rs.getString(6), "Delete", "Update" });
                    jTable1.setModel(tm);

                    ButtonColumn buttonColumn = new ButtonColumn(jTable1, delete, 5);
                    ButtonColumn btnColumn = new ButtonColumn(jTable1, delete, 6);
                    buttonColumn.setMnemonic(KeyEvent.VK_D);
                    btnColumn.setMnemonic(KeyEvent.VK_U);
                } while (rs.next());
            }

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

From source file:StockForecast.Main.java

private void displayUser() throws Exception {
    String selectItem = jComboBox2.getSelectedItem().toString();
    Connect connect = new Connect();
    DefaultTableModel displayTable = new DefaultTableModel();
    String text = jComboBox4.getSelectedItem().toString();
    System.out.println(text.toUpperCase());

    displayTable.addColumn("User ID");
    displayTable.addColumn("Username");
    displayTable.addColumn("Password");
    displayTable.addColumn("User Type");
    displayTable.addColumn("Name");
    displayTable.addColumn("");
    displayTable.addColumn("");
    ResultSet rs = connect.connectSelect("1",
            "SELECT * FROM ROOT.LOGIN NATURAL JOIN PROFILE WHERE LOGINID='" + text + "'");
    displayTable.addRow(new Object[] { rs.getString("loginid"), rs.getString("username"),
            rs.getString("password"), rs.getString("usertype"), rs.getString("name"), "Delete", "Update" });
    jTable1.setModel(displayTable);// w  w  w.j a  v  a 2 s .  c  o  m
    Action delete = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            JTable table = (JTable) e.getSource();
            int modelRow = Integer.valueOf(e.getActionCommand());
            ((DefaultTableModel) table.getModel()).removeRow(modelRow);
        }
    };

    ButtonColumn buttonColumn = new ButtonColumn(jTable1, delete, 5);
    ButtonColumn btnColumn = new ButtonColumn(jTable1, delete, 6);
    buttonColumn.setMnemonic(KeyEvent.VK_D);
    btnColumn.setMnemonic(KeyEvent.VK_U);

}

From source file:StockForecast.Stock.java

private void displayStock() throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    jTable1.setModel(model);/*from   ww  w. j  a v  a  2  s. c om*/
    model.addColumn("Entity Name");
    model.addColumn("Symbol");
    Connect connect = new Connect();
    ResultSet rs = connect.connectSelect("1", "SELECT * FROM ROOT.STOCK");
    while (rs.next()) {
        model.addRow(new Object[] { rs.getString(1), rs.getString(2) });
    }
}

From source file:uk.ac.ebi.demo.picr.swing.PICRBLASTDemo.java

public PICRBLASTDemo() {

    //set general layout
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    add(Box.createVerticalStrut(5));

    //create components
    JPanel row1 = new JPanel();
    row1.setLayout(new BoxLayout(row1, BoxLayout.X_AXIS));
    row1.add(Box.createHorizontalStrut(5));
    row1.setBorder(BorderFactory.createTitledBorder(""));
    row1.add(new JLabel("Fragment:"));
    row1.add(Box.createHorizontalStrut(10));
    final JTextArea sequenceArea = new JTextArea(5, 40);
    sequenceArea.setMaximumSize(sequenceArea.getPreferredSize());
    row1.add(Box.createHorizontalStrut(10));

    row1.add(sequenceArea);/*from  w ww .  j  a va2  s  . c o m*/
    row1.add(Box.createHorizontalGlue());

    JPanel row2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    row2.setBorder(BorderFactory.createTitledBorder("Target Databases"));
    final JList databaseList = new JList();
    JScrollPane listScroller = new JScrollPane(databaseList);
    listScroller.setMaximumSize(new Dimension(100, 10));
    JButton loadDBButton = new JButton("Load Databases");
    row2.add(listScroller);
    row2.add(loadDBButton);

    JPanel row3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JCheckBox onlyActiveCheckBox = new JCheckBox("Only Active");
    onlyActiveCheckBox.setSelected(true);
    row3.add(new JLabel("Options:  "));
    row3.add(onlyActiveCheckBox);

    add(row1);
    add(row2);
    add(row3);

    final String[] columns = new String[] { "Database", "Accession", "Version", "Taxon ID" };
    final JTable dataTable = new JTable(new Object[0][0], columns);
    dataTable.setShowGrid(true);
    add(new JScrollPane(dataTable));

    JPanel buttonPanel = new JPanel();
    JButton mapAccessionButton = new JButton("Generate Mapping!");
    buttonPanel.add(mapAccessionButton);
    add(buttonPanel);

    //create listeners!

    //update boolean flag in communication class
    onlyActiveCheckBox.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            client.setOnlyActive(((JCheckBox) e.getSource()).isSelected());
        }
    });

    //performs mapping call and updates interface with results
    mapAccessionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            try {

                if (!"".equals(sequenceArea.getText())) {
                    //TODO filters and database are hardcoded here.  They should be added to the input panel at a later revision.
                    java.util.List<UPEntry> entries = client.performBlastMapping(sequenceArea.getText(),
                            databaseList.getSelectedValues(), "90", "", "IDENTITY", "UniprotKB", "", false,
                            new BlastParameter());

                    //compute size of array
                    if (entries != null) {
                        int size = 0;
                        for (UPEntry entry : entries) {
                            for (CrossReference xref : entry.getIdenticalCrossReferences()) {
                                size++;
                            }
                            for (CrossReference xref : entry.getLogicalCrossReferences()) {
                                size++;
                            }
                        }

                        if (size > 0) {

                            final Object[][] data = new Object[size][4];
                            int i = 0;
                            for (UPEntry entry : entries) {
                                for (CrossReference xref : entry.getIdenticalCrossReferences()) {
                                    data[i][0] = xref.getDatabaseName();
                                    data[i][1] = xref.getAccession();
                                    data[i][2] = xref.getAccessionVersion();
                                    data[i][3] = xref.getTaxonId();
                                    i++;
                                }
                                for (CrossReference xref : entry.getLogicalCrossReferences()) {
                                    data[i][0] = xref.getDatabaseName();
                                    data[i][1] = xref.getAccession();
                                    data[i][2] = xref.getAccessionVersion();
                                    data[i][3] = xref.getTaxonId();
                                    i++;
                                }
                            }

                            //refresh
                            DefaultTableModel dataModel = new DefaultTableModel();
                            dataModel.setDataVector(data, columns);
                            dataTable.setModel(dataModel);

                            System.out.println("update done");

                        } else {
                            JOptionPane.showMessageDialog(null, "No Mappind data found.");
                        }
                    } else {
                        JOptionPane.showMessageDialog(null, "No Mappind data found.");
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "You must enter a valid FASTA sequence to map.");
                }
            } catch (SOAPFaultException soapEx) {
                JOptionPane.showMessageDialog(null, "A SOAP Error occurred.");
                soapEx.printStackTrace();
            }
        }
    });

    //loads list of mapping databases from communication class
    loadDBButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            try {

                java.util.List<String> databases = client.loadDatabases();
                if (databases != null && databases.size() > 0) {

                    databaseList.setListData(databases.toArray());
                    System.out.println("database refresh done");

                } else {
                    JOptionPane.showMessageDialog(null, "No Databases Loaded!.");
                }

            } catch (SOAPFaultException soapEx) {
                JOptionPane.showMessageDialog(null, "A SOAP Error occurred.");
                soapEx.printStackTrace();
            }
        }
    });

}

From source file:uk.chromis.pos.forms.JRootApp.java

private void poweredbyMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_poweredbyMouseClicked

    JFrame sampleFrame = new JFrame();
    final Action exit = new AbstractAction("Exit") {
        @Override//from   w  w w.  j  a  va2s.  c o  m
        public final void actionPerformed(final ActionEvent e) {
            sampleFrame.setVisible(false);
            sampleFrame.dispose();
        }
    };

    String currentPath = null;

    if (OSValidator.isMac()) {
        try {
            currentPath = new File(
                    JRootApp.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath())
                            .toString();
        } catch (URISyntaxException ex) {
        }
    } else {
        currentPath = System.getProperty("user.dir") + "\\chromispos.jar";
    }

    String md5 = null;
    try {
        FileInputStream fis = new FileInputStream(new File(currentPath));
        md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
        fis.close();

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

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

    /*
    int mb = 1024*1024;         
    //Getting the runtime reference from system
    Runtime runtime = Runtime.getRuntime();         
    System.out.println("##### Heap utilization statistics [MB] #####");         
    //Print used memory
    System.out.println("Used Memory:"
    + (runtime.totalMemory() - runtime.freeMemory()) / mb); 
    //Print free memory
    System.out.println("Free Memory:"
    + runtime.freeMemory() / mb);         
    //Print total available memory
    System.out.println("Total Memory:" + runtime.totalMemory() / mb); 
    //Print Maximum available memory
    System.out.println("Max Memory:" + runtime.maxMemory() / mb);
     */
    AboutDialog dialog = new AboutDialog();
    JPanel dialogPanel = new JPanel();
    MigLayout layout = new MigLayout("", "[fill]");
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);
    model.addColumn("Details");
    model.addColumn("Value");
    model.addRow(new Object[] { "Database Version", readDataBaseVersion() });
    model.addRow(new Object[] { "Java Version", System.getProperty("java.version") });
    model.addRow(new Object[] { "Jar MD5", md5 });
    model.addRow(new Object[] { "Operating System", System.getProperty("os.name") });
    model.addRow(new Object[] { "Sync library", Sync.getVersion() });

    JScrollPane scrollPane = new JScrollPane(table);
    JPanel mainPanel = new JPanel(layout);
    JLabel label = new JLabel();
    JPanel btnPanel = new JPanel();
    dialogPanel.add(dialog);
    mainPanel.add(dialogPanel, "wrap");
    mainPanel.add(scrollPane, "wrap");
    JButton btnExit = new JButton(exit);
    btnPanel.add(btnExit, "width 100!");
    mainPanel.add(btnPanel, "right, wrap");
    mainPanel.add(new JLabel(), "wrap");
    sampleFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    sampleFrame.setPreferredSize(new Dimension(500, 300));
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    sampleFrame.setLocation(dim.width / 2 - 250, dim.height / 2 - 150);
    sampleFrame.setUndecorated(true);
    mainPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 4));
    sampleFrame.add(mainPanel);
    sampleFrame.pack();
    sampleFrame.setVisible(true);

}

From source file:Visao.Outros.FRMRelatorio.java

private DefaultTableModel criaTabelaVenda() {
    DefaultTableModel dTable = new DefaultTableModel() {
        Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.Float.class,
                java.lang.String.class, java.lang.String.class, java.lang.String.class };
        boolean[] canEdit = new boolean[] { false, false, false, false, false, false };

        @Override/*from   w w  w .  j av  a  2s  .c om*/
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        };

    };
    return dTable;
}

From source file:Visao.Outros.FRMRelatorio.java

private DefaultTableModel criaTabelaFornecimento() {
    DefaultTableModel dTable = new DefaultTableModel() {
        Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.Float.class,
                java.lang.String.class, java.lang.String.class };
        boolean[] canEdit = new boolean[] { false, false, false, false, false };

        @Override//w w  w.j ava 2 s  .c o  m
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        };

    };
    return dTable;
}