[ normandija @ 05.03.2009. 14:02 ] @
Da li mi moze neko reci zasto mi ne ispisuje podatke u tabeli ??? Ne mogu da nadjem gresku .... dio koji vrsi upis u tabelu je pod metodom getService().... u prilogu sam zakacio source ,pa ako moze pomoc Code: import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Vector; import javax.swing.JTable; import javax.swing.table.AbstractTableModel; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import sun.security.krb5.internal.i; import sun.security.krb5.internal.j; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * mainFrame.java * * Created on Mar 2, 2009, 11:44:39 AM */ /** * * @author Administrator */ public class mainFrame extends javax.swing.JFrame { /** Creates new form mainFrame */ public mainFrame() { initComponents(); } static DefaultTableModel model; /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { lblCityName = new javax.swing.JLabel(); fldCityName = new javax.swing.JTextField(); btnShowResult = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); lblNumRecords = new javax.swing.JLabel(); lblTextNumRecord = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Searching..."); lblCityName.setText("City name:"); fldCityName.setText("fldCityName"); btnShowResult.setText("Show results"); btnShowResult.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnShowResultActionPerformed(evt); } }); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); jLabel1.setText("Information about cities and post codes"); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null}, {null, null}, {null, null}, {null, null} }, new String [] { "City name", "Post Code" } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.String.class }; boolean[] canEdit = new boolean [] { false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); jTable1.setColumnSelectionAllowed(true); jScrollPane1.setViewportView(jTable1); jTable1.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); lblTextNumRecord.setText("Number found records:"); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(lblCityName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 66, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(fldCityName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(18, 18, 18) .add(btnShowResult)) .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 260, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(layout.createSequentialGroup() .add(lblTextNumRecord, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 143, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(21, 21, 21) .add(lblNumRecords)) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 375, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addContainerGap(15, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(jLabel1) .add(19, 19, 19) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(lblCityName) .add(fldCityName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(btnShowResult)) .add(18, 18, 18) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(lblNumRecords) .add(lblTextNumRecord)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 144, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap(24, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void btnShowResultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnShowResultActionPerformed getService(); }//GEN-LAST:event_btnShowResultActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new mainFrame().setVisible(true); } }); } public String getService() { city.WebServiceCityService service = new city.WebServiceCityService(); city.WebServiceCity port = service.getWebServiceCityPort(); String fldCity = fldCityName.getText(); // Passing data over method to service and retrive string back String postCodesString = port.getResults(fldCity); // test.setText(postPutField); // Split string and insert to JTable int counter = 0; int a = 0; int b = 5; String postPutField = ""; List list = new ArrayList(); model = new DefaultTableModel(new String[][]{},new String[]{}); while (a < postCodesString.length()) { postPutField = postCodesString.substring(a, b); a = a + 5; b = b + 5; counter++; // ovdje je stavljeno test1 i test2 samo radi testiranja,a inace tu ce biti dve varijable model.addRow(new String[]{"test1","test2"}); } String strCount = new String(); strCount = new Integer(counter).toString(); lblNumRecords.setText(strCount); return null; } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnShowResult; private javax.swing.JTextField fldCityName; private javax.swing.JLabel jLabel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTable1; private javax.swing.JLabel lblCityName; private javax.swing.JLabel lblNumRecords; private javax.swing.JLabel lblTextNumRecord; // End of variables declaration//GEN-END:variables } |