List of usage examples for javax.swing.table DefaultTableModel getDataVector
@SuppressWarnings("rawtypes") public Vector<Vector> getDataVector()
Vector
of Vectors
that contains the table's data values. From source file:Main.java
public static void main(String[] argv) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); table.setAutoCreateColumnsFromModel(false); Vector data = model.getDataVector(); Collections.sort(data, new ColumnSorter(0)); model.fireTableStructureChanged();// w w w. j a v a2 s . c om }
From source file:Main.java
public static void main(String[] argv) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); table.setAutoCreateColumnsFromModel(false); boolean ascending = false; Vector data = model.getDataVector(); Object[] colData = new Object[model.getRowCount()]; for (int i = 0; i < colData.length; i++) { colData[i] = ((Vector) data.get(i)).get(0); }/*ww w. j a v a2 s. c o m*/ Arrays.sort(colData, new ColumnSorter()); for (int i = 0; i < colData.length; i++) { ((Vector) data.get(i)).set(0, colData[i]); } model.fireTableStructureChanged(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); model.addColumn("Col1"); model.addRow(new Object[] { "r1" }); model.addRow(new Object[] { "r2" }); model.addRow(new Object[] { "r3" }); Vector data = model.getDataVector(); Vector row = (Vector) data.elementAt(1); // Overwrite the first row with the copy Vector firstRow = (Vector) data.elementAt(0); for (int i = 0; i < row.size(); i++) { firstRow.set(i, row.get(i));//from ww w . j a va 2 s .co m } JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); model.addColumn("Col1"); model.addRow(new Object[] { "r1" }); model.addRow(new Object[] { "r2" }); model.addRow(new Object[] { "r3" }); Vector data = model.getDataVector(); Vector row = (Vector) data.elementAt(1); // Copy the first column int mColIndex = 0; List colData = new ArrayList(table.getRowCount()); for (int i = 0; i < table.getRowCount(); i++) { row = (Vector) data.elementAt(i); colData.add(row.get(mColIndex)); }//ww w . j ava 2 s . c o m JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); model.addColumn("Col1"); model.addRow(new Object[] { "r1" }); model.addRow(new Object[] { "r2" }); model.addRow(new Object[] { "r3" }); Vector data = model.getDataVector(); Vector row = (Vector) data.elementAt(1); int mColIndex = 0; List colData = new ArrayList(table.getRowCount()); for (int i = 0; i < table.getRowCount(); i++) { row = (Vector) data.elementAt(i); colData.add(row.get(mColIndex)); }// w ww . j a v a 2 s .c o m // Append a new column with copied data model.addColumn("Col3", colData.toArray()); JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); model.addColumn("Col1"); model.addRow(new Object[] { "r1" }); model.addRow(new Object[] { "r2" }); model.addRow(new Object[] { "r3" }); // Get all the table data Vector data = model.getDataVector(); JFrame f = new JFrame(); f.setSize(300, 300);/*w w w. j av a 2 s .com*/ f.add(new JScrollPane(table)); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); model.addColumn("Col1"); model.addRow(new Object[] { "r1" }); model.addRow(new Object[] { "r2" }); model.addRow(new Object[] { "r3" }); // Get all the table data Vector data = model.getDataVector(); // Copy the second row Vector row = (Vector) data.elementAt(1); row = (Vector) row.clone();/*from w w w. j av a 2 s .c om*/ JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.setVisible(true); }
From source file:vn.edu.vttu.ui.PanelStatiticsPaymentRawmaterialInvoice.java
public void sortAllRowsBy(DefaultTableModel model, int colIndex, boolean ascending) { Vector data = model.getDataVector(); Collections.sort(data, new ColumnSorter(colIndex, ascending)); model.fireTableStructureChanged();//w w w. ja v a 2s . c om }
From source file:com.ftb2om2.view.MultiplePane.java
private void createDifficultiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createDifficultiesActionPerformed Converter converter;/*from www . j a v a 2s. c om*/ Reader reader = null; Writer writer = null; switch (jComboBox1.getSelectedIndex()) { case 0: reader = new FtbAirReader(); break; case 1: reader = new FtbOldReader(); break; } switch (jComboBox2.getSelectedIndex()) { case 0: writer = new OsuManiaV14Writer(); } converter = new Converter(reader, writer); Metadata metadata = new Metadata(mP3TagsPane1.getTitleField(), mP3TagsPane1.getUnicodeTitleField(), mP3TagsPane1.getArtistField(), mP3TagsPane1.getUnicodeArtistField(), mP3TagsPane1.getCreatorField(), mP3TagsPane1.getSourceField()); DefaultTableModel model = (DefaultTableModel) difficultyTable.getModel(); List<List<Object>> data = model.getDataVector(); Boolean valid = true; for (List row : data) { if (row.get(2).toString().isEmpty() && valid == true) { JOptionPane.showMessageDialog(jPanel6, "Difficulty " + row.get(1).toString() + " Has no output name!", "Error", JOptionPane.ERROR_MESSAGE); valid = false; } } if (valid) { try { for (List row : data) { converter.convert(row.get(1).toString(), outputFolder.getText(), row.get(2).toString(), Integer.parseInt(hitsoundVolume.getModel().getValue().toString()), metadata); } JOptionPane.showMessageDialog(jPanel6, "Difficulty created succesfully!", "Success!", JOptionPane.PLAIN_MESSAGE); } catch (IOException e) { handleError(e); } } }
From source file:com.ftb2om2.view.MultiplePane.java
private void createOsuFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createOsuFileActionPerformed Converter converter;//from www . j av a 2s . com Reader reader = null; Writer writer = null; switch (jComboBox1.getSelectedIndex()) { case 0: reader = new FtbAirReader(); break; case 1: reader = new FtbOldReader(); break; } switch (jComboBox2.getSelectedIndex()) { case 0: writer = new OsuManiaV14Writer(); } converter = new Converter(reader, writer); Metadata metadata = new Metadata(mP3TagsPane1.getTitleField(), mP3TagsPane1.getUnicodeTitleField(), mP3TagsPane1.getArtistField(), mP3TagsPane1.getUnicodeArtistField(), mP3TagsPane1.getCreatorField(), mP3TagsPane1.getSourceField()); DefaultTableModel model = (DefaultTableModel) difficultyTable.getModel(); List<List<Object>> data = model.getDataVector(); Boolean valid = true; for (List row : data) { if (row.get(2).toString().isEmpty() && valid == true) { JOptionPane.showMessageDialog(jPanel6, "Difficulty " + row.get(1).toString() + " Has no output name!", "Error", JOptionPane.ERROR_MESSAGE); valid = false; } } if (valid) { try { List<Difficulty> difficulties = new LinkedList<>(); Zipper zipper = new Zipper(); for (List row : data) { converter.convert(row.get(1).toString(), outputFolder.getText(), row.get(2).toString(), Integer.parseInt(hitsoundVolume.getValue().toString()), metadata); difficulties.add(new Difficulty(row.get(2).toString(), row.get(2).toString())); } zipper.createOSZ(audioFieldMulti.getText(), outputFolder.getText(), difficulties); JOptionPane.showMessageDialog(jPanel6, "Difficulties created succesfully!", "Success!", JOptionPane.PLAIN_MESSAGE); } catch (IOException e) { handleError(e); } } }