public void ListenAndDo() { try { while (true) { in = new ObjectInputStream(new BufferedInputStream(sockt.getInputStream())); Packet message = (Packet) in.readObject(); Log.outString("Packet received from server (opcode :" + message.getOpcode() + ")"); if (message.getOpcode().equals(0x07)) break; TreatPacket(message); sleep(100); } Log.outTimed("Close connection with server"); sockt.close(); } catch (SocketTimeoutException ste) { Log.outTimed("Server connection timeout"); } catch (EOFException e) { try { sockt.close(); } catch (IOException e1) { this.interrupt(); } this.interrupt(); } catch (SocketException e) { this.interrupt(); } catch (Exception e) { e.printStackTrace(); this.interrupt(); } }
// This method is called when a cell value is edited by the user. @Override public Component getTableCellEditorComponent( JTable table, Object value, boolean isSelected, int rowIndex, int colIndex) { DeviceControlTableModel data = (DeviceControlTableModel) table.getModel(); item_ = data.getPropertyItem(rowIndex); // Configure the component with the specified value: if (item_.allowed.length == 0) { if (item_.hasRange) { if (item_.isInteger()) { slider_.setLimits((int) item_.lowerLimit, (int) item_.upperLimit); } else { slider_.setLimits(item_.lowerLimit, item_.upperLimit); } try { slider_.setText((String) value); } catch (ParseException ex) { Log.log(ex); } return slider_; } else { text_.setText((String) value); return text_; } } else { ActionListener[] l = combo_.getActionListeners(); for (int i = 0; i < l.length; i++) { combo_.removeActionListener(l[i]); } combo_.removeAllItems(); for (int i = 0; i < item_.allowed.length; i++) { combo_.addItem(item_.allowed[i]); } combo_.setSelectedItem(item_.value); // end editing on selection change combo_.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fireEditingStopped(); } }); return combo_; } }