Java Code Examples for javax.swing.table.DefaultTableModel#setValueAt()
The following examples show how to use
javax.swing.table.DefaultTableModel#setValueAt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LibraryPanel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Constructs a LibraryPanel. * * @param libraries * a list of libraries (represented by Library objects). */ public LibraryPanel( final List libraries ) { setLayout( new BorderLayout() ); final ResourceBundle resources = ResourceBundle.getBundle( SwingPreviewModule.BUNDLE_NAME ); final String[] names = new String[] { resources.getString( "libraries-table.column.name" ), resources.getString( "libraries-table.column.version" ), resources.getString( "libraries-table.column.licence" ), resources.getString( "libraries-table.column.info" ) }; final DefaultTableModel model = new DefaultTableModel( names, libraries.size() ); for ( int i = 0; i < libraries.size(); i++ ) { final DependencyInformation depInfo = (DependencyInformation) libraries.get( i ); model.setValueAt( depInfo.getName(), i, 0 ); model.setValueAt( depInfo.getVersion(), i, 1 ); model.setValueAt( depInfo.getLicenseName(), i, 2 ); model.setValueAt( depInfo.getInfo(), i, 3 ); } this.table = new JTable( model ); add( new JScrollPane( this.table ) ); }
Example 2
Source File: XMLExportIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testExport() throws Exception { final MasterReport report = new MasterReport(); final ItemBand itemBand = report.getItemBand(); final TextFieldElementFactory cfef = new TextFieldElementFactory(); cfef.setFieldname( "field" ); cfef.setMinimumWidth( new Float( 500 ) ); cfef.setMinimumHeight( new Float( 200 ) ); itemBand.addElement( cfef.createElement() ); final DefaultTableModel tableModel = new DefaultTableModel( new String[] { "field" }, 2000 ); for ( int row = 0; row < tableModel.getRowCount(); row++ ) { tableModel.setValueAt( "Value row = " + row, row, 0 ); } report.setDataFactory( new TableDataFactory( "default", tableModel ) ); DebugReportRunner.createDataXML( report ); }
Example 3
Source File: PDeclensionListPanel.java From PolyGlot with MIT License | 6 votes |
private void populateTableModelValues(DefaultTableModel tableModel) { int yPos = 0; for (DeclensionPair pair : declensionPairs) { // if suppressed, add null value if (decMan.isCombinedDeclSurpressed(pair.combinedId, word.getWordTypeId())) { tableModel.setValueAt(null, yPos, 1); } else { String wordForm = getWordForm(pair.combinedId); autoPopulated = autoPopulated || !wordForm.isBlank(); // keep track of whether anything in this list is populated tableModel.setValueAt(wordForm, yPos, 1); decIdsToListLocation.put(pair.combinedId, yPos); } yPos++; } }
Example 4
Source File: SparklineXMLDemo.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates data of sales per months. * * @return The tabular report data. */ private DefaultTableModel createData() { final String[] columnNames = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; final DefaultTableModel data = new DefaultTableModel(columnNames, 10); for (int r = 0; r < 10; r++) { for (int i = 0; i < 12 && r < 10; i++) { final Integer value = new Integer(random.nextInt(30)); data.setValueAt(value, r, i); } } return data; }
Example 5
Source File: CSVExportIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testExport() throws Exception { final MasterReport report = new MasterReport(); final ItemBand itemBand = report.getItemBand(); final TextFieldElementFactory cfef = new TextFieldElementFactory(); cfef.setFieldname( "field" ); cfef.setMinimumWidth( new Float( 500 ) ); cfef.setMinimumHeight( new Float( 200 ) ); itemBand.addElement( cfef.createElement() ); final DefaultTableModel tableModel = new DefaultTableModel( new String[] { "field" }, 2000 ); for ( int row = 0; row < tableModel.getRowCount(); row++ ) { tableModel.setValueAt( "Value row = " + row, row, 0 ); } report.setDataFactory( new TableDataFactory( "default", tableModel ) ); DebugReportRunner.createDataCSV( report ); }
Example 6
Source File: SparklineAPIDemo.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates data of sales per months. * * @return The tabular report data. */ private DefaultTableModel createData() { final String[] columnNames = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; DefaultTableModel data = new DefaultTableModel(columnNames, 10); for (int r = 0; r < 10; r++) { for (int i = 0; i < 12 && r < 10; i++) { // we want some negative values int neg = -random.nextInt(2); if (neg == 0) { neg = 1; } final Integer value = new Integer(neg * random.nextInt(30)); data.setValueAt(value, r, i); } } return data; }
Example 7
Source File: ReplaceConstructorWithBuilderPanel.java From netbeans with Apache License 2.0 | 5 votes |
private void updateSetterNames(String prefix) { DefaultTableModel model = (DefaultTableModel) paramTable.getModel(); for (int k = 0;k < parameterNames.size();k ++) { if (prefix == null || prefix.isEmpty()) { model.setValueAt(parameterNames.get(k),k,1); } else { model.setValueAt(prefix + Character.toUpperCase(parameterNames.get(k).charAt(0)) + parameterNames.get(k).substring(1),k,1); } } }
Example 8
Source File: CategoryPanelStepFilters.java From netbeans with Apache License 2.0 | 5 votes |
private void filtersCheckAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filtersCheckAllButtonActionPerformed DefaultTableModel model = (DefaultTableModel) filterClassesTable.getModel(); for (int i = 0; i < model.getRowCount(); i++) { model.setValueAt(Boolean.TRUE, i, 0); } filterClassesTable.repaint(); }
Example 9
Source File: HelloWorld.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates a small dataset to use in a report. JFreeReport always reads data from a <code>TableModel</code> * instance. * * @return a dataset. */ private TableModel createData() { final Object[] columnNames = new String[]{"Column1", "Column2"}; final DefaultTableModel result = new DefaultTableModel(columnNames, 1); result.setValueAt("Hello\n", 0, 0); result.setValueAt("World!\n", 0, 1); return result; }
Example 10
Source File: SystemPropertiesPanel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates and returns a JTable containing all the system properties. This method returns a table that is configured * so that the user can sort the properties by clicking on the table header. * * @return a system properties table. */ public static JTable createSystemPropertiesTable() { final ResourceBundle resources = ResourceBundle.getBundle( SwingPreviewModule.BUNDLE_NAME ); final String[] names = new String[] { resources.getString( "system-properties-table.column.name" ), resources.getString( "system-properties-table.column.value" ), }; final Properties sysProps = System.getProperties(); final TreeMap data = new TreeMap( sysProps ); final Map.Entry[] entries = (Map.Entry[]) data.entrySet().toArray( new Map.Entry[data.size()] ); final DefaultTableModel properties = new DefaultTableModel( names, entries.length ); for ( int i = 0; i < entries.length; i++ ) { final Map.Entry entry = entries[i]; properties.setValueAt( entry.getKey(), i, 0 ); properties.setValueAt( entry.getValue(), i, 1 ); } final JTable table = new JTable( properties ); final TableColumnModel model = table.getColumnModel(); TableColumn column = model.getColumn( 0 ); column.setPreferredWidth( 200 ); column = model.getColumn( 1 ); column.setPreferredWidth( 350 ); table.setAutoResizeMode( JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS ); return table; }
Example 11
Source File: TableColumnChooser.java From nmonvisualizer with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { DefaultTableModel model = getModel(); for (int i = 0; i < model.getRowCount(); i++) { model.setValueAt(tableModel.getDefaultColumnState(i), i, 1); } }
Example 12
Source File: PDeclensionGridPanel.java From PolyGlot with MIT License | 5 votes |
/** * Populates table model with labels in the first row (uneditable) * @param tableModel * @param yNode */ private void populateYLabels(DefaultTableModel tableModel, DeclensionNode yNode) { Object[] rowLabels = getLabels(yNode, false); for (int i = 0; i < rowLabels.length; i++) { tableModel.setValueAt(rowLabels[i], i, 0); } }
Example 13
Source File: TableColumnChooser.java From nmonvisualizer with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { DefaultTableModel model = getModel(); for (int i = 0; i < model.getRowCount(); i++) { model.setValueAt(true, i, 1); } }
Example 14
Source File: Pre497IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static TableModel createMasterReport() { if ( querytracker.contains( "MR" ) ) { throw new IllegalStateException( "MasterReport query has been called twice! Caching does not work." ); } final DefaultTableModel model = new DefaultTableModel( 2, 1 ); model.setValueAt( "1", 0, 0 ); model.setValueAt( "2", 1, 0 ); DebugLog.log( "Master-Query " ); querytracker.add( "MR" ); return model; }
Example 15
Source File: ProprietesView.java From niftyeditor with Apache License 2.0 | 5 votes |
private void fillTable(GElement ele, DefaultTableModel model) { Map<String,String> attribut = ele.listAttributes(); model.setNumRows(attribut.keySet().size()); int line =0; for(String sel : attribut.keySet()){ model.setValueAt(sel, line, 0); model.setValueAt(attribut.get(sel), line, 1); line++; } }
Example 16
Source File: SettingsForm.java From intellij-extra-icons-plugin with MIT License | 4 votes |
private void disableAll() { DefaultTableModel tableModel = iconsTabbedPane.getSelectedIndex() == 0 ? pluginIconsSettingsTableModel : userIconsSettingsTableModel; for (int settingsTableRow = 0; settingsTableRow < tableModel.getRowCount(); settingsTableRow++) { tableModel.setValueAt(false, settingsTableRow, PluginIconsSettingsTableModel.ICON_ENABLED_ROW_NUMBER); // Enabled row number is the same for both models } }
Example 17
Source File: OrderBook.java From btdex with GNU General Public License v3.0 | 4 votes |
private void addOrders(DefaultTableModel model, ArrayList<AssetOrder> orders, int[] cols) { Globals g = Globals.getInstance(); pendingIconRotating.clearCells(model); int row = 0; for (; row < orders.size(); row++) { AssetOrder o = orders.get(row); // price always come in Burst, so no problem in this division using long's long price = o.getPrice().longValue(); long amountToken = o.getQuantity().longValue(); if(price == 0 || amountToken == 0) continue; String priceFormated = NumberFormatting.BURST.format(price*market.getFactor()); JButton b = new ActionButton(this, priceFormated, o, false); if(o.getAccountAddress().equals(g.getAddress()) && o.getAssetId() != null) { b = new ActionButton(this, priceFormated, o, true); b.setIcon(cancelIcon); } if(o.getId() == null || o.getAssetId() == null) { b.setIcon(pendingIconRotating); pendingIconRotating.addCell(model, row, cols[OrderBookSettings.COL_PRICE]); } b.setBackground(o.getType() == AssetOrder.OrderType.ASK ? HistoryPanel.RED : HistoryPanel.GREEN); model.setValueAt(b, row, cols[OrderBookSettings.COL_PRICE]); model.setValueAt(market.format(amountToken), row, cols[OrderBookSettings.COL_SIZE]); model.setValueAt(NumberFormatting.BURST.format(amountToken*price), row, cols[OrderBookSettings.COL_TOTAL]); ExplorerButton exp = null; if(o.getId()!=null) { exp = new ExplorerButton(o.getId().getID(), copyIcon, expIcon, BUTTON_EDITOR); if(o.getAccountAddress().equals(g.getAddress()) && o.getAssetId() != null) { JButton cancel = new ActionButton(this, "", o, true); cancel.setIcon(cancelIcon); exp.add(cancel, BorderLayout.WEST); } } model.setValueAt(exp, row, cols[OrderBookSettings.COL_CONTRACT]); } }
Example 18
Source File: JListEditor.java From JByteMod-Beta with GNU General Public License v2.0 | 4 votes |
public void recalcIndex(DefaultTableModel lm) { for (int i = 0; i < lm.getRowCount(); i++) { lm.setValueAt(i, i, 0); } }
Example 19
Source File: JAnnotationEditor.java From JByteMod-Beta with GNU General Public License v2.0 | 4 votes |
public static void recalcIndex(DefaultTableModel lm) { for (int i = 0; i < lm.getRowCount(); i++) { lm.setValueAt(i, i, 0); } }
Example 20
Source File: OrderBook.java From btdex with GNU General Public License v3.0 | 4 votes |
private void addContracts(DefaultTableModel model, ArrayList<ContractState> contracts, int []cols) { Globals g = Globals.getInstance(); pendingIconRotating.clearCells(model); // Update the contents int row = 0; for (; row < contracts.size(); row++) { ContractState s = contracts.get(row); String priceFormated = market.format(s.getRate()); Icon icon = s.getCreator().equals(g.getAddress()) ? editIcon : null; // takeIcon; JButton b = new ActionButton(this,"", s, false); if(s.hasPending()) { if(s.getRate() == 0) priceFormated = tr("book_pending_button"); icon = pendingIconRotating; pendingIconRotating.addCell(model, row, cols[OrderBookSettings.COL_PRICE]); } else if(s.getState() > SellContract.STATE_DISPUTE && (s.getTaker() == g.getAddress().getSignedLongId() || s.getCreator().equals(g.getAddress()))){ priceFormated = tr("book_dispute_button"); icon = null; } else if(s.getTaker() == g.getAddress().getSignedLongId() && s.hasStateFlag(SellContract.STATE_WAITING_PAYMT)) { priceFormated = tr(s.getType() == ContractType.BUY ? "book_confirm_dispute_button" : "book_deposit_dispute_button"); icon = null; } else if(s.getCreator().equals(g.getAddress()) && s.hasStateFlag(SellContract.STATE_WAITING_PAYMT)) { priceFormated = tr(s.getType() == ContractType.BUY ? "book_deposit_dispute_button" : "book_confirm_dispute_button"); icon = null; } b.setText(priceFormated); b.setIcon(icon); b.setBackground(s.getType() == ContractType.BUY ? HistoryPanel.GREEN : HistoryPanel.RED); model.setValueAt(b, row, cols[OrderBookSettings.COL_PRICE]); if(s.getSecurityNQT() > 0 && s.getAmountNQT() > 0 && s.getRate() > 0) { long securityPercent = s.getSecurityNQT()*100L / s.getAmountNQT(); String sizeString = s.getAmount() + " (" + securityPercent + "%)"; model.setValueAt(sizeString, row, cols[OrderBookSettings.COL_SIZE]); double amount = ((double)s.getRate())*s.getAmountNQT(); amount /= Contract.ONE_BURST; model.setValueAt(market.format((long)amount), row, cols[OrderBookSettings.COL_TOTAL]); } else { model.setValueAt(null, row, cols[OrderBookSettings.COL_SIZE]); model.setValueAt(null, row, cols[OrderBookSettings.COL_TOTAL]); } ExplorerButton exp = new ExplorerButton(s.getAddress().getRawAddress(), copyIcon, expIcon, ExplorerButton.TYPE_ADDRESS, s.getAddress().getID(), s.getAddress().getFullAddress(), BUTTON_EDITOR); if(s.getCreator().getSignedLongId() == g.getAddress().getSignedLongId() && s.getBalance().longValue() > 0 && s.getState() < SellContract.STATE_WAITING_PAYMT && !s.hasPending()) { ActionButton withDrawButton = new ActionButton(this,"", s, true); withDrawButton.setToolTipText(tr("book_withdraw")); withDrawButton.setIcon(cancelIcon); exp.add(withDrawButton, BorderLayout.WEST); } model.setValueAt(exp, row, cols[OrderBookSettings.COL_CONTRACT]); // model.setValueAt(new ExplorerButton( // s.getCreator().getSignedLongId()==g.getAddress().getSignedLongId() ? "YOU" : s.getCreator().getRawAddress(), copyIcon, expIcon, // ExplorerButton.TYPE_ADDRESS, s.getCreator().getID(), s.getCreator().getFullAddress(), OrderBook.BUTTON_EDITOR), row, COL_ACCOUNT); // model.setValueAt(s.getSecurity(), row, COL_SECURITY); } }