|
4 | 4 | import java.awt.Font; |
5 | 5 | import java.awt.Graphics; |
6 | 6 | import java.awt.Graphics2D; |
| 7 | +import java.awt.GraphicsEnvironment; |
7 | 8 | import java.awt.Point; |
8 | 9 | import java.awt.Rectangle; |
9 | 10 | import java.awt.RenderingHints; |
@@ -166,15 +167,12 @@ public Struktogramm(StrTabbedPane tabbedpane){ |
166 | 167 | addMouseMotionListener(this); |
167 | 168 |
|
168 | 169 |
|
169 | | - /*Drag & Drop aktivieren, siehe |
170 | | - http://www.java2s.com/Code/Java/Swing-JFC/MakingaComponentDraggable.htm |
171 | | - und |
172 | | - http://www.java2s.com/Code/Java/Swing-JFC/PanelDropTarget.htm |
173 | | - */ |
174 | | - dragSource = new DragSource(); |
175 | | - dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this); |
176 | | - |
177 | | - new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, this, true, null); |
| 170 | + /* Drag & Drop nur mit Display (GitHub CI / headless: Tests ohne X11). */ |
| 171 | + if (!GraphicsEnvironment.isHeadless()) { |
| 172 | + dragSource = new DragSource(); |
| 173 | + dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this); |
| 174 | + new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, this, true, null); |
| 175 | + } |
178 | 176 |
|
179 | 177 |
|
180 | 178 |
|
@@ -1431,7 +1429,8 @@ public void dragGestureRecognized(DragGestureEvent evt) {//ein Element aus dem S |
1431 | 1429 |
|
1432 | 1430 | dragZwischenlagerElement = (StruktogrammElement)dragZwischenlagerListe.gibElementAnPos(mausPos.x,mausPos.y,false);//das gezogene Element wird gespeichert |
1433 | 1431 |
|
1434 | | - if ((dragZwischenlagerElement != null) && !(dragZwischenlagerElement instanceof LeerElement)){//wenn das Element nicht null ist und kein LeerElement ist... |
| 1432 | + if ((dragZwischenlagerElement != null) && !(dragZwischenlagerElement instanceof LeerElement) |
| 1433 | + && dragSource != null) {//wenn das Element nicht null ist und kein LeerElement ist... |
1435 | 1434 | Transferable t = new StringSelection("z");//z für Element aus dem Zwischenlager |
1436 | 1435 |
|
1437 | 1436 | dragSource.startDrag(evt, DragSource.DefaultCopyDrop, t, this);//...wird ein Drag ausgelöst |
|
0 commit comments