下面列出了java.util.TooManyListenersException#printStackTrace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected void installDragSupport() {
tabPane.setTransferHandler(TRANSFER_HANDLER);
try {
DropTarget target = tabPane.getDropTarget();
if (target != null) {
target.addDropTargetListener(TRANSFER_HANDLER);
target.setActive(dndEnabled);
}
} catch (TooManyListenersException e) {
e.printStackTrace();
}
}
protected void installDnD() {
tabFrame.setTransferHandler(TRANSFER_HANDLER);
try {
DropTarget dropTarget = tabFrame.getDropTarget();
if (dropTarget != null) {
dropTarget.addDropTargetListener(TRANSFER_HANDLER);
dropTarget.setActive(tabFrame.isDndEnabled());
}
} catch (TooManyListenersException e) {
e.printStackTrace();
}
}
/**
* 添加监听器
*
* @param port
* 串口对象
* @param listener
* 串口存在有效数据监听
*/
public static void addListener(SerialPort serialPort, DataAvailableListener listener) {
try {
// 给串口添加监听器
serialPort.addEventListener(new SerialPortListener(listener));
// 设置当有数据到达时唤醒监听接收线程
serialPort.notifyOnDataAvailable(true);
// 设置当通信中断时唤醒中断线程
serialPort.notifyOnBreakInterrupt(true);
} catch (TooManyListenersException e) {
e.printStackTrace();
}
}
private void configureGlassLayer() {
try {
glassLayer.setDropTarget(new DropTarget());
glassLayer.getDropTarget().addDropTargetListener(new GlassLayerDropTargetListener());
} catch (TooManyListenersException ex) {
ex.printStackTrace();
}
}
@Override
public void exportAsDrag(JComponent comp, InputEvent e, int action) {
int srcActions = getSourceActions(comp);
// only mouse events supported for drag operations
if (!(e instanceof MouseEvent)
// only support known actions
|| !(action == COPY || action == MOVE || action == LINK)
// only support valid source actions
|| (srcActions & action) == 0) {
action = NONE;
}
if (action != NONE && !GraphicsEnvironment.isHeadless()) {
if (recognizer == null) {
recognizer = new SwingDragGestureRecognizer();
}
DragHandler dgl = new DragHandler();
try {
recognizer.addDragGestureListener(dgl);
} catch (TooManyListenersException e1) {
e1.printStackTrace();
}
recognizer.gestured(comp, (MouseEvent) e, srcActions, action);
recognizer.removeDragGestureListener(dgl);
} else {
exportDone(comp, null, NONE);
}
}