Swing 中是否有一种优雅的方式来查明我的框架中当前是否显示任何工具提示?
我正在使用自定义工具提示,因此在我的方法中设置标志非常容易createToolTip()
,但我看不到一种方法来找出工具提示何时消失。
ToolTipManager
有一个很好的标志,tipShowing,但当然是这样private
,他们似乎没有提供一种方法来实现它。 hideWindow()
没有调用工具提示组件(我可以告诉),所以我看不到那里的方法。
有人有什么好主意吗?
更新:我进行了反思。您可以在此处查看代码:
private boolean isToolTipVisible() {
// Going to do some nasty reflection to get at this private field. Don't try this at home!
ToolTipManager ttManager = ToolTipManager.sharedInstance();
try {
Field f = ttManager.getClass().getDeclaredField("tipShowing");
f.setAccessible(true);
boolean tipShowing = f.getBoolean(ttManager);
return tipShowing;
} catch (Exception e) {
// We'll keep silent about this for now, but obviously we don't want to hit this
// e.printStackTrace();
return false;
}
}
Run Code Online (Sandbox Code Playgroud) 我有两个问题:
1.我已经开始使用Linq解决XML问题了,我想知道是否可以通过Linq更改XML文档.我的意思是,有什么喜欢的
XDocument xmlDoc = XDocument.Load("sample.xml");
update item in xmlDoc.Descendants("item")
where (int)item .Attribute("id") == id
...
Run Code Online (Sandbox Code Playgroud)
2.我已经知道如何通过简单地使用创建和添加新的XMLElement
xmlDoc.Element("items").Add(new XElement(......);
Run Code Online (Sandbox Code Playgroud)
但是如何删除单个条目?
XML样本数据:
<items>
<item id="1" name="sample1" info="sample1 info" web="" />
<item id="2" name="sample2" info="sample2 info" web="" />
</itmes>
Run Code Online (Sandbox Code Playgroud) 什么是更好的方式来启动一个线程_beginthread
,_beginthreadx
或CreateThread
?
我试图确定什么是优势/劣势_beginthread
,_beginthreadex
和CreateThread
.所有这些函数都返回一个新创建的线程的线程句柄,我已经知道CreateThread在发生错误时提供了一些额外的信息(可以通过调用来检查GetLastError
)......但是当我发现时,我应该考虑哪些事情?我用这些功能?
我正在使用Windows应用程序,因此跨平台兼容性已经不可能了.
我已经浏览了msdn文档,但我无法理解,例如,为什么有人会决定使用_beginthread而不是CreateThread,反之亦然.
干杯!
更新:好的,感谢所有的信息,我也读过几个我不能打电话的地方,WaitForSingleObject()
如果我用的话_beginthread()
,但是如果我_endthread()
在线程中打电话应该不行吗?这有什么交易?
我的代码如下:
URLConnection cnx = address.openConnection();
cnx.setAllowUserInteraction(false);
cnx.setDoOutput(true);
cnx.addRequestProperty("User-Agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
InputStream is = cnx.getInputStream();
Run Code Online (Sandbox Code Playgroud)
如果我在收到之前设置标题是否可以InputStream
?我的标题会被发送,还是服务器会看到默认URLConnection
的用户代理(如果有的话)?
我有一个控件,用户可以用鼠标调整大小.当他们移动右侧时,我只是改变宽度,一切正常.
但是,当他们移动左侧大小时,我必须更改"左"和"宽度"属性.控制器的右侧明显抽搐,显示新位置的旧宽度.
如果我使用Bounds一次设置左侧和宽度,它仍会抽搐; 我是否将SetStyle与UserPaint,Opaque,OptimizedDoubleBuffer,AllPaintingInWmPaint或ResizeRedraw中的任何一个一起使用; 以及它是否是双缓冲的.如果我在控件或其父控件上调用SuspendLayout()/ ResumeLayout(),它仍会抽搐.
当我改变左侧位置和宽度时,如何阻止控制旋转?
我需要创建一个XmlDocument
包含多个名称空间的根元素.我使用的是C#2.0或3.0
这是我的代码:
XmlDocument doc = new XmlDocument();
XmlElement root = doc.CreateElement("JOBS", "http://www.example.com");
doc.AppendChild(root);
XmlElement job = doc.CreateElement("JOB", "http://www.example.com");
root.AppendChild(job);
XmlElement docInputs = doc.CreateElement("JOB", "DOCINPUTS", "http://www.example.com");
job.AppendChild(docInputs);
XmlElement docInput = doc.CreateElement("JOB", "DOCINPUT", "http://www.example.com");
docInputs.AppendChild(docInput);
XmlElement docOutput = doc.CreateElement("JOB", "DOCOUTPUT", "http://www.example.com");
docOutputs.AppendChild(docOutput);
Run Code Online (Sandbox Code Playgroud)
目前的输出:
<JOBS xmlns="http://www.example.com">
<JOB>
<JOB:DOCINPUTS xmlns:JOB="http://www.example.com">
<JOB:DOCINPUT />
</JOB:DOCINPUTS>
<JOB:DOCOUTPUTS xmlns:JOB="http://www.example.com">
<JOB:DOCOUTPUT />
</JOB:DOCOUTPUTS>
</JOB>
</JOBS>
Run Code Online (Sandbox Code Playgroud)
但是,我想要的输出是:
<JOBS xmlns:JOBS="http://www.example.com" xmlns:JOB="http://www.example.com">
<JOB>
<JOB:DOCINPUTS>
<JOB:DOCINPUT />
</JOB:DOCINPUTS>
<JOB:DOCOUTPUTS>
<JOB:DOCOUTPUT />
</JOB:DOCOUTPUTS>
</JOB>
</JOBS>
Run Code Online (Sandbox Code Playgroud)
我的问题:我如何创建一个XmlDocument
包含多个名称空间的根元素?
当试图杀死包含Emacs中的更改的缓冲区时,会显示消息:"Buffer [buffer] modified; kill all any?(yes or no)".
而不是这个我想让Emacs问我是否要:1.查看更改的差异,2.保存缓冲区,3.杀死缓冲区.
怎么样?
有没有人有成功地将调试器附加到系留设备?我能够在模拟器中调试我的j2me应用程序,但在出现时解决手机特定的问题时会遇到很多麻烦.我使用的手机是诺基亚N95,但理想情况下,调试过程适用于任何手机.
这可能吗?如果是这样的话,他们有过步骤设置的步骤吗?
我使用嵌套的html无序列表作为下拉列表.当单击内部列表列表项中的a标记时,它会触发一些javascript,该javascript应该将隐藏字段的值设置为单击的链接的文本.
javascript似乎工作 - 我使用警报从隐藏字段中读取值,但是当我尝试将该值放在我的asp.net c#代码后面的查询字符串中时 - 它会拉出初始值 - 而不是javascript设置值.
我想这是因为javascript是客户端而不是服务器端,但任何人都知道如何让这个工作
HTML
<div class="dropDown accomodation">
<label for="accomodationList">Type of accomodation</label>
<ul class="quicklinks" id="accomodationList">
<li><a href="#" title="Quicklinks" id="accomodationSelectList">All types
<!--[if IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul id="sub" onclick="dropDownSelected(event,'accomodation');">
<li><a href="#" id="val=-1$#$All types" >All types</a></li>
<li><a href="#" id="val=1$#$Villa" >Villa</a></li>
<li><a href="#" id="val=2$#$Studio" >Studio</a></li>
<li><a href="#" id="val=3$#$Apartment" >Apartment</a></li>
<li><a class="last" href="#" id="val=4$#$Rustic Properties" >Rustic Properties</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li></ul>
</div>
<input type="hidden" ID="accomodationAnswer" runat="server" />
Run Code Online (Sandbox Code Playgroud)
JavaScript的
if(isChildOf(document.getElementById(parentList),document.getElementById(targ.id)) == true)
{
document.getElementById(parentLi).innerHTML = …
Run Code Online (Sandbox Code Playgroud) c# ×5
java ×2
xml ×2
.net ×1
assemblies ×1
c ×1
c++ ×1
debugging ×1
eclipse ×1
emacs ×1
header ×1
java-me ×1
javascript ×1
linq ×1
linq-to-xml ×1
namespaces ×1
strongname ×1
swing ×1
tooltip ×1
winapi ×1
winforms ×1
xmldocument ×1