Skip to main content

Posts

Showing posts from May, 2014

Java Swing JTable the proper way to remove rows

Problem .. removing the last row is throwing array out of index exception in the GUI scope! solution ... make the removing action inside invokeLater block , this will make the GUI listeners work correctly final DefaultTableModel model=   ((DefaultTableModel)jTable.getModel());                      SwingUtilities.invokeLater(new Runnable() {                 @Override                 public void run() {                      model.removeRow(_row);                 }                 } );

Android read from bar-code scanner

private TextView result; private String barCode=""; @Override public boolean onKeyDown(int keyCode, KeyEvent event) { char pressedKey = (char) event.getUnicodeChar(); if(result==null){ // System.out.println("result=null"); result=(TextView)findViewById(R.id.scanResult); } barCode+=pressedKey; if(event.getKeyCode()==KeyEvent.KEYCODE_ENTER){ result.setText(barCode); barCode=""; } return super.onKeyDown(keyCode, event); }