我使用下面的代码为JPanel设置自定义光标,但是当我运行代码时,它会放大我为光标设置的图像.有没有办法设置用户定义的游标大小?
Toolkit toolkit = Toolkit.getDefaultToolkit();
BufferedImage erasor=new BufferedImage(10,10, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d=(Graphics2D) erasor.createGraphics();
g2d.setPaint(Color.red);
g2d.drawRect(e.getX(),e.getY() ,10, 10);
toolkit.getBestCursorSize(10, 10);
Cursor mcursor=toolkit.createCustomCursor(erasor, new Point(10,10), "Eraser");
setCursor(mcursor);
Run Code Online (Sandbox Code Playgroud) 我有以下场景.实时是应用程序的实现.
1)我需要在容器中存储最多20个条目(STL Map,STL List等).2)如果有新条目并且已经存在20个条目,则必须使用新条目覆盖最旧的条目.
考虑到第2点,我觉得如果容器已满(最多20个条目)'list'是最好的选择,因为我总是可以删除列表中的第一个条目并最后添加新条目(push_back).但是,搜索效率不高.
对于只有20个条目,如果我使用列表代替地图,它在搜索效率方面是否真的有很大差异?
另外考虑在地图中插入的费用我觉得我应该去列表?
你能告诉我什么是更好的选择吗?
我确定有一个非常简单的解决方案.
我有一堆来自项目的.cpp/.h文件,比如在目录中 ~/files
另一方面,我想使用eclipse创建一个c ++项目来处理这些文件,所以我把我的工作区放在上面~/wherever
.然后我创建一个c ++项目:~/wherever/project
并包含源文件(位于/~files
).
我遇到的问题是文件现在被复制了~/wherever/project
,我想避免这种情况,特别是我知道要提交的文件的哪个副本.
这可能吗?我确定它是,但不能得到它.
提前致谢.
我正在尝试使用批处理文件映射驱动器.我试过了:
net use m: \\Server01\myfolder /USER:mynetwork\Administrator "Mypassword" /persistent:yes
Run Code Online (Sandbox Code Playgroud)
它工作正常.当我尝试映射名称中带有空格的文件夹时,问题出现了:
net use m: \\Server01\my folder /USER:mynetwork\Administrator "Mypassword" /persistent:yes
Run Code Online (Sandbox Code Playgroud)
我尝试使用引号,使用myfold~1但没有任何作用.
一个简单的方法是重命名文件夹,但我将它映射到300多个工作站,所以这不是一个好主意.
我需要独特的可重复使用的ID.用户可以选择自己的ID,也可以要求免费.API基本上就是
class IdManager {
public:
int AllocateId(); // Allocates an id
void FreeId(int id); // Frees an id so it can be used again
bool MarkAsUsed(int id); // Let's the user register an id.
// returns false if the id was already used.
bool IsUsed(int id); // Returns true if id is used.
};
Run Code Online (Sandbox Code Playgroud)
假设ID恰好从1开始,进展,2,3等.这不是一个要求,只是为了帮助说明.
IdManager mgr;
mgr.MarkAsUsed(3);
printf ("%d\n", mgr.AllocateId());
printf ("%d\n", mgr.AllocateId());
printf ("%d\n", mgr.AllocateId());
Run Code Online (Sandbox Code Playgroud)
会打印
1
2
4
Run Code Online (Sandbox Code Playgroud)
因为id 3已经被声明使用了.
什么是最好的容器/算法,以记住使用哪些ID并找到一个免费的ID?
如果你想知道一个特定的用例,OpenGL的glGenTextures,glBindTexture和glDeleteTextures等同于AllocateId,MarkAsUsed和FreeId
我是python的新手,我有任务所以我需要扫描wifi并将数据发送到服务器,下面是我必须发送的格式,这在手动输入浏览器URL文本框时工作正常,
http://223.56.124.58:8080/ppod-web/ProcessRawData?data={"userId":"2220081127-14","timestamp":"2010-04-12 10:54:24","wifi":{"ssid":"guest","rssi":"80"}}
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
import httplib
import urllib
params = urllib.urlencode('{\"userId\":\"20081127-14\",\"timestamp\":\"2010-04-12 10:54:24\",\"wifi\":{\"ssid\":\"guest\",\"rssi\":\"80\"}}')
headers = {"Content-type":"application/x-www-form-urlencoded","Accept":"text/plain"}
conn = httplib.HTTPConnection("http://223.56.124.58:8080")
conn.request("POST","ppod-web/ProcessRawData?data=",params,headers)
response = conn.getresponse()
print response.status
print "-----"
print response.reason
data = response.read()
print data
conn.close()
Run Code Online (Sandbox Code Playgroud)
谢谢
http://docs.djangoproject.com/en/dev/intro/tutorial03/
我正在解决URLconfs的步骤,其中教程说明了如何解耦urls.py
.在完全按照它说的做,我得到以下错误 -
error at /polls/1/
nothing to repeat
Request Method: GET
Request URL: http://localhost:8000/polls/1/
Exception Type: error
Exception Value:
nothing to repeat
Exception Location: C:\jython2.5.1\Lib\re.py in _compile, line 241
Python Executable: C:\jython2.5.1\jython.bat
Python Version: 2.5.1
Python Path: ['E:\\Programming\\Project\\django_app\\mysite', 'C:\\jython2.5.1\\Lib\\site-packages\\setuptools-0.6c11-py2.5.egg', 'C:\\jython2.5.1\\Lib', '__classpath__', '__pyclasspath__/', 'C:\\jython2.5.1\\Lib\\site-packages']
Server time: Mon, 12 Apr 2010 12:02:56 +0530
Run Code Online (Sandbox Code Playgroud) 我试图按照"Minimal Perl"一书中描述的方式理解Perl.
我已将所有源txt文件上传到我自己的服务器:results文件夹
我在这样的"链"中使用了几个bash命令获得了输出:
cat run*.txt | grep '^Bank[[:space:]]Balance'|cut -d ':' -f2 | grep -E '\$[0-9]+'
Run Code Online (Sandbox Code Playgroud)
我知道这远非最简洁和有效,但至少它有效......
由于我们的uni主题现在转移到Perl部分,我想知道是否有办法在一行中获得相同的结果?
我尝试类似下面的代码,但卡在中间:
Chenxi Mao@chenxi-a6b123bb /cygdrive/c/eMarket/output
$ perl -wlne 'print; if $n=~/^Bank Balance/'
syntax error at -e line 1, near "if $n"
Execution of -e aborted due to compilation errors.
Run Code Online (Sandbox Code Playgroud) 我的C#项目引用了第三方DLL,我有源代码.我可以以某种方式告诉Visual Studio该源代码的位置,例如,当我按下F12打开DLL中方法的定义时,它将打开源代码,而不是打开"类[来自元数据]"存根代码?
c++ ×3
algorithm ×1
batch-file ×1
comparison ×1
django ×1
django-urls ×1
eclipse ×1
eclipse-cdt ×1
http ×1
java ×1
json ×1
jython ×1
perl ×1
python ×1
reference ×1
stl ×1
swing ×1
url ×1
workspace ×1
xml ×1