我扩展的JList让用户拖放重新排序它(使用拖放重新排序JList并使用拖放重新排序列表)但它给了我一个奇怪的结果.它没有给我我的习惯JComponent,而是给了我它的.toString()价值.我我自定义的模型设置JList来DefaultListModel<JComponent>思考它会工作,但事实并非如此.
题:
我需要一个DragAndDrop解决方案来下载Windows资源管理器的C#和.NET 4.0文件夹中的文件.没有必要在计算机上安装该文件.该文件足够大,拖动时间不足以完成下载.我发现了各种问题,甚至是已经接受的答案,但没有任何问题.最接近工作的是这个演示项目:
如何实现此代码下载文件作为将其放入Windows资源管理器中的放置位置的操作的一部分?
我正在将节点从一个应用程序拖到另一个应用程序.只有在我之前选择节点时,它才能正常工作.这是因为我使用GetNodeData(FocusedNode)方法收集数据.
我想以某种方式在节点悬停上自动聚焦节点.可能吗?
我正在使用VirtualTreeView v.4.8.7
我有一个DragListener我想获得视图发布位置的坐标.但是,不管我在哪里砸我得到x = 0和y = 0.显然我做错了什么.我如何获得x和y发布点?
this.setOnDragListener(new View.OnDragListener() {
CustomIcon temp;
CustomIcon dragging;
Boolean thisOne;
public boolean onDrag(View v, DragEvent event) {
for(int i= 0; i<mIcons.size();i++) {
temp = mIcons.get(i);
thisOne = temp.getDragging();
if(thisOne) {
dragging = temp;
}
}
final int action = event.getAction();
switch (action) {
case DragEvent.ACTION_DRAG_STARTED: {
Toast.makeText(getContext(), "Dragging: "+v+" Width:"+dragging.getWidth()+ " X:"+dragging.getX(),Toast.LENGTH_SHORT).show();
dragging.setVisibility(View.INVISIBLE);
} break;
case DragEvent.ACTION_DRAG_ENDED: {
dragging.setVisibility(View.VISIBLE);
dragging.stopDragging();
// WHERE MY PROBLEM IS:
Toast.makeText(getContext(), …Run Code Online (Sandbox Code Playgroud) 如何在不需要Honeycomb或超越操作系统的情况下使用Android中的视图进行拖放操作?该意见支持拖放功能,但是需要API等级11.
我对WPF还是很陌生,尽管我有一些Forms的经验,所以我决定最终尝试弄清楚如何使用WPF。因此,当我使用可拖动控件时,这是我想到的代码(我尝试将其更改为与WPF配合使用,但控件随处可见):
private void rectangle1_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed) {
double x = this.Left + (double)e.GetPosition(this).X - (double)rectangle1.Margin.Left;
double y = this.Top + (double)e.GetPosition(this).Y - (double)rectangle1.Margin.Top;
rectangle1.Margin = new Thickness(x, y, rectangle1.Margin.Right, rectangle1.Margin.Bottom);
}
}
Run Code Online (Sandbox Code Playgroud) DefaultTableModel modeltable = new DefaultTableModel(8,8);
table = new JTable(modeltable);
table.setBorder(BorderFactory.createLineBorder (Color.blue, 2));
int height = table.getRowHeight();
table.setRowHeight(height=50);
table.setColumnSelectionAllowed(true);
table.setDragEnabled(true);
le1.setFillsViewportHeight(true);
panel.add(table);
panel.setSize(400,400);
DnDListener dndListener = new DnDListener();
DragSource dragSource = new DragSource();
DropTarget dropTarget1 = new DropTarget(table, dndListener);
DragGestureRecognizer dragRecognizer2 = dragSource.
createDefaultDragGestureRecognizer(option1,
DnDConstants.ACTION_COPY, dndListener);
DragGestureRecognizer dragRecognizer3 = dragSource.
createDefaultDragGestureRecognizer(option2,
DnDConstants.ACTION_COPY, dndListener);
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个问题,将鼠标监听器添加到"table"这是drop target,接受drop组件从鼠标中掉落的地方.在此代码中,当组件进入放置目标时,它总是进入默认位置.我无法自定义放置目标上的位置.请有人帮我这个.提前致谢
我有DataGridView dgv.在dgv的一个单元格中,我有一个带灰色阴影的单元格(其余单元格为空白和白色).我希望能够将该阴影单元格拖动到该列中的另一个单元格,并从前一个单元格的位置,值,行#,列#等以及新单元格的位置,值,行/列中获取信息.这可能吗?这非常类似于棋盘,其中"棋子"通过拖动从一个单元格移动到另一个单元格.
我想在我的Mac应用程序中实现一些"简单"的拖放操作.我在视图中拖动并相应地在我的nib文件中输入"MyView".但是我的控制台中没有得到任何响应(我尝试在触发任何协议方法时记录消息)
我有这样的NSView子类:
@interface MyView : NSView <NSDraggingDestination>{
NSImageView* imageView;
}
Run Code Online (Sandbox Code Playgroud)
并像这样实现它:
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self registerForDraggedTypes:[NSImage imagePasteboardTypes]];
NSRect rect = NSMakeRect(150, 0, 400, 300);
imageView = [[NSImageView alloc] initWithFrame:rect];
[imageView setImageScaling:NSScaleNone];
[imageView setImage:[NSImage imageNamed:@"test.png"]];
[self addSubview:imageView];
}
return self;
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender{
NSLog(@"entered");
return NSDragOperationCopy;
}
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender{
return NSDragOperationCopy;
}
- (void)draggingExited:(id <NSDraggingInfo>)sender{
NSLog(@"exited");
}
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender{
NSLog(@"som");
return YES;
}
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
NSPasteboard *pboard = [sender draggingPasteboard]; …Run Code Online (Sandbox Code Playgroud) 我正在使用JavaFX 2表格来播放某些播放列表,我希望能够在表格中拖放行,例如在第2行之前拖动第3行,就像您在典型媒体播放器中播放列表中的拖放内容一样比如Winamp,AIMP ......
那可能吗?那个代码样本?非常感谢你!