List of usage examples for javax.swing.table DefaultTableModel getValueAt
public Object getValueAt(int row, int column)
row
and column
. From source file:com.mirth.connect.client.ui.attachments.RegexAttachmentDialog.java
private void closeButtonActionPerformed(ActionEvent evt) { if (regexTable.isEditing()) { regexTable.getCellEditor().stopCellEditing(); }/* www . j a v a2s .c o m*/ if (inboundReplacementTable.isEditing()) { inboundReplacementTable.getCellEditor().stopCellEditing(); } if (outboundReplacementTable.isEditing()) { outboundReplacementTable.getCellEditor().stopCellEditing(); } attachmentHandlerProperties.getProperties().clear(); for (int row = 0; row < regexTable.getModel().getRowCount(); row++) { String regex = (String) regexTable.getModel().getValueAt(row, 0); String mimeType = (String) regexTable.getModel().getValueAt(row, 1); attachmentHandlerProperties.getProperties().put("regex.pattern" + row, regex); attachmentHandlerProperties.getProperties().put("regex.mimetype" + row, mimeType); } DefaultTableModel inboundTableModel = (DefaultTableModel) inboundReplacementTable.getModel(); for (int row = 0; row < inboundTableModel.getRowCount(); row++) { String replaceKey = (String) inboundTableModel.getValueAt(row, 0); String replaceValue = (String) inboundTableModel.getValueAt(row, 1); attachmentHandlerProperties.getProperties().put("regex.replaceKey" + row, replaceKey); attachmentHandlerProperties.getProperties().put("regex.replaceValue" + row, replaceValue); } DefaultTableModel outboundTableModel = (DefaultTableModel) outboundReplacementTable.getModel(); for (int row = 0; row < outboundTableModel.getRowCount(); row++) { String replaceKey = (String) outboundTableModel.getValueAt(row, 0); String replaceValue = (String) outboundTableModel.getValueAt(row, 1); attachmentHandlerProperties.getProperties().put("outbound.regex.replaceKey" + row, replaceKey); attachmentHandlerProperties.getProperties().put("outbound.regex.replaceValue" + row, replaceValue); } attachmentHandlerProperties = null; parent.setSaveEnabled(true); this.dispose(); }
From source file:de.stefanwndelmann.zy1270logger.ZY1270LoggerMain.java
/** * Reads the Data from the JTable and returns it as a CSV String. * /*from w ww . j a v a2 s . c o m*/ * @return */ private String getCSVData() { DefaultTableModel dtm = (DefaultTableModel) resultTable.getModel(); int nRow = dtm.getRowCount(), nCol = dtm.getColumnCount(); String data = ""; for (int i = 0; i < nCol; i++) { data += dtm.getColumnName(i) + ";"; } data = data.substring(0, data.length() - 1) + "\n"; for (int i = 0; i < nRow; i++) { for (int j = 0; j < nCol; j++) { data += dtm.getValueAt(i, j) + ";"; } data = data.substring(0, data.length() - 1) + "\n"; } return data; }
From source file:Main.java
public Main() { DefaultTableModel model = new DefaultTableModel(0, 5) { @Override//from w w w .j ava 2 s .c o m public boolean isCellEditable(int row, int column) { return false; } }; JTable table = new JTable(model); for (int i = 0; i < 20; i++) { model.addRow(new String[] { i + ".1", i + ".2", i + ".3", i + ".4", i + ".5", }); } add(table, BorderLayout.CENTER); table.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { System.out.println("pressed"); char key = e.getKeyChar(); int selectedColumn = table.getSelectedColumn(); for (int i = 0; i < model.getRowCount(); i++) { String value = (String) model.getValueAt(i, selectedColumn); model.setValueAt(value + key, i, selectedColumn); } } }); }
From source file:gtu._work.ui.SaveFileToPropertiesUI.java
private void initGUI() { try {//from w w w . j a v a2s. c o m BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); this.setTitle("save file to properties"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("load", null, jPanel1, null); { jScrollPane2 = new JScrollPane(); jPanel1.add(jScrollPane2, BorderLayout.CENTER); { textArea = new JTextArea(); jScrollPane2.setViewportView(textArea); } } { jPanel2 = new JPanel(); jPanel1.add(jPanel2, BorderLayout.NORTH); jPanel2.setPreferredSize(new java.awt.Dimension(400, 40)); { addPropsFile = new JButton(); jPanel2.add(addPropsFile); addPropsFile.setText("load properties from file"); addPropsFile.setPreferredSize(new java.awt.Dimension(234, 30)); addPropsFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectFileOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("file is not correct!", "ERROR"); return; } try { props.load(new InputStreamReader(new FileInputStream(file), (String) openUnknowFilecharSet.getSelectedItem())); reloadPropertiesTable(); } catch (Exception e) { JCommonUtil.handleException(e); } } }); } { openFile = new JButton(); jPanel2.add(openFile); openFile.setText("open unknow file"); openFile.setPreferredSize(new java.awt.Dimension(204, 30)); openFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectFileOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("file is not correct!", "ERROR"); return; } try { String encode = (String) openUnknowFilecharSet.getSelectedItem(); BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(file), encode)); StringBuilder sb = new StringBuilder(); for (String line = null; (line = reader.readLine()) != null;) { sb.append(line + "\n"); } reader.close(); textArea.setText(textArea.getText() + "\n" + sb); } catch (IOException e) { JCommonUtil.handleException(e); } } }); } { ComboBoxModel openUnknowFilecharSetModel = new DefaultComboBoxModel( new String[] { "BIG5", "UTF8" }); openUnknowFilecharSet = new JComboBox(); jPanel2.add(openUnknowFilecharSet); openUnknowFilecharSet.setModel(openUnknowFilecharSetModel); openUnknowFilecharSet.setPreferredSize(new java.awt.Dimension(73, 24)); } { appendTextAreaToProps = new JButton(); jPanel2.add(appendTextAreaToProps); appendTextAreaToProps.setText("append textarea to properties"); appendTextAreaToProps.setPreferredSize(new java.awt.Dimension(227, 30)); appendTextAreaToProps.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (StringUtils.isBlank(textArea.getText())) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("textArea is empty", "ERROR"); return; } try { BufferedReader reader = new BufferedReader( new StringReader(textArea.getText())); int pos = -1; String key = null; String value = null; for (String line = null; (line = reader.readLine()) != null;) { if ((pos = line.lastIndexOf("=")) != -1) { key = line.substring(0, pos); value = line.substring(pos + 1); props.put(key, value); } } reader.close(); JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("append success!", "SUCCESS"); reloadPropertiesTable(); } catch (IOException e) { JCommonUtil.handleException(e); } } }); } } } { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("props edit", null, jPanel3, null); { jScrollPane1 = new JScrollPane(); jPanel3.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(629, 361)); { TableModel propsTableModel = new DefaultTableModel(); propsTable = new JTable(); jScrollPane1.setViewportView(propsTable); propsTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (propsTable.getRowCount() == 0) { return; } int rowPos = JTableUtil.newInstance(propsTable).getSelectedRow(); Object key = propsTable.getValueAt(rowPos, 0); Object value = propsTable.getValueAt(rowPos, 1); JMenuItem insertRowItem = JTableUtil.newInstance(propsTable) .jMenuItem_addRow(false, null); insertRowItem.setText("inert row..."); String rowInfo = "delete row : [" + key + "] = [" + value + "]"; JMenuItem delRowItem = JTableUtil.newInstance(propsTable) .jMenuItem_removeRow("are you sure remove row : \n" + rowInfo); delRowItem.setText(rowInfo); JPopupMenuUtil.newInstance(propsTable).applyEvent(evt) .addJMenuItem(insertRowItem, delRowItem).show(); } }); propsTable.setModel(propsTableModel); JTableUtil.defaultSetting(propsTable); } } { jPanel4 = new JPanel(); jPanel3.add(jPanel4, BorderLayout.SOUTH); jPanel4.setPreferredSize(new java.awt.Dimension(629, 45)); { clearProps = new JButton(); jPanel4.add(clearProps); clearProps.setText("clear properties"); clearProps.setPreferredSize(new java.awt.Dimension(182, 36)); clearProps.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { props.clear(); reloadPropertiesTable(); } }); } { savePropsToFile = new JButton(); jPanel4.add(savePropsToFile); savePropsToFile.setText("save properties to file"); savePropsToFile.setPreferredSize(new java.awt.Dimension(182, 36)); savePropsToFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectFileOnly().showSaveDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("file is not correct!", "ERROR"); return; } try { props.clear(); DefaultTableModel model = (DefaultTableModel) propsTable.getModel(); Object key = null; Object value = null; for (int ii = 0; ii < model.getRowCount(); ii++) { key = model.getValueAt(ii, 0); value = model.getValueAt(ii, 1); props.put(key, value); } props.store(new FileOutputStream(file), SaveFileToPropertiesUI.class.getSimpleName()); JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("save completed!\n" + file, "SUCCESS"); } catch (IOException e) { JCommonUtil.handleException(e); } } }); } } } } pack(); this.setSize(798, 505); } catch (Exception e) { e.printStackTrace(); } }
From source file:gtu._work.ui.PropertyEditUI.java
void loadModelToProperties(Properties prop) { DefaultTableModel model = JTableUtil.newInstance(propTable).getModel(); for (int ii = 0; ii < model.getRowCount(); ii++) { String key = (String) model.getValueAt(ii, 1); String value = getChs2Big5((String) model.getValueAt(ii, 2)); System.out.println(key + " = " + value); prop.setProperty(key, value);//from w ww.j a v a2s.c o m } }
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjFieldFormatMultiplePanel.java
/** * @param model/* w ww .j a v a 2s . c o m*/ */ protected void addTableModelListener(DefaultTableModel model) { TableModelListener tml = new TableModelListener() { public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int column = e.getColumn(); DefaultTableModel localModel = (DefaultTableModel) e.getSource(); String columnName = localModel.getColumnName(column); if (columnName.equals(FIELD_VALUE_COL)) { int formatColumn = formatSwitchTbl.getColumnModel().getColumnIndex(DISPLAY_FORMAT_COL); DataObjDataFieldFormat format = (DataObjDataFieldFormat) localModel.getValueAt(row, formatColumn); String value = (String) localModel.getValueAt(row, column); format.setValue(value); enableUIControls(); } } }; model.addTableModelListener(tml); }
From source file:gtu._work.ui.RegexCatchReplacer.java
private void initGUI() { try {/*from w ww .j a v a2 s . com*/ { } BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("source", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { replaceArea = new JTextArea(); jScrollPane1.setViewportView(replaceArea); replaceArea.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JPopupMenuUtil.newInstance(replaceArea).applyEvent(evt) .addJMenuItem("load from file", true, new ActionListener() { Thread newThread; public void actionPerformed(ActionEvent arg0) { if (newThread != null && newThread.getState() != Thread.State.TERMINATED) { JCommonUtil._jOptionPane_showMessageDialog_error( "file is loading!"); return; } final File file = JCommonUtil._jFileChooser_selectFileOnly(); if (file == null) { JCommonUtil._jOptionPane_showMessageDialog_error( "file is not correct!"); return; } String defaultCharset = Charset.defaultCharset().displayName(); String chst = (String) JCommonUtil._jOptionPane_showInputDialog( "input your charset!", defaultCharset); final Charset charset2 = Charset.forName( StringUtils.defaultIfEmpty(chst, defaultCharset)); newThread = new Thread(Thread.currentThread().getThreadGroup(), new Runnable() { public void run() { try { loadFromFileSb = new StringBuilder(); BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream(file), charset2)); for (String line = null; (line = reader .readLine()) != null;) { loadFromFileSb.append(line + "\n"); } reader.close(); replaceArea .setText(loadFromFileSb.toString()); JCommonUtil ._jOptionPane_showMessageDialog_info( "load completed!"); } catch (Exception e) { JCommonUtil.handleException(e); } } }, "" + System.currentTimeMillis()); newThread.setDaemon(true); newThread.start(); } }).show(); } }); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("param", null, jPanel2, null); { exeucte = new JButton(); jPanel2.add(exeucte, BorderLayout.SOUTH); exeucte.setText("exeucte"); exeucte.setPreferredSize(new java.awt.Dimension(491, 125)); exeucte.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { exeucteActionPerformed(evt); } }); } { jPanel3 = new JPanel(); GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel2.add(jPanel3, BorderLayout.CENTER); { repFromText = new JTextField(); } { repToText = new JTextField(); } jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup() .addContainerGap(25, 25) .addGroup(jPanel3Layout.createParallelGroup() .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repFromText, GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repToText, GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE))) .addContainerGap(20, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap() .addComponent(repFromText, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(repToText, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); } { addToTemplate = new JButton(); jPanel2.add(addToTemplate, BorderLayout.NORTH); addToTemplate.setText("add to template"); addToTemplate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { prop.put(repFromText.getText(), repToText.getText()); reloadTemplateList(); } }); } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("result", null, jPanel4, null); { jScrollPane2 = new JScrollPane(); jPanel4.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(491, 283)); { DefaultTableModel resultAreaModel = JTableUtil.createModel(true, "match", "count"); resultArea = new JTable(); jScrollPane2.setViewportView(resultArea); JTableUtil.defaultSetting(resultArea); resultArea.setModel(resultAreaModel); } } } { jPanel5 = new JPanel(); BorderLayout jPanel5Layout = new BorderLayout(); jPanel5.setLayout(jPanel5Layout); jTabbedPane1.addTab("template", null, jPanel5, null); { jScrollPane3 = new JScrollPane(); jPanel5.add(jScrollPane3, BorderLayout.CENTER); { templateList = new JList(); jScrollPane3.setViewportView(templateList); reloadTemplateList(); } templateList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (templateList.getLeadSelectionIndex() == -1) { return; } Entry<Object, Object> entry = (Entry<Object, Object>) JListUtil .getLeadSelectionObject(templateList); repFromText.setText((String) entry.getKey()); repToText.setText((String) entry.getValue()); } }); templateList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(templateList).defaultJListKeyPressed(evt); } }); } } { jPanel6 = new JPanel(); FlowLayout jPanel6Layout = new FlowLayout(); jPanel6.setLayout(jPanel6Layout); jTabbedPane1.addTab("result1", null, jPanel6, null); { resultBtn1 = new JButton(); jPanel6.add(resultBtn1); resultBtn1.setText("to String[]"); resultBtn1.setPreferredSize(new java.awt.Dimension(105, 32)); resultBtn1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { JTableUtil tableUtil = JTableUtil.newInstance(resultArea); int[] rowPoss = tableUtil.getSelectedRows(); DefaultTableModel model = tableUtil.getModel(); List<Object> valueList = new ArrayList<Object>(); for (int ii = 0; ii < rowPoss.length; ii++) { valueList.add(model.getValueAt(rowPoss[ii], 0)); } String reult = valueList.toString().replaceAll("[\\s]", "") .replaceAll("[\\,]", "\",\"").replaceAll("[\\[\\]]", "\""); ClipboardUtil.getInstance().setContents(reult); } }); } { resultBtn2 = new JButton(); jPanel6.add(resultBtn2); resultBtn2.setText("TODO"); resultBtn2.setPreferredSize(new java.awt.Dimension(105, 32)); resultBtn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("resultBtn1.actionPerformed, event=" + evt); //TODO add your code for resultBtn1.actionPerformed JCommonUtil._jOptionPane_showMessageDialog_info("TODO"); } }); } } } this.setSize(512, 350); JCommonUtil.setFont(repToText, repFromText, replaceArea, templateList); JCommonUtil.frameCloseDo(this, new WindowAdapter() { public void windowClosing(WindowEvent paramWindowEvent) { if (StringUtils.isNotBlank(repFromText.getText())) { prop.put(repFromText.getText(), repToText.getText()); } try { prop.store(new FileOutputStream(propFile), "regexText"); } catch (Exception e) { JCommonUtil.handleException("properties store error!", e); } setVisible(false); dispose(); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:maltcms.ui.fileHandles.csv.CSV2JFCLoader.java
@Override public void run() { CSV2TableLoader tl = new CSV2TableLoader(this.ph, this.is); DefaultTableModel dtm; try {//from w ww .j a va2 s. c o m dtm = tl.call(); if (this.mode == CHART.XY) { XYSeriesCollection cd = new XYSeriesCollection(); for (int j = 0; j < dtm.getColumnCount(); j++) { XYSeries xys = new XYSeries(dtm.getColumnName(j)); for (int i = 0; i < dtm.getRowCount(); i++) { Object o = dtm.getValueAt(i, j); try { double d = Double.parseDouble(o.toString()); xys.add(i, d); Logger.getLogger(getClass().getName()).log(Level.INFO, "Adding {0} {1} {2}", new Object[] { i, d, dtm.getColumnName(j) }); } catch (Exception e) { } } cd.addSeries(xys); } XYLineAndShapeRenderer d = new XYLineAndShapeRenderer(true, false); XYPlot xyp = new XYPlot(cd, new NumberAxis("category"), new NumberAxis("value"), d); JFreeChart jfc = new JFreeChart(this.title, xyp); jtc.setChart(jfc); Logger.getLogger(getClass().getName()).info("creating chart done"); } else if (this.mode == CHART.MATRIX) { DefaultXYZDataset cd = new DefaultXYZDataset(); Logger.getLogger(getClass().getName()).log(Level.INFO, "Name of column 0: {0}", dtm.getColumnName(0)); if (dtm.getColumnName(0).isEmpty()) { Logger.getLogger(getClass().getName()).info("Removing column 0"); dtm = removeColumn(dtm, 0); } if (dtm.getColumnName(dtm.getColumnCount() - 1).equalsIgnoreCase("filename")) { dtm = removeColumn(dtm, dtm.getColumnCount() - 1); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < dtm.getRowCount(); i++) { for (int j = 0; j < dtm.getColumnCount(); j++) { sb.append(dtm.getValueAt(i, j) + " "); } sb.append("\n"); } Logger.getLogger(getClass().getName()).log(Level.INFO, "Table before sorting: {0}", sb.toString()); // dtm = sort(dtm); StringBuilder sb2 = new StringBuilder(); for (int i = 0; i < dtm.getRowCount(); i++) { for (int j = 0; j < dtm.getColumnCount(); j++) { sb2.append(dtm.getValueAt(i, j) + " "); } sb2.append("\n"); } Logger.getLogger(getClass().getName()).log(Level.INFO, "Table after sorting: {0}", sb2.toString()); int rows = dtm.getRowCount(); int columns = dtm.getColumnCount(); Logger.getLogger(getClass().getName()).log(Level.INFO, "Storing {0} * {1} elements, {2} total!", new Object[] { columns, rows, rows * columns }); double[][] data = new double[3][(columns * rows)]; ArrayDouble.D1 dt = new ArrayDouble.D1((columns) * rows); double min = Double.POSITIVE_INFINITY; double max = Double.NEGATIVE_INFINITY; EvalTools.eqI(rows, columns, this); int k = 0; for (int i = 0; i < dtm.getRowCount(); i++) { for (int j = 0; j < dtm.getColumnCount(); j++) { Object o = dtm.getValueAt(i, j); try { double d = Double.parseDouble(o.toString()); if (d < min) { min = d; } if (d > max) { max = d; } data[0][k] = (double) i; data[1][k] = (double) j; data[2][k] = d; dt.set(k, d); k++; //System.out.println("Adding "+i+" "+d+" "+dtm.getColumnName(j)); } catch (Exception e) { } } //cd.addSeries(xys); } cd.addSeries(this.title, data); XYBlockRenderer xyb = new XYBlockRenderer(); GradientPaintScale ps = new GradientPaintScale(ImageTools.createSampleTable(256), min, max, ImageTools .rampToColorArray(new ColorRampReader().readColorRamp("res/colorRamps/bcgyr.csv"))); xyb.setPaintScale(ps); final String[] colnames = new String[dtm.getColumnCount()]; for (int i = 0; i < colnames.length; i++) { colnames[i] = dtm.getColumnName(i); } NumberAxis na1 = new SymbolAxis("category", colnames); na1.setVerticalTickLabels(false); NumberAxis na2 = new SymbolAxis("category", colnames); na1.setVerticalTickLabels(true); XYPlot xyp = new XYPlot(cd, na1, na2, xyb); xyb.setSeriesToolTipGenerator(0, new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset xyd, int i, int i1) { return "[" + colnames[xyd.getX(i, i1).intValue()] + ":" + colnames[xyd.getY(i, i1).intValue()] + "] = " + ((XYZDataset) xyd).getZValue(i, i1) + ""; } }); JFreeChart jfc = new JFreeChart(this.title, xyp); NumberAxis values = new NumberAxis("value"); values.setAutoRange(false); values.setRangeWithMargins(min, max); PaintScaleLegend psl = new PaintScaleLegend(ps, values); psl.setBackgroundPaint(jfc.getBackgroundPaint()); jfc.addSubtitle(psl); psl.setStripWidth(50); psl.setPadding(20, 20, 20, 20); psl.setHeight(200); psl.setPosition(RectangleEdge.RIGHT); jtc.setChart(jfc); } } catch (Exception ex) { Exceptions.printStackTrace(ex); } ph.finish(); }
From source file:frames.MainGUI.java
private String removeItemFromFeeTable(int i) { DefaultTableModel model = (DefaultTableModel) this.jTable2.getModel(); String name = (String) model.getValueAt(i, 0); model.removeRow(i);//ww w.j a v a2s . c o m this.resetButtons(); return name; }
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjFieldFormatMultiplePanel.java
/** * @return/* w ww . j a v a 2 s .co m*/ */ protected boolean isValidFormatter() { // check if there's an empty row in the switch formatter table DefaultTableModel model = (DefaultTableModel) formatSwitchTbl.getModel(); if (model.getRowCount() == 0) { return false; // formatter is not valid if there are no internal formatters attached to it } Set<String> valueSet = new HashSet<String>(); // check if there are valid values in each row for (int i = 0; i < model.getRowCount(); ++i) { for (int j = 0; j <= 1; ++j) { Object obj = model.getValueAt(i, j); String value = obj.toString(); if (obj == null || StringUtils.isEmpty(value)) { return false; } // also check if field value is unique (column 0) if (j == 0) { // value already in the set: so it's not unique if (valueSet.contains(value)) return false; valueSet.add(value); } } } return true; }