- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 JDialog
显示在屏幕上,我想根据条件模拟它的移动(从一个位置拖动到另一个位置)。有什么办法可以做到这一点吗?
最佳答案
请参阅下面的这段代码。我刚刚测试过它并且工作正常。这只是一个概念证明。
private void startDialog() {
final JDialog d = new JDialog(this, "Test", true);
d.getContentPane().add(new JLabel("Something"));
d.setBounds(100, 100, 400, 300);
Thread t = new Thread(new Runnable() {
public void run() {
for (int i = 0; i < 50; i++) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Point p = d.getLocation();
d.setLocation(p.x + 10, p.y + 10);
}
});
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
}
}
});
t.start();
d.setVisible(true);
}
您可以自己改进代码:
计时器
而不是常规线程
只需从任何 Swing 应用程序调用此方法即可工作。
关于java - 如何在JFC中模拟JDialog运动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12116091/
我在使用 JscrollPane 时遇到问题。尝试连续添加几个按钮,然后继续添加一组行,它最初显示得很好,但是一旦我单击滚动条,所有按钮都会被包裹在框架中。我想使用 setBounds (没有任何布局
请引导我阅读一个不错的 jfcunit 教程, 请帮助我了解如何使用它,因为我找不到更多信息, 最佳答案 为什么不简单地为 Swing 应用程序使用另一个单元测试框架?JFC Unit 自 2004
据我了解, TreeMap : 1. Insert O( logN ) 2. Delete O( logN ) 3. Retrieve O( logN ) HashMap : 1. Insert O(
所以,我应该 use SparseArray instead of HashMap为了性能: 然而,SparseArray不是 JCF 的一部分并且不执行 Collection也不List也不Map
众所周知,Java和J#中禁止“多重继承”。但是,您可以使用 Java 和 J# 实现多个接口(interface),例如 Runnable。那么,您将如何编写自己的类来同时继承 JFC 和 WFC
使用 NetBeans(java),我使用 JFileChooser 创建了一个 JDialog,当我尝试使用 ComboBox 打开 lnk 文件夹(以其他方式工作正常)时,会引发异常并且未打开该文
我是一名优秀的程序员,十分优秀!