My java application waits till the trigger compltes its job and as a result it hangs my application.
Please give me a solution wherein I do my table insert and my java application control gets back immediately.
Thank
Radhika
Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!
Edited by DragonMaster Jay, 04 June 2009 - 11:05 AM.
Edited by stettybet0, 05 June 2009 - 02:15 PM.
Have you read what the user stated his/her problem was? Explain to me how simply updating Java would remedy his/her issue.
I mean, it would be nice if code magically wrote itself when you updated Java, but it doesn't.
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; import javax.swing.event.*; public class GinTable extends JFrame{ Container container; JTable table; JScrollPane scrollPane; JButton button; public GinTable () { super ("GinTable"); container = this.getContentPane (); String [] columnTitles = { "Player name", "Game 1 Score"}; Object[][] dataEntries = { {"Lynne", new Integer (1),new Integer(2)}, {"Dan", new Integer (1),new Integer(2)}, {"push button for total:",null} }; TableModel model = new EditableTableModel (columnTitles, dataEntries); table = new JTable(model); table.createDefaultColumnsFromModel(); JButton button = new JButton("Calculate Score"); button.setPreferredSize(new Dimension(100,25)); GridLayout grid = new GridLayout(0,1, 10,10); container.setLayout(grid); container.add(new JScrollPane(table)); container.add(button); button.addActionListener(new ButtonL ()); addWindowListener (new WindowEventHandler ()); setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE); setBackground (Color.white); setSize(350, 300); show(); } //end of constructor method class WindowEventHandler extends WindowAdapter { // inner class for window events public void windowClosing (WindowEvent evt) { System.exit (0); }//End of sytem exit methdo } //end of WindowEventHandler inner class class ButtonL implements ActionListener // inner class for button { public void actionPerformed (ActionEvent e) { //example: add the scores int total=0; int tableLength = table.getRowCount(); for (int i=0;i<tableLength-1;i++) { //use the getValueAt() method: total+=((Integer)(table.getValueAt(i,1))).intValue(); } //This is how to use the setValueAt() method, where //"new Integer(total)" is the wrapper, //"tableLength" is the row # and 1 is the column #: table.setValueAt(new Integer(total),tableLength-1,1); //IMPORTANT: now tell the JTable to update its view: ((AbstractTableModel)( table.getModel())).fireTableChanged(null); // what code here to change the values in "dataentries" //or to access the For other calculations?? }; } // end of button class public static void main (String [ ] args ) { // start of main method GinTable frame = new GinTable(); }//end of main method public class EditableTableModel extends AbstractTableModel // inner class for editableTableModel { String[] columnTitles; Object [][] dataEntries; int rowCount; public EditableTableModel (String [] columnTitles, Object[][] dataEntries) { this.columnTitles = columnTitles; this.dataEntries = dataEntries; } // end of editmethod constructor public int getRowCount () { return dataEntries.length; } //end getRowcount public int getColumnCount() { return columnTitles.length; } //end Columncount public Object getValueAt(int row, int column) { return dataEntries[row][column]; } public String getColumnName (int column) { return columnTitles[column]; } public Class getColumnClass (int column) { return getValueAt(0,column).getClass(); } public boolean isCellEditable(int row,int column) { return true; } public void setValueAt(Object value, int row,int column) { dataEntries[row][column] = value; } } //end of inner class EditableTableModel } // end of class
Edited by DragonMaster Jay, 06 June 2009 - 12:37 AM.
Updating Java would not update COBOL. Updating Java would not change the user's code (or "methods") at all. Updating Java is not an acceptable fix for the user's problem.COBOL is an older programming language, so a switch to newer methods would eliminate the bug.
I studied Java for quite a while. COBOL is an older programming language, so a switch to newer methods would eliminate the bug. I gathered some example info from the DB of examples I have:
Is this familiar (just an example on doing tables from here):import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; import javax.swing.event.*; public class GinTable extends JFrame{ Container container; JTable table; JScrollPane scrollPane; JButton button; public GinTable () { super ("GinTable"); container = this.getContentPane (); String [] columnTitles = { "Player name", "Game 1 Score"}; Object[][] dataEntries = { {"Lynne", new Integer (1),new Integer(2)}, {"Dan", new Integer (1),new Integer(2)}, {"push button for total:",null} }; TableModel model = new EditableTableModel (columnTitles, dataEntries); table = new JTable(model); table.createDefaultColumnsFromModel(); JButton button = new JButton("Calculate Score"); button.setPreferredSize(new Dimension(100,25)); GridLayout grid = new GridLayout(0,1, 10,10); container.setLayout(grid); container.add(new JScrollPane(table)); container.add(button); button.addActionListener(new ButtonL ()); addWindowListener (new WindowEventHandler ()); setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE); setBackground (Color.white); setSize(350, 300); show(); } //end of constructor method class WindowEventHandler extends WindowAdapter { // inner class for window events public void windowClosing (WindowEvent evt) { System.exit (0); }//End of sytem exit methdo } //end of WindowEventHandler inner class class ButtonL implements ActionListener // inner class for button { public void actionPerformed (ActionEvent e) { //example: add the scores int total=0; int tableLength = table.getRowCount(); for (int i=0;i<tableLength-1;i++) { //use the getValueAt() method: total+=((Integer)(table.getValueAt(i,1))).intValue(); } //This is how to use the setValueAt() method, where //"new Integer(total)" is the wrapper, //"tableLength" is the row # and 1 is the column #: table.setValueAt(new Integer(total),tableLength-1,1); //IMPORTANT: now tell the JTable to update its view: ((AbstractTableModel)( table.getModel())).fireTableChanged(null); // what code here to change the values in "dataentries" //or to access the For other calculations?? }; } // end of button class public static void main (String [ ] args ) { // start of main method GinTable frame = new GinTable(); }//end of main method public class EditableTableModel extends AbstractTableModel // inner class for editableTableModel { String[] columnTitles; Object [][] dataEntries; int rowCount; public EditableTableModel (String [] columnTitles, Object[][] dataEntries) { this.columnTitles = columnTitles; this.dataEntries = dataEntries; } // end of editmethod constructor public int getRowCount () { return dataEntries.length; } //end getRowcount public int getColumnCount() { return columnTitles.length; } //end Columncount public Object getValueAt(int row, int column) { return dataEntries[row][column]; } public String getColumnName (int column) { return columnTitles[column]; } public Class getColumnClass (int column) { return getValueAt(0,column).getClass(); } public boolean isCellEditable(int row,int column) { return true; } public void setValueAt(Object value, int row,int column) { dataEntries[row][column] = value; } } //end of inner class EditableTableModel } // end of class
(Upgrading Java was only asked for so it can optimize the performance. Not just to throw out some fix.)
0 members, 0 guests, 0 anonymous users
Community Forum Software by IP.Board
Licensed to: Geeks to Go, Inc.