public String getTextForGesture(long parId, Point topLeft, Point bottomRight) { try { Paragraph p = lockManager.getParFromId(parId); int parY = documentPanel.textPane.modelToView(p.getOffset()).y; topLeft.y = topLeft.y + parY; bottomRight.y = bottomRight.y + parY; int startOffset = documentPanel.textPane.viewToModel(topLeft); int endOffset = documentPanel.textPane.viewToModel(bottomRight); while (startOffset > 0 && Character.isLetterOrDigit((document.getText(startOffset - 1, 1).charAt(0)))) startOffset--; while (endOffset < document.getLength() && Character.isLetterOrDigit((document.getText(endOffset, 1).charAt(0)))) endOffset++; String text = document.getText(startOffset, endOffset - startOffset); return text; } catch (Exception e) { System.out.println("EditorClient: addGestureAction. error identifying text"); e.printStackTrace(); return ""; } // return "PLACEBO"; }
public void actionPerformed(ActionEvent ev) { try { // stok String query = "DELETE FROM stok_produk WHERE id_produk=" + idProduk; int hasil1 = stm.executeUpdate(query); // pemasukkan query = "DELETE FROM pemasukan WHERE id_produk=" + idProduk; int hasil2 = stm.executeUpdate(query); // pengeluaran query = "DELETE FROM pengeluaran WHERE id_produk=" + idProduk; int hasil3 = stm.executeUpdate(query); // produk query = "DELETE FROM produk WHERE id_produk=" + idProduk; int hasil4 = stm.executeUpdate(query); if (hasil1 == 1 || hasil2 == 1 || hasil3 == 1 && hasil4 == 1) { setDataTabel(); JOptionPane.showMessageDialog(null, "berhasil hapus"); } else { JOptionPane.showMessageDialog(null, "gagal"); } } catch (SQLException SQLerr) { SQLerr.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
public JCTimePanel() { try { jbInit(); } catch (Exception ex) { ex.printStackTrace(); } }
/** * @param obj ValueObject related to the current row * @param colIndex TableModel column index * @return Object contained into the TableModel at the specified column and ValueObject */ public final Object getField(ValueObject obj, int colIndex) { try { Method[] m = (Method[]) voGetterMethods.get(getFieldName(colIndex)); if (m == null) Logger.error( this.getClass().getName(), "getField", "No getter method for index " + colIndex + " and attribute name '" + getFieldName(colIndex) + "'.", null); for (int i = 0; i < m.length - 1; i++) { obj = (ValueObject) m[i].invoke(obj, new Object[0]); if (obj == null) { if (grids.getGridControl() == null || !grids.getGridControl().isCreateInnerVO()) return null; else obj = (ValueObject) m[i].getReturnType().newInstance(); } } return m[m.length - 1].invoke(obj, new Object[0]); } catch (Exception ex) { ex.printStackTrace(); return null; } }
public void textInserted(Message.TextInsertMsg m) { if (EditorServer_Debug) System.err.println("EditorServer-> textInserted."); try { int ClientId = m.getClientId(); int offset = m.getOffset(); String characterInserted = m.getText(); if (EditorServer_Debug) System.out.println("EditorServer-> textInserted : *" + characterInserted + "*"); Vector pars = lockManager.textInserted(m.getPar(), offset, characterInserted, ClientId); textChannel.sendToOthers(client, new Data(m)); EditorClient c = getEditorClient(ClientId); // new condition inserted to avoid timestamp generation if the character // is a newline if (characterInserted.equals("\n")) { if (EditorServer_Debug) System.out.println("EditorServer-> textInserted : attempting to insert a newLine"); } c.addTextInsertAction(System.currentTimeMillis(), pars, offset, characterInserted); clientsPanel.updateActionTableFor(c); updateParagraphList(); } catch (Exception e) { System.err.println("EditorServer-> textInserted: error receiving-sending msg"); if (EditorServer_Debug) e.printStackTrace(); } }
public void textInserted(Message.TextPasteMsg m) { try { int SenderId = m.getClientId(); int offset = m.getOffset(); String textPasted = m.getText(); if (EditorServer_Debug) System.err.println("EditorServer->textinserted : PASTED by : " + SenderId); Vector pars = null; try { pars = lockManager.textInserted(m.getPar(), offset, textPasted, SenderId); if (EditorServer_Debug) System.err.println("\n+=*%EditorServer--> textInserted recovered VECTOR..."); } catch (Exception e) { System.err.println("\n+=*%EditorServer--> textInserted VECTOR error "); } textChannel.sendToOthers(client, new Data(m)); EditorClient SenderClient = getEditorClient(SenderId); SenderClient.addTextPasteAction(System.currentTimeMillis(), pars, offset, textPasted); clientsPanel.updateActionTableFor(SenderClient); updateParagraphList(); } catch (Exception e) { System.err.println("\nEditorServer--> textPasted: error sending msg"); if (EditorServer_Debug) e.printStackTrace(); } }
public void setQuery(String q) { cache = new Vector(); try { ResultSet rs = statement.executeQuery(q); ResultSetMetaData meta = rs.getMetaData(); colCount = meta.getColumnCount(); headers = new String[colCount]; for (int h = 1; h <= colCount; h++) { headers[h - 1] = meta.getColumnName(h); } while (rs.next()) { String[] record = new String[colCount]; for (int i = 0; i < colCount; i++) { record[i] = rs.getString(i + 1); } cache.addElement(record); } // while sonu fireTableChanged(null); } // try sonu catch (Exception e) { cache = new Vector(); e.printStackTrace(); } } // setQuery sonu
public void sendHighlights() { // send highlights to everybody try { Iterator i = highlights.getHighlights().iterator(); while (i.hasNext()) { Highlights.Highlight h = (Highlights.Highlight) i.next(); Paragraph sPar = lockManager.getParFromOffset(h.getStart()); Paragraph ePar = lockManager.getParFromOffset(h.getEnd()); if (EditorServer_Debug) { System.out.println("StartPar: " + sPar.toString()); System.out.println("EndPar: " + ePar.toString()); } Message.HighlightAddMsg msg = new Message.HighlightAddMsg( -1, h.getId(), h.getType().getId(), sPar.getID(), ePar.getID(), h.getStart() - sPar.getOffset(), h.getEnd() - ePar.getOffset()); textChannel.sendToOthers(client, new Data(msg)); } } catch (Exception e) { System.err.println("EditorServer: sendHighlights: error sending msg"); if (EditorServer_Debug) e.printStackTrace(); } }
public void actionPerformed(ActionEvent evt) { // 删除原来的JTable(JTable使用scrollPane来包装) if (scrollPane != null) { jf.remove(scrollPane); } try ( // 根据用户输入的SQL执行查询 ResultSet rs = stmt.executeQuery(sqlField.getText())) { // 取出ResultSet的MetaData ResultSetMetaData rsmd = rs.getMetaData(); Vector<String> columnNames = new Vector<>(); Vector<Vector<String>> data = new Vector<>(); // 把ResultSet的所有列名添加到Vector里 for (int i = 0; i < rsmd.getColumnCount(); i++) { columnNames.add(rsmd.getColumnName(i + 1)); } // 把ResultSet的所有记录添加到Vector里 while (rs.next()) { Vector<String> v = new Vector<>(); for (int i = 0; i < rsmd.getColumnCount(); i++) { v.add(rs.getString(i + 1)); } data.add(v); } // 创建新的JTable JTable table = new JTable(data, columnNames); scrollPane = new JScrollPane(table); // 添加新的Table jf.add(scrollPane); // 更新主窗口 jf.validate(); } catch (Exception e) { e.printStackTrace(); } }
public void setFolder(Folder newFolder) throws MessagingException { if (folder != null) { try { folder.removeMessageCountListener(messageCountListener); folder.close(true); } catch (Exception ex) { // Failure here seems to happen relatively often. // enp has a corrupt folder, for example, and enh finds that Exchange seems to sometimes // close folders on him, maybe because he's running Outlook at the same time. // It's not currently obvious that there's much to be gained by showing this error to the // user. // It does seem that we should blunder on, rather than back out, because the UI's already // been updated by this point. // If we back out here, we really need to back out the UI change too, and going that route // seems like a mistake. ex.printStackTrace(); } } this.folder = newFolder; this.messages = Collections.<Message>emptyList(); if (folder != null) { scanWholeFolder(); folder.addMessageChangedListener(messageChangedListener); folder.addMessageCountListener(messageCountListener); } }
public boolean loadDocument(String fileName) { try { File file = new File(fileName); ObjectInputStream in = new ObjectInputStream(new FileInputStream(file)); SavedDocument doc = (SavedDocument) in.readObject(); document = new EditorDocument( doc.getTitle(), doc.getDescription(), doc.getText(), doc.getStartTime()); paragraphs = new Paragraphs(document, doc.getParagraphsVector()); clients = doc.getClients(); Iterator i = clients.iterator(); while (i.hasNext()) { EditorClient c = (EditorClient) i.next(); c.setPresent(false); if (c.getIdNumber() > nextClientId) nextClientId = c.getIdNumber(); } nextClientId++; lockManager = new LockManager(clients, document, paragraphs); highlights = new Highlights(lockManager, document, doc.getHighlightTypes(), doc.getHighlights()); return true; } catch (Exception e) { System.out.println("EditorServer: loadDocument. error"); e.printStackTrace(); return false; } } // endof const WITH audio profile maker
/** Start talking to the server */ public void start() { String codehost = getCodeBase().getHost(); if (socket == null) { try { // Open the socket to the server socket = new Socket(codehost, port); // Create output stream out = new ObjectOutputStream(socket.getOutputStream()); out.flush(); // Create input stream and start background // thread to read data from the server in = new ObjectInputStream(socket.getInputStream()); new Thread(this).start(); } catch (Exception e) { // Exceptions here are unexpected, but we can't // really do anything (so just write it to stdout // in case someone cares and then ignore it) System.out.println("Exception! " + e.toString()); e.printStackTrace(); setErrorStatus(STATUS_NOCONNECT); socket = null; } } else { // Already started } if (socket != null) { // Make sure the right buttons are enabled start_button.setEnabled(false); stop_button.setEnabled(true); setStatus(STATUS_ACTIVE); } }
@Override public void actionPerformed(ActionEvent e) { ID = (Integer) hashRoomType.get(boxRoomTypeID.getSelectedItem().toString()); IDSTATUS = (Integer) hashRoomStatus.get(boxRoomStatusID.getSelectedItem().toString()); if (e.getSource() == buttonInsert) { try { Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS); RoomsController.roomsController.save(rooms); int c = model.getRowCount(); for (int i = c - 1; i >= 0; i--) { model.removeRow(i); jRoom.revalidate(); } all(); JOptionPane.showMessageDialog(this, "ok"); } catch (Exception ex) { ex.printStackTrace(); } } if (e.getSource() == buttonUpdate) { try { Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS); rooms.setRoomID(IDROOM); RoomsController.roomsController.update(rooms); int c = model.getRowCount(); for (int i = c - 1; i >= 0; i--) { model.removeRow(i); jRoom.revalidate(); } all(); JOptionPane.showMessageDialog(this, "Update to succeed !"); } catch (Exception ex) { ex.printStackTrace(); } } if (e.getSource() == buttonDelete) { try { List<CheckIn> temp = CheckInController.checkInController.all(); for (int i = 0; i < temp.size(); i++) { if (IDROOM == temp.get(i).getRoomID()) { this.error = 0; } else { this.error = 0; RoomsController.roomsController.delete(IDROOM); int c = model.getRowCount(); for (int ii = c - 1; ii >= 0; ii--) { model.removeRow(ii); jRoom.revalidate(); } all(); } } JOptionPane.showMessageDialog(this, "Delete to succeed !"); } catch (Exception ex) { JOptionPane.showMessageDialog(this, "can't delete row bcause check still !"); } } if (e.getSource() == buttonRefresh) {} }
public FileList() { super("FileList", true, true, true); try { jbInit(); } catch (Exception ex) { ex.printStackTrace(); } }
public TableDwnld() { setDataModel(new ModelTableDwnld()); try { jbInit(); } catch (Exception e) { e.printStackTrace(); } }
public Class getColumnClass(int columnIndex) { try { return set.getTypeClass(columnIndex); } catch (Exception e) { e.printStackTrace(); } return String.class; }
/** * @param colIndex TableModel column index * @return TableCellEditor for the specified column */ public final TableCellEditor getCellEditor(int colIndex) { try { return colProperties[colIndex].getCellEditor(tableContainer, grids); } catch (Exception ex) { ex.printStackTrace(); return null; } }
public boolean dbOpenList(Connection connection, String sql) { dbClearList(); this.oldSql = sql; this.oldConnection = connection; // apre il resultset da abbinare ResultSet resu = null; ResultSetMetaData meta; try { stat = connection.createStatement(); resu = stat.executeQuery(sql); meta = resu.getMetaData(); if (meta.getColumnCount() > 1) { this.contieneChiavi = true; } // righe while (resu.next()) { for (int i = 1; i <= meta.getColumnCount(); ++i) { if (i == 1) { dbItems.add((Object) resu.getString(i)); lm.addElement((Object) resu.getString(i)); } else if (i == 2) { dbItemsK.add((Object) resu.getString(i)); // debug // System.out.println("list:" + String.valueOf(i) + ":" + resu.getString(i)); } else if (i == 3) { dbItemsK2.add((Object) resu.getString(i)); } } } this.setModel(lm); // vado al primo if (dbTextAbbinato != null) { // debug // javax.swing.JOptionPane.showMessageDialog(null,this.getKey(0).toString()); dbTextAbbinato.setText(this.getKey(0).toString()); } return (true); } catch (Exception e) { javax.swing.JOptionPane.showMessageDialog(null, e.toString()); e.printStackTrace(); return (false); } finally { try { stat.close(); } catch (Exception e) { } try { resu.close(); } catch (Exception e) { } meta = null; } }
/** コンストラクタです。 */ public QO005Design() { try { initialize(); } catch (Exception e) { e.printStackTrace(); } }
public static void main(String[] args) { // デフォルトデバッグ起動 try { ACFrame.getInstance().setFrameEventProcesser(new QkanFrameEventProcesser()); ACFrame.debugStart(new ACAffairInfo(QS001_13811_201504Design.class.getName())); } catch (Exception e) { e.printStackTrace(); } }
/** コンストラクタです。 */ public QS001_13811_201504Design() { try { initialize(); } catch (Exception e) { e.printStackTrace(); } }
public final Class getColumnClass(int columnIndex) { try { Method[] m = (Method[]) voGetterMethods.get(attributeNames[columnIndex]); return m[m.length - 1].getReturnType(); } catch (Exception ex) { ex.printStackTrace(); return String.class; } }
private void all() { try { for (Rooms rooms : RoomsController.roomsController.all()) { model.insertRow(0, rooms.toArray()); } } catch (Exception ex) { ex.printStackTrace(); } }
public void sendClientReject(int keyValue, int reason) { Message.ClientRejectMsg msg = new Message.ClientRejectMsg(-1, keyValue, reason); try { clientChannel.sendToOthers(client, new Data(msg)); } catch (Exception e) { System.err.println("EditorServer: clientRejected: error sending msg"); if (EditorServer_Debug) e.printStackTrace(); } }
public void initDB(String url) { try { db = DriverManager.getConnection(url); statement = db.createStatement(); } catch (Exception e) { System.out.println("Database could not started"); e.printStackTrace(); } } // initDB sonu
public void setTime(String theTime) { time = theTime; try { this.theDate = dateFormat.parse(time); } catch (Exception ex) { jade.util.Logger.getMyLogger(this.getClass().getName()) .log(jade.util.Logger.WARNING, ex.getMessage()); } }
public int getYValueFromOffset(int offset) { try { return textPane.modelToView(offset).y; } catch (Exception e) { System.out.println("EditorServer: DocumentPanel: getYValueFromOffset. error"); e.printStackTrace(); return 0; } }
public void scrollMoved(Message.ScrollMoveMsg m) { // if(EditorServer_Debug) System.err.println("EditorServer: scrollMoved.") ; try { clientChannel.sendToOthers(client, new Data(m)); } catch (Exception e) { System.err.println("EditorServer: scrollMoved: error sending msg"); if (EditorServer_Debug) e.printStackTrace(); } }
public void sendDocumentState(int clientId) { Message.DocumentStateMsg msg = new Message.DocumentStateMsg(clientId, lockManager.getDocumentAsXML()); try { clientChannel.sendToOthers(client, new Data(msg)); } catch (Exception e) { System.err.println("EditorServer: sendDocumentState: error sending msg"); if (EditorServer_Debug) e.printStackTrace(); } }
public void lockReleased(Message.LockReleaseMsg m) { if (EditorServer_Debug) System.err.println("EditorServer: lockReleased."); lockManager.lockReleased(m.getStartPar(), m.getEndPar(), m.getClientId()); try { textChannel.sendToOthers(client, new Data(m)); } catch (Exception e) { System.err.println("EditorServer: lockReleased: error sending lock released"); if (EditorServer_Debug) e.printStackTrace(); } }